From fe2d90c0e7f31f514b4bfc8d6a4dc38e25817278 Mon Sep 17 00:00:00 2001 From: SP193 Date: Wed, 13 Feb 2019 22:32:21 +0800 Subject: [PATCH] SMSTCPIP: fixed tcpip waiting for a signal when TCPIP core locking is used. Removed redundant memory free from tcpip_apimsg(). Moved call to sys_mbox_fetch() into tcpip_apimsg(), as every call to tcpip_apimsg() will be followed by a call to sys_mbox_fetch(). --- modules/network/SMSTCPIP/api_lib.c | 14 +------------- modules/network/SMSTCPIP/tcpip.c | 4 ++-- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/modules/network/SMSTCPIP/api_lib.c b/modules/network/SMSTCPIP/api_lib.c index 1299b72d2..ce6d15275 100644 --- a/modules/network/SMSTCPIP/api_lib.c +++ b/modules/network/SMSTCPIP/api_lib.c @@ -36,6 +36,7 @@ #include "lwip/opt.h" #include "lwip/api.h" #include "lwip/api_msg.h" +#include "lwip/tcpip.h" #include "lwip/memp.h" #include @@ -44,9 +45,6 @@ #include "smsutils.h" -extern void tcpip_apimsg(struct api_msg *apimsg); - - struct netbuf *netbuf_new(void) { struct netbuf *buf = memp_malloc(MEMP_NETBUF); @@ -169,7 +167,6 @@ struct msg->msg.msg.bc.port = proto; /* misusing the port field */ msg->msg.conn = conn; api_msg_post(msg); - sys_mbox_fetch(conn->mbox, NULL); memp_free(MEMP_API_MSG, msg); if (conn->err != ERR_OK) { @@ -196,7 +193,6 @@ err_t netconn_delete(struct netconn *conn) msg->type = API_MSG_DELCONN; msg->msg.conn = conn; api_msg_post(msg); - sys_mbox_fetch(conn->mbox, NULL); memp_free(MEMP_API_MSG, msg); /* Drain the recvmbox. */ @@ -304,7 +300,6 @@ err_t netconn_bind(struct netconn *conn, struct ip_addr *addr, msg->msg.msg.bc.ipaddr = addr; msg->msg.msg.bc.port = port; api_msg_post(msg); - sys_mbox_fetch(conn->mbox, NULL); memp_free(MEMP_API_MSG, msg); return conn->err; } @@ -334,7 +329,6 @@ err_t netconn_connect(struct netconn *conn, struct ip_addr *addr, msg->msg.msg.bc.ipaddr = addr; msg->msg.msg.bc.port = port; api_msg_post(msg); - sys_mbox_fetch(conn->mbox, NULL); memp_free(MEMP_API_MSG, msg); return conn->err; } @@ -353,7 +347,6 @@ err_t netconn_disconnect(struct netconn *conn) msg->type = API_MSG_DISCONNECT; msg->msg.conn = conn; api_msg_post(msg); - sys_mbox_fetch(conn->mbox, NULL); memp_free(MEMP_API_MSG, msg); return conn->err; } @@ -379,7 +372,6 @@ err_t netconn_listen(struct netconn *conn) msg->type = API_MSG_LISTEN; msg->msg.conn = conn; api_msg_post(msg); - sys_mbox_fetch(conn->mbox, NULL); memp_free(MEMP_API_MSG, msg); return conn->err; } @@ -476,7 +468,6 @@ netconn_recv(struct netconn *conn) } api_msg_post(msg); - sys_mbox_fetch(conn->mbox, NULL); memp_free(MEMP_API_MSG, msg); } else { sys_mbox_fetch(conn->recvmbox, (void **)&buf); @@ -509,7 +500,6 @@ err_t netconn_send(struct netconn *conn, struct netbuf *buf) msg->msg.msg.p = buf->p; api_msg_post(msg); - sys_mbox_fetch(conn->mbox, NULL); memp_free(MEMP_API_MSG, msg); return conn->err; } @@ -561,7 +551,6 @@ err_t netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy) LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_write: writing %d bytes (%d)\n", len, copy)); msg->msg.msg.w.len = len; api_msg_post(msg); - sys_mbox_fetch(conn->mbox, NULL); if (conn->err == ERR_OK) { dataptr = (void *)((u8_t *)dataptr + len); size -= len; @@ -595,7 +584,6 @@ err_t netconn_close(struct netconn *conn) msg->type = API_MSG_CLOSE; msg->msg.conn = conn; api_msg_post(msg); - sys_mbox_fetch(conn->mbox, NULL); if (conn->err == ERR_MEM && conn->sem != SYS_SEM_NULL) { sys_sem_wait(conn->sem); diff --git a/modules/network/SMSTCPIP/tcpip.c b/modules/network/SMSTCPIP/tcpip.c index 75367ddf4..6d244e9f8 100644 --- a/modules/network/SMSTCPIP/tcpip.c +++ b/modules/network/SMSTCPIP/tcpip.c @@ -149,9 +149,9 @@ void tcpip_apimsg(struct api_msg *apimsg) msg->type = TCPIP_MSG_API; msg->msg.apimsg = apimsg; sys_mbox_post(g_TCPIPMBox, msg); + sys_mbox_fetch(apimsg->msg.conn->mbox, NULL); - } else - memp_free(MEMP_API_MSG, apimsg); + } #endif /* LWIP_TCPIP_CORE_LOCKING */ } /* end tcpip_apimsg */