Fixed compiling with different options disabled (TCP/UDP), triggered by bug #29345; don't allocate acceptmbox if LWIP_TCP is disabled
This commit is contained in:
@@ -79,7 +79,9 @@ netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto, netconn_cal
|
||||
LWIP_ASSERT("freeing conn without freeing pcb", conn->pcb.tcp == NULL);
|
||||
LWIP_ASSERT("conn has no op_completed", sys_sem_valid(&conn->op_completed));
|
||||
LWIP_ASSERT("conn has no recvmbox", sys_mbox_valid(&conn->recvmbox));
|
||||
#if LWIP_TCP
|
||||
LWIP_ASSERT("conn->acceptmbox shouldn't exist", !sys_mbox_valid(&conn->acceptmbox));
|
||||
#endif /* LWIP_TCP */
|
||||
sys_sem_free(&conn->op_completed);
|
||||
sys_mbox_free(&conn->recvmbox);
|
||||
memp_free(MEMP_NETCONN, conn);
|
||||
@@ -268,6 +270,7 @@ netconn_listen_with_backlog(struct netconn *conn, u8_t backlog)
|
||||
err_t
|
||||
netconn_accept(struct netconn *conn, struct netconn **new_conn)
|
||||
{
|
||||
#if LWIP_TCP
|
||||
struct netconn *newconn;
|
||||
err_t err;
|
||||
#if TCP_LISTEN_BACKLOG
|
||||
@@ -313,6 +316,11 @@ netconn_accept(struct netconn *conn, struct netconn **new_conn)
|
||||
*new_conn = newconn;
|
||||
/* don't set conn->last_err: it's only ERR_OK, anyway */
|
||||
return ERR_OK;
|
||||
#else /* LWIP_TCP */
|
||||
LWIP_UNUSED_ARG(conn);
|
||||
LWIP_UNUSED_ARG(new_conn);
|
||||
return ERR_ARG;
|
||||
#endif /* LWIP_TCP */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,10 +335,12 @@ netconn_accept(struct netconn *conn, struct netconn **new_conn)
|
||||
static err_t
|
||||
netconn_recv_data(struct netconn *conn, void **new_buf)
|
||||
{
|
||||
struct api_msg msg;
|
||||
void *buf = NULL;
|
||||
u16_t len;
|
||||
err_t err;
|
||||
#if LWIP_TCP
|
||||
struct api_msg msg;
|
||||
#endif /* LWIP_TCP */
|
||||
|
||||
LWIP_ERROR("netconn_recv: invalid pointer", (new_buf != NULL), return ERR_ARG;);
|
||||
*new_buf = NULL;
|
||||
@@ -432,16 +442,18 @@ netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf)
|
||||
err_t
|
||||
netconn_recv(struct netconn *conn, struct netbuf **new_buf)
|
||||
{
|
||||
#if LWIP_TCP
|
||||
struct netbuf *buf = NULL;
|
||||
err_t err;
|
||||
#endif /* LWIP_TCP */
|
||||
|
||||
LWIP_ERROR("netconn_recv: invalid pointer", (new_buf != NULL), return ERR_ARG;);
|
||||
*new_buf = NULL;
|
||||
LWIP_ERROR("netconn_recv: invalid conn", (conn != NULL), return ERR_ARG;);
|
||||
LWIP_ERROR("netconn_accept: invalid recvmbox", sys_mbox_valid(&conn->recvmbox), return ERR_CONN;);
|
||||
|
||||
if (conn->type == NETCONN_TCP) {
|
||||
#if LWIP_TCP
|
||||
if (conn->type == NETCONN_TCP) {
|
||||
struct pbuf *p = NULL;
|
||||
/* This is not a listening netconn, since recvmbox is set */
|
||||
|
||||
@@ -465,8 +477,9 @@ netconn_recv(struct netconn *conn, struct netbuf **new_buf)
|
||||
*new_buf = buf;
|
||||
/* don't set conn->last_err: it's only ERR_OK, anyway */
|
||||
return ERR_OK;
|
||||
} else
|
||||
#endif /* LWIP_TCP */
|
||||
} else {
|
||||
{
|
||||
#if (LWIP_UDP || LWIP_RAW)
|
||||
return netconn_recv_data(conn, (void **)new_buf);
|
||||
#endif /* (LWIP_UDP || LWIP_RAW) */
|
||||
|
||||
@@ -602,7 +602,9 @@ netconn_alloc(enum netconn_type t, netconn_callback callback)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if LWIP_TCP
|
||||
sys_mbox_set_invalid(&conn->acceptmbox);
|
||||
#endif
|
||||
conn->state = NETCONN_NONE;
|
||||
#if LWIP_SOCKET
|
||||
/* initialize socket to -1 since 0 is a valid socket */
|
||||
@@ -636,8 +638,10 @@ netconn_free(struct netconn *conn)
|
||||
LWIP_ASSERT("PCB must be deallocated outside this function", conn->pcb.tcp == NULL);
|
||||
LWIP_ASSERT("recvmbox must be deallocated before calling this function",
|
||||
!sys_mbox_valid(&conn->recvmbox));
|
||||
#if LWIP_TCP
|
||||
LWIP_ASSERT("acceptmbox must be deallocated before calling this function",
|
||||
!sys_mbox_valid(&conn->acceptmbox));
|
||||
#endif /* LWIP_TCP */
|
||||
|
||||
sys_sem_free(&conn->op_completed);
|
||||
sys_sem_set_invalid(&conn->op_completed);
|
||||
@@ -657,13 +661,16 @@ static void
|
||||
netconn_drain(struct netconn *conn)
|
||||
{
|
||||
void *mem;
|
||||
#if LWIP_TCP
|
||||
struct pbuf *p;
|
||||
#endif /* LWIP_TCP */
|
||||
|
||||
/* This runs in tcpip_thread, so we don't need to lock against rx packets */
|
||||
|
||||
/* Delete and drain the recvmbox. */
|
||||
if (sys_mbox_valid(&conn->recvmbox)) {
|
||||
while (sys_mbox_tryfetch(&conn->recvmbox, &mem) != SYS_MBOX_EMPTY) {
|
||||
#if LWIP_TCP
|
||||
if (conn->type == NETCONN_TCP) {
|
||||
if(mem != NULL) {
|
||||
p = (struct pbuf*)mem;
|
||||
@@ -673,7 +680,9 @@ netconn_drain(struct netconn *conn)
|
||||
}
|
||||
pbuf_free(p);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
#endif /* LWIP_TCP */
|
||||
{
|
||||
netbuf_delete((struct netbuf *)mem);
|
||||
}
|
||||
}
|
||||
@@ -682,6 +691,7 @@ netconn_drain(struct netconn *conn)
|
||||
}
|
||||
|
||||
/* Delete and drain the acceptmbox. */
|
||||
#if LWIP_TCP
|
||||
if (sys_mbox_valid(&conn->acceptmbox)) {
|
||||
while (sys_mbox_tryfetch(&conn->acceptmbox, &mem) != SYS_MBOX_EMPTY) {
|
||||
/* Only tcp pcbs have an acceptmbox, so no need to check conn->type */
|
||||
@@ -694,6 +704,7 @@ netconn_drain(struct netconn *conn)
|
||||
sys_mbox_free(&conn->acceptmbox);
|
||||
sys_mbox_set_invalid(&conn->acceptmbox);
|
||||
}
|
||||
#endif /* LWIP_TCP */
|
||||
}
|
||||
|
||||
#if LWIP_TCP
|
||||
|
||||
Reference in New Issue
Block a user