summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-04-06 10:11:04 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-04-06 10:12:14 +0300
commit1da840464759f73efbc42238a91733f436991eaf (patch)
tree887fb733fac798d4b7c2a4e1f74573ccb61a8d85
parentfaf333c04f3dddb9ca1a6b7fc5ff74eabcfe51b0 (diff)
downloadmicropython-1da840464759f73efbc42238a91733f436991eaf.tar.gz
micropython-1da840464759f73efbc42238a91733f436991eaf.zip
modusocket: Handle a case when recv_q is empty when EOF is signaled.
In this case, we can mark socket as closed directly.
-rw-r--r--zephyr/modusocket.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/zephyr/modusocket.c b/zephyr/modusocket.c
index 0bcbbce604..a5ed5c1b01 100644
--- a/zephyr/modusocket.c
+++ b/zephyr/modusocket.c
@@ -145,9 +145,14 @@ static void sock_received_cb(struct net_context *context, struct net_buf *net_bu
// if net_buf == NULL, EOF
if (net_buf == NULL) {
struct net_buf *last_buf = _k_fifo_peek_tail(&socket->recv_q);
- // We abuse "buf_sent" flag to store EOF flag
- net_nbuf_set_buf_sent(last_buf, true);
- DEBUG_printf("Set EOF flag on %p\n", last_buf);
+ if (last_buf == NULL) {
+ socket->state = STATE_PEER_CLOSED;
+ DEBUG_printf("Marked socket %p as peer-closed\n", socket);
+ } else {
+ // We abuse "buf_sent" flag to store EOF flag
+ net_nbuf_set_buf_sent(last_buf, true);
+ DEBUG_printf("Set EOF flag on %p\n", last_buf);
+ }
return;
}