Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit a3008e4

Browse files
author
Paul Sokolovsky
committed
zephyr/modusocket: First step to switch to alternative FIFO processing.
Here we wait for non-empty FIFO, and then directly access/drop its head element.
1 parent 88c51c3 commit a3008e4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

zephyr/modusocket.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,14 @@ STATIC mp_uint_t sock_read(mp_obj_t self_in, void *buf, mp_uint_t max_len, int *
399399
}
400400

401401
DEBUG_printf("TCP recv: no cur_pkt, getting\n");
402-
struct net_pkt *pkt = k_fifo_get(&socket->recv_q, K_FOREVER);
403-
402+
_k_fifo_wait_non_empty(&socket->recv_q, K_FOREVER);
403+
struct net_pkt *pkt = _k_fifo_peek_head(&socket->recv_q);
404404
if (pkt == NULL) {
405405
DEBUG_printf("TCP recv: NULL return from fifo\n");
406406
continue;
407407
}
408+
// Drop head packet from queue
409+
k_fifo_get(&socket->recv_q, K_NO_WAIT);
408410

409411
DEBUG_printf("TCP recv: new cur_pkt: %p\n", pkt);
410412
socket->cur_pkt = pkt;

0 commit comments

Comments
 (0)