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.
This commit is contained in:
parent
1fe0f678f8
commit
868453d3d8
|
@ -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) {
|
} else if (sock_type == SOCK_STREAM) {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
|
if (socket->cur_buf == NULL) {
|
||||||
if (socket->state == STATE_PEER_CLOSED) {
|
if (socket->state == STATE_PEER_CLOSED) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (socket->cur_buf == NULL) {
|
|
||||||
DEBUG_printf("TCP recv: no cur_buf, getting\n");
|
DEBUG_printf("TCP recv: no cur_buf, getting\n");
|
||||||
struct net_buf *net_buf = k_fifo_get(&socket->recv_q, K_FOREVER);
|
struct net_buf *net_buf = k_fifo_get(&socket->recv_q, K_FOREVER);
|
||||||
// Restore ->frags overwritten by fifo
|
// Restore ->frags overwritten by fifo
|
||||||
|
|
Loading…
Reference in New Issue