lwip_sock: re-issue receive events if there are still received messages
... after `*_recv()` or `*_accept()` was called. This prevents a client from needing to call `*_recv()` or `*_accept()` in a loop.
This commit is contained in:
parent
fcd36f7b77
commit
ef1d458089
@ -548,6 +548,13 @@ int lwip_sock_recv(struct netconn *conn, uint32_t timeout, struct netbuf **buf)
|
||||
/* unset flags */
|
||||
#if LWIP_SO_RCVTIMEO
|
||||
netconn_set_recvtimeout(conn, 0);
|
||||
#endif
|
||||
#if IS_ACTIVE(SOCK_HAS_ASYNC)
|
||||
lwip_sock_base_t *sock = netconn_get_callback_arg(conn);
|
||||
|
||||
if (sock && sock->async_cb.gen && cib_avail(&conn->recvmbox.mbox.cib)) {
|
||||
sock->async_cb.gen(sock, SOCK_ASYNC_MSG_RECV, sock->async_cb_arg);
|
||||
}
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -254,6 +254,13 @@ int sock_tcp_accept(sock_tcp_queue_t *queue, sock_tcp_t **sock,
|
||||
}
|
||||
#if LWIP_SO_RCVTIMEO
|
||||
netconn_set_recvtimeout(queue->base.conn, 0);
|
||||
#endif
|
||||
#if IS_ACTIVE(SOCK_HAS_ASYNC)
|
||||
if (queue->base.async_cb.gen &&
|
||||
cib_avail(&queue->base.conn->acceptmbox.mbox.cib)) {
|
||||
queue->base.async_cb.gen(&queue->base, SOCK_ASYNC_CONN_RECV,
|
||||
queue->base.async_cb_arg);
|
||||
}
|
||||
#endif
|
||||
mutex_unlock(&queue->mutex);
|
||||
return res;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user