diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-04-26 09:06:58 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-04-26 09:14:41 +0300 |
commit | 868453d3d83ea8d3ed161bd20f2f6cb59a396562 (patch) | |
tree | 1e51617b938087e426ffcfdb0e3fa3cb3703b2a7 /zephyr | |
parent | 1fe0f678f86507781989e8db5c005df602968e13 (diff) | |
download | micropython-868453d3d83ea8d3ed161bd20f2f6cb59a396562.tar.gz micropython-868453d3d83ea8d3ed161bd20f2f6cb59a396562.zip |
zephyr/modusocket: sock_read: Check socket status only at the start of packet.
Otherwise, if we already have a packet in progress, finish it first, before
check "peer closed" status.
Diffstat (limited to 'zephyr')
-rw-r--r-- | zephyr/modusocket.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/zephyr/modusocket.c b/zephyr/modusocket.c index 2fa04a64ac..5700cc4bd2 100644 --- a/zephyr/modusocket.c +++ b/zephyr/modusocket.c @@ -373,11 +373,12 @@ STATIC mp_uint_t sock_read(mp_obj_t self_in, void *buf, mp_uint_t max_len, int * } else if (sock_type == SOCK_STREAM) { do { - if (socket->state == STATE_PEER_CLOSED) { - return 0; - } if (socket->cur_buf == NULL) { + if (socket->state == STATE_PEER_CLOSED) { + return 0; + } + DEBUG_printf("TCP recv: no cur_buf, getting\n"); struct net_buf *net_buf = k_fifo_get(&socket->recv_q, K_FOREVER); // Restore ->frags overwritten by fifo |