diff options
author | Damien George <damien.p.george@gmail.com> | 2019-01-31 11:22:03 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-01-31 11:22:03 +1100 |
commit | 2a7a307baaa8b5a1fbd30ccdd8fa393ec0341888 (patch) | |
tree | 6453df192585e53ae050bcdc45a909dd3d80697f | |
parent | 4bed17e78615360c018103ef3c3c2e204a9c9a46 (diff) |
extmod/modlwip: Add support for polling UDP sockets for writability.
-rw-r--r-- | extmod/modlwip.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/extmod/modlwip.c b/extmod/modlwip.c index 73f167955..84a1bd3c1 100644 --- a/extmod/modlwip.c +++ b/extmod/modlwip.c @@ -1231,9 +1231,15 @@ STATIC mp_uint_t lwip_socket_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_ } } - // Note: pcb.tcp==NULL if state<0, and in this case we can't call tcp_sndbuf - if (flags & MP_STREAM_POLL_WR && socket->pcb.tcp != NULL && tcp_sndbuf(socket->pcb.tcp) > 0) { - ret |= MP_STREAM_POLL_WR; + if (flags & MP_STREAM_POLL_WR) { + if (socket->type == MOD_NETWORK_SOCK_DGRAM && socket->pcb.udp != NULL) { + // UDP socket is writable + ret |= MP_STREAM_POLL_WR; + } else if (socket->pcb.tcp != NULL && tcp_sndbuf(socket->pcb.tcp) > 0) { + // TCP socket is writable + // Note: pcb.tcp==NULL if state<0, and in this case we can't call tcp_sndbuf + ret |= MP_STREAM_POLL_WR; + } } if (socket->state == STATE_NEW) { |