mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-17 17:10:03 +00:00
api_lib.c: Implement SO_RCVTIMEO for accept and recv on TCP connections, such present in patch #5959.
This commit is contained in:
parent
a330917ee8
commit
a3fdc33f88
@ -19,6 +19,10 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ New features:
|
||||||
|
|
||||||
|
2007-05-23 Frédéric Bernon
|
||||||
|
* api_lib.c, sockets.c: Implement SO_RCVTIMEO for accept and recv on TCP
|
||||||
|
connections, such present in patch #5959.
|
||||||
|
|
||||||
2007-05-23 Frédéric Bernon
|
2007-05-23 Frédéric Bernon
|
||||||
* api.h, api_lib.c, api_msg.c, sockets.c: group the different NETCONN_UDPxxx
|
* api.h, api_lib.c, api_msg.c, sockets.c: group the different NETCONN_UDPxxx
|
||||||
code in only one part...
|
code in only one part...
|
||||||
|
@ -352,8 +352,7 @@ netconn_bind(struct netconn *conn, struct ip_addr *addr, u16_t port)
|
|||||||
|
|
||||||
LWIP_ASSERT("netconn_bind: invalid conn", (conn != NULL));
|
LWIP_ASSERT("netconn_bind: invalid conn", (conn != NULL));
|
||||||
|
|
||||||
if (conn->type != NETCONN_TCP &&
|
if (conn->type != NETCONN_TCP && conn->recvmbox == SYS_MBOX_NULL) {
|
||||||
conn->recvmbox == SYS_MBOX_NULL) {
|
|
||||||
if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
@ -424,7 +423,14 @@ netconn_accept(struct netconn *conn)
|
|||||||
LWIP_ASSERT("netconn_accept: invalid conn", (conn != NULL));
|
LWIP_ASSERT("netconn_accept: invalid conn", (conn != NULL));
|
||||||
LWIP_ASSERT("netconn_accept: invalid acceptmbox", (conn->acceptmbox != SYS_MBOX_NULL));
|
LWIP_ASSERT("netconn_accept: invalid acceptmbox", (conn->acceptmbox != SYS_MBOX_NULL));
|
||||||
|
|
||||||
|
#if LWIP_SO_RCVTIMEO
|
||||||
|
if (sys_arch_mbox_fetch(conn->acceptmbox, (void *)&newconn, conn->recv_timeout)==SYS_ARCH_TIMEOUT) {
|
||||||
|
newconn = NULL;
|
||||||
|
}
|
||||||
|
#else
|
||||||
sys_arch_mbox_fetch(conn->acceptmbox, (void *)&newconn, 0);
|
sys_arch_mbox_fetch(conn->acceptmbox, (void *)&newconn, 0);
|
||||||
|
#endif /* LWIP_SO_RCVTIMEO*/
|
||||||
|
|
||||||
/* Register event with callback */
|
/* Register event with callback */
|
||||||
if (conn->callback)
|
if (conn->callback)
|
||||||
(*conn->callback)(conn, NETCONN_EVT_RCVMINUS, 0);
|
(*conn->callback)(conn, NETCONN_EVT_RCVMINUS, 0);
|
||||||
@ -467,7 +473,13 @@ netconn_recv(struct netconn *conn)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LWIP_SO_RCVTIMEO
|
||||||
|
if (sys_arch_mbox_fetch(conn->recvmbox, (void *)&p, conn->recv_timeout)==SYS_ARCH_TIMEOUT) {
|
||||||
|
p = NULL;
|
||||||
|
}
|
||||||
|
#else
|
||||||
sys_arch_mbox_fetch(conn->recvmbox, (void *)&p, 0);
|
sys_arch_mbox_fetch(conn->recvmbox, (void *)&p, 0);
|
||||||
|
#endif /* LWIP_SO_RCVTIMEO*/
|
||||||
|
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
len = p->tot_len;
|
len = p->tot_len;
|
||||||
|
Loading…
Reference in New Issue
Block a user