Skip to content

Commit

Permalink
SMSTCPIP: fixed tcpip waiting for a signal when TCPIP core locking is…
Browse files Browse the repository at this point in the history
… 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().
  • Loading branch information
sp193 committed Feb 13, 2019
1 parent 6836e5e commit fe2d90c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
14 changes: 1 addition & 13 deletions modules/network/SMSTCPIP/api_lib.c
Expand Up @@ -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 <intrman.h>
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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. */
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions modules/network/SMSTCPIP/tcpip.c
Expand Up @@ -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 */
Expand Down

0 comments on commit fe2d90c

Please sign in to comment.