From 7b3e158c921d62914f451c9d20a6e2dc8afc282d Mon Sep 17 00:00:00 2001 From: davidhaas Date: Tue, 11 Feb 2003 21:00:14 +0000 Subject: [PATCH] sys_thread_new() now returns the thread (request from Marc Boucher). Removed some unused .h files in coldfire port. Support LWIP_DIAG and LWIP_ASSERT in coldfire (sort of). Fix to last api fix to make sure select() is triggered, even when there has been a FIN. Allow build of unixsim from cygwin by specifying "make ARCH=cygwin" or from linux by specifying "make ARCH=linux". --- src/api/api_lib.c | 16 +++++++++++----- src/api/api_msg.c | 16 ++++++++++------ src/include/lwip/sys.h | 2 +- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/api/api_lib.c b/src/api/api_lib.c index 02d284b1..fd2c9f2a 100644 --- a/src/api/api_lib.c +++ b/src/api/api_lib.c @@ -467,6 +467,7 @@ netconn_recv(struct netconn *conn) struct api_msg *msg; struct netbuf *buf; struct pbuf *p; + u16_t len; if(conn == NULL) { return NULL; @@ -497,12 +498,17 @@ netconn_recv(struct netconn *conn) sys_mbox_fetch(conn->recvmbox, (void **)&p); - if (p != NULL) { - conn->recv_avail -= p->tot_len; - /* Register event with callback */ - if (conn->callback) - (*conn->callback)(conn, NETCONN_EVT_RCVMINUS, p->tot_len); + if (p != NULL) + { + len = p->tot_len; + conn->recv_avail -= len; } + else + len = 0; + + /* Register event with callback */ + if (conn->callback) + (*conn->callback)(conn, NETCONN_EVT_RCVMINUS, len); /* If we are closed, we indicate that we no longer wish to recieve data by setting conn->recvmbox to SYS_MBOX_NULL. */ diff --git a/src/api/api_msg.c b/src/api/api_msg.c index c3b84375..c9924212 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -42,7 +42,8 @@ static err_t recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) { struct netconn *conn; - + u16_t len; + conn = arg; if(conn == NULL) { @@ -54,11 +55,14 @@ recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) conn->err = err; if (p != NULL) { - conn->recv_avail += p->tot_len; - /* Register event with callback */ - if (conn->callback) - (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, p->tot_len); - } + len = p->tot_len; + conn->recv_avail += len; + } + else + len = 0; + /* Register event with callback */ + if (conn->callback) + (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, len); sys_mbox_post(conn->recvmbox, p); } return ERR_OK; diff --git a/src/include/lwip/sys.h b/src/include/lwip/sys.h index 46669868..0aeac0fc 100644 --- a/src/include/lwip/sys.h +++ b/src/include/lwip/sys.h @@ -114,7 +114,7 @@ u32_t sys_arch_protect(void); void sys_arch_unprotect(u32_t pval); /* Thread functions. */ -void sys_thread_new(void (* thread)(void *arg), void *arg); +sys_thread_t sys_thread_new(void (* thread)(void *arg), void *arg); /* The following functions are used only in Unix code, and can be omitted when porting the stack. */