sys.h, sys.c, api_lib.c, tcpip.c: remove sys_mbox_fetch_timeout() (was only used for LWIP_SO_RCVTIMEO option) and use sys_arch_mbox_fetch() instead of sys_mbox_fetch() in api files. Now, users SHOULD NOT use internal lwIP features like "sys_timeout" in their application threads.

This commit is contained in:
fbernon 2007-05-22 20:51:34 +00:00
parent 0aaf69769f
commit 2ff620e1b5
5 changed files with 18 additions and 62 deletions

View File

@ -11,10 +11,6 @@ FUTURE
a thread subsystem. Either PPP needs to be moved to contrib/ports/??? a thread subsystem. Either PPP needs to be moved to contrib/ports/???
or rearranged to be more generic. or rearranged to be more generic.
* TODO: review the the sequential netconn and socket API (lwip/src/api)
for bugs and performance issues. Frequent system calls (e.g. sys_mbox_fetch)
slooow things down considerably.
HISTORY HISTORY
(CVS HEAD) (CVS HEAD)
@ -170,6 +166,12 @@ HISTORY
* tcp.c: Fixed bug #1895 (tcp_bind not correct) by introducing a list of * tcp.c: Fixed bug #1895 (tcp_bind not correct) by introducing a list of
bound but unconnected (and non-listening) tcp_pcbs. bound but unconnected (and non-listening) tcp_pcbs.
2007-05-22 Frédéric Bernon
* sys.h, sys.c, api_lib.c, tcpip.c: remove sys_mbox_fetch_timeout() (was only
used for LWIP_SO_RCVTIMEO option) and use sys_arch_mbox_fetch() instead of
sys_mbox_fetch() in api files. Now, users SHOULD NOT use internal lwIP features
like "sys_timeout" in their application threads.
2007-05-22 Frédéric Bernon 2007-05-22 Frédéric Bernon
* api.h, api_lib.c, api_msg.h, api_msg.c: change the struct api_msg_msg to see * api.h, api_lib.c, api_msg.h, api_msg.c: change the struct api_msg_msg to see
which parameters are used by which do_xxx function, and to avoid "misusing" which parameters are used by which do_xxx function, and to avoid "misusing"

View File

@ -443,7 +443,7 @@ netconn_accept(struct netconn *conn)
return NULL; return NULL;
} }
sys_mbox_fetch(conn->acceptmbox, (void *)&newconn); sys_arch_mbox_fetch(conn->acceptmbox, (void *)&newconn, 0);
/* Register event with callback */ /* Register event with callback */
if (conn->callback) if (conn->callback)
(*conn->callback)(conn, NETCONN_EVT_RCVMINUS, 0); (*conn->callback)(conn, NETCONN_EVT_RCVMINUS, 0);
@ -488,7 +488,7 @@ netconn_recv(struct netconn *conn)
return NULL; return NULL;
} }
sys_mbox_fetch(conn->recvmbox, (void *)&p); sys_arch_mbox_fetch(conn->recvmbox, (void *)&p, 0);
if (p != NULL) if (p != NULL)
{ {
@ -529,9 +529,9 @@ netconn_recv(struct netconn *conn)
} else { } else {
#if (LWIP_UDP || LWIP_RAW) #if (LWIP_UDP || LWIP_RAW)
#if LWIP_SO_RCVTIMEO #if LWIP_SO_RCVTIMEO
sys_mbox_fetch_timeout(conn->recvmbox, (void *)&buf, conn->recv_timeout); sys_arch_mbox_fetch(conn->recvmbox, (void *)&buf, conn->recv_timeout);
#else #else
sys_mbox_fetch(conn->recvmbox, (void *)&buf); sys_arch_mbox_fetch(conn->recvmbox, (void *)&buf, 0);
#endif /* LWIP_SO_RCVTIMEO*/ #endif /* LWIP_SO_RCVTIMEO*/
if (buf!=NULL) if (buf!=NULL)
{ conn->recv_avail -= buf->p->tot_len; { conn->recv_avail -= buf->p->tot_len;

View File

@ -321,7 +321,7 @@ tcpip_apimsg(struct api_msg *apimsg)
msg.type = TCPIP_MSG_API; msg.type = TCPIP_MSG_API;
msg.msg.apimsg = apimsg; msg.msg.apimsg = apimsg;
sys_mbox_post(mbox, &msg); sys_mbox_post(mbox, &msg);
sys_mbox_fetch(apimsg->msg.conn->mbox, NULL); sys_arch_mbox_fetch(apimsg->msg.conn->mbox, NULL, 0);
return ERR_OK; return ERR_OK;
} }
return ERR_VAL; return ERR_VAL;

View File

@ -44,11 +44,8 @@ struct sswt_cb
}; };
#if LWIP_SO_RCVTIMEO void
void sys_mbox_fetch_timeout(sys_mbox_t mbox, void **msg, u32_t timeout) sys_mbox_fetch(sys_mbox_t mbox, void **msg)
#else
void sys_mbox_fetch(sys_mbox_t mbox, void **msg)
#endif /* LWIP_SO_RCVTIMEO */
{ {
u32_t time; u32_t time;
struct sys_timeouts *timeouts; struct sys_timeouts *timeouts;
@ -60,38 +57,15 @@ void sys_mbox_fetch(sys_mbox_t mbox, void **msg)
timeouts = sys_arch_timeouts(); timeouts = sys_arch_timeouts();
if (!timeouts || !timeouts->next) { if (!timeouts || !timeouts->next) {
#if LWIP_SO_RCVTIMEO
time = sys_arch_mbox_fetch(mbox, msg, timeout);
#else
time = sys_arch_mbox_fetch(mbox, msg, 0); time = sys_arch_mbox_fetch(mbox, msg, 0);
#endif /* LWIP_SO_RCVTIMEO */
} else { } else {
if (timeouts->next->time > 0) { if (timeouts->next->time > 0) {
#if LWIP_SO_RCVTIMEO
time = sys_arch_mbox_fetch(mbox, msg, (timeout?((timeout<timeouts->next->time)?timeout:timeouts->next->time):timeouts->next->time));
#else
time = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time); time = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time);
#endif /* LWIP_SO_RCVTIMEO */
} else { } else {
time = SYS_ARCH_TIMEOUT; time = SYS_ARCH_TIMEOUT;
} }
if (time == SYS_ARCH_TIMEOUT) { if (time == SYS_ARCH_TIMEOUT) {
#if LWIP_SO_RCVTIMEO
if ((timeout) && (timeout<timeouts->next->time)) {
/* If time == SYS_ARCH_TIMEOUT, and we have wait "fetch's timeout" and not "timer's timeout",
The timeout variable is the number of milliseconds we have waited for the message. */
timeouts->next->time -= timeout;
} else {
/* The timeouts->next->time variable is the number of milliseconds we have waited for the message. */
if (timeouts->next->time < timeout) {
timeout -= timeouts->next->time;
} else {
/* either timeout == 0, or timeout must == timeouts->next->time */
if (timeout) timeout = SYS_ARCH_TIMEOUT;
}
#endif /* LWIP_SO_RCVTIMEO */
/* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message /* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message
could be fetched. We should now call the timeout handler and could be fetched. We should now call the timeout handler and
deallocate the memory allocated for the timeout. */ deallocate the memory allocated for the timeout. */
@ -105,15 +79,8 @@ void sys_mbox_fetch(sys_mbox_t mbox, void **msg)
h(arg); h(arg);
} }
#if LWIP_SO_RCVTIMEO
if (timeout != SYS_ARCH_TIMEOUT)
#endif /* LWIP_SO_RCVTIMEO */
/* We try again to fetch a message from the mbox. */ /* We try again to fetch a message from the mbox. */
goto again; goto again;
#if LWIP_SO_RCVTIMEO
}
#endif /* LWIP_SO_RCVTIMEO */
} else { } else {
/* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout /* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout
occured. The time variable is set to the number of occured. The time variable is set to the number of
@ -124,14 +91,7 @@ void sys_mbox_fetch(sys_mbox_t mbox, void **msg)
timeouts->next->time = 0; timeouts->next->time = 0;
} }
} }
} }
#if LWIP_SO_RCVTIMEO
if ((time == SYS_ARCH_TIMEOUT) && (msg))
{ (*msg)=NULL;
}
#endif /* LWIP_SO_RCVTIMEO */
} }
void void

View File

@ -58,7 +58,6 @@ struct sys_timeo {u8_t dummy;};
#define sys_arch_sem_wait(s,t) #define sys_arch_sem_wait(s,t)
#define sys_sem_free(s) #define sys_sem_free(s)
#define sys_mbox_new() 0 #define sys_mbox_new() 0
#define sys_mbox_fetch_timeout(m,d,t)
#define sys_mbox_fetch(m,d) #define sys_mbox_fetch(m,d)
#define sys_mbox_post(m,d) #define sys_mbox_post(m,d)
#define sys_mbox_free(m) #define sys_mbox_free(m)
@ -132,12 +131,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg);
/* For now, we map straight to sys_arch implementation. */ /* For now, we map straight to sys_arch implementation. */
#define sys_mbox_tryfetch(mbox, msg) sys_arch_mbox_tryfetch(mbox, msg) #define sys_mbox_tryfetch(mbox, msg) sys_arch_mbox_tryfetch(mbox, msg)
void sys_mbox_free(sys_mbox_t mbox); void sys_mbox_free(sys_mbox_t mbox);
#if LWIP_SO_RCVTIMEO
void sys_mbox_fetch_timeout(sys_mbox_t mbox, void **msg, u32_t timeout);
#define sys_mbox_fetch(m,d) sys_mbox_fetch_timeout(m,d,0)
#else
void sys_mbox_fetch(sys_mbox_t mbox, void **msg); void sys_mbox_fetch(sys_mbox_t mbox, void **msg);
#endif /* LWIP_SO_RCVTIMEO */
/* Thread functions. */ /* Thread functions. */
sys_thread_t sys_thread_new(void (* thread)(void *arg), void *arg, int prio); sys_thread_t sys_thread_new(void (* thread)(void *arg), void *arg, int prio);