Skip to content

Commit 868453d

Browse files
committed
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.
1 parent 1fe0f67 commit 868453d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

zephyr/modusocket.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,12 @@ STATIC mp_uint_t sock_read(mp_obj_t self_in, void *buf, mp_uint_t max_len, int *
373373
} else if (sock_type == SOCK_STREAM) {
374374

375375
do {
376-
if (socket->state == STATE_PEER_CLOSED) {
377-
return 0;
378-
}
379376

380377
if (socket->cur_buf == NULL) {
378+
if (socket->state == STATE_PEER_CLOSED) {
379+
return 0;
380+
}
381+
381382
DEBUG_printf("TCP recv: no cur_buf, getting\n");
382383
struct net_buf *net_buf = k_fifo_get(&socket->recv_q, K_FOREVER);
383384
// Restore ->frags overwritten by fifo

0 commit comments

Comments
 (0)