Skip to content
Snippets Groups Projects
Commit 1da84046 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

modusocket: Handle a case when recv_q is empty when EOF is signaled.

In this case, we can mark socket as closed directly.
parent faf333c0
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment