mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
netconn_accept: reduce number of ifdefs
This commit is contained in:
parent
4cc953d0e3
commit
fa55458c42
@ -81,6 +81,16 @@
|
|||||||
#define API_MSG_VAR_ALLOC_RETURN_NULL(name) API_VAR_ALLOC(struct api_msg, MEMP_API_MSG, name, NULL)
|
#define API_MSG_VAR_ALLOC_RETURN_NULL(name) API_VAR_ALLOC(struct api_msg, MEMP_API_MSG, name, NULL)
|
||||||
#define API_MSG_VAR_FREE(name) API_VAR_FREE(MEMP_API_MSG, name)
|
#define API_MSG_VAR_FREE(name) API_VAR_FREE(MEMP_API_MSG, name)
|
||||||
|
|
||||||
|
#if TCP_LISTEN_BACKLOG
|
||||||
|
/* need to allocate API message for accept so empty message pool does not result in event loss
|
||||||
|
* see bug #47512: MPU_COMPATIBLE may fail on empty pool */
|
||||||
|
#define API_MSG_VAR_ALLOC_ACCEPT(msg) API_MSG_VAR_ALLOC(msg)
|
||||||
|
#define API_MSG_VAR_FREE_ACCEPT(msg) API_MSG_VAR_FREE(msg)
|
||||||
|
#else /* TCP_LISTEN_BACKLOG */
|
||||||
|
#define API_MSG_VAR_ALLOC_ACCEPT(msg)
|
||||||
|
#define API_MSG_VAR_FREE_ACCEPT(msg)
|
||||||
|
#endif /* TCP_LISTEN_BACKLOG */
|
||||||
|
|
||||||
static err_t netconn_close_shutdown(struct netconn *conn, u8_t how);
|
static err_t netconn_close_shutdown(struct netconn *conn, u8_t how);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -446,25 +456,17 @@ netconn_accept(struct netconn *conn, struct netconn **new_conn)
|
|||||||
return ERR_CLSD;
|
return ERR_CLSD;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TCP_LISTEN_BACKLOG
|
API_MSG_VAR_ALLOC_ACCEPT(msg);
|
||||||
/* need to allocate API message here so empty message pool does not result in event loss
|
|
||||||
* see bug #47512: MPU_COMPATIBLE may fail on empty pool */
|
|
||||||
API_MSG_VAR_ALLOC(msg);
|
|
||||||
#endif /* TCP_LISTEN_BACKLOG */
|
|
||||||
|
|
||||||
if (netconn_is_nonblocking(conn)) {
|
if (netconn_is_nonblocking(conn)) {
|
||||||
if (sys_arch_mbox_tryfetch(&conn->acceptmbox, &accept_ptr) == SYS_ARCH_TIMEOUT) {
|
if (sys_arch_mbox_tryfetch(&conn->acceptmbox, &accept_ptr) == SYS_ARCH_TIMEOUT) {
|
||||||
#if TCP_LISTEN_BACKLOG
|
API_MSG_VAR_FREE_ACCEPT(msg);
|
||||||
API_MSG_VAR_FREE(msg);
|
|
||||||
#endif /* TCP_LISTEN_BACKLOG */
|
|
||||||
return ERR_WOULDBLOCK;
|
return ERR_WOULDBLOCK;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if LWIP_SO_RCVTIMEO
|
#if LWIP_SO_RCVTIMEO
|
||||||
if (sys_arch_mbox_fetch(&conn->acceptmbox, &accept_ptr, conn->recv_timeout) == SYS_ARCH_TIMEOUT) {
|
if (sys_arch_mbox_fetch(&conn->acceptmbox, &accept_ptr, conn->recv_timeout) == SYS_ARCH_TIMEOUT) {
|
||||||
#if TCP_LISTEN_BACKLOG
|
API_MSG_VAR_FREE_ACCEPT(msg);
|
||||||
API_MSG_VAR_FREE(msg);
|
|
||||||
#endif /* TCP_LISTEN_BACKLOG */
|
|
||||||
return ERR_TIMEOUT;
|
return ERR_TIMEOUT;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -476,16 +478,12 @@ netconn_accept(struct netconn *conn, struct netconn **new_conn)
|
|||||||
|
|
||||||
if (lwip_netconn_is_err_msg(accept_ptr, &err)) {
|
if (lwip_netconn_is_err_msg(accept_ptr, &err)) {
|
||||||
/* a connection has been aborted: e.g. out of pcbs or out of netconns during accept */
|
/* a connection has been aborted: e.g. out of pcbs or out of netconns during accept */
|
||||||
#if TCP_LISTEN_BACKLOG
|
API_MSG_VAR_FREE_ACCEPT(msg);
|
||||||
API_MSG_VAR_FREE(msg);
|
|
||||||
#endif /* TCP_LISTEN_BACKLOG */
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (accept_ptr == NULL) {
|
if (accept_ptr == NULL) {
|
||||||
/* connection has been aborted */
|
/* connection has been aborted */
|
||||||
#if TCP_LISTEN_BACKLOG
|
API_MSG_VAR_FREE_ACCEPT(msg);
|
||||||
API_MSG_VAR_FREE(msg);
|
|
||||||
#endif /* TCP_LISTEN_BACKLOG */
|
|
||||||
return ERR_CLSD;
|
return ERR_CLSD;
|
||||||
}
|
}
|
||||||
newconn = (struct netconn *)accept_ptr;
|
newconn = (struct netconn *)accept_ptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user