* sys.h, api_lib.c: Provide new sys_mbox_tryfetch function.

Require ports to provide new sys_arch_mbox_tryfetch function to get
    a message if one is there, otherwise return with SYS_MBOX_EMPTY.
This commit is contained in:
jifl 2007-04-11 15:41:03 +00:00
parent 05909d6fa7
commit 0c94f22ded
3 changed files with 16 additions and 2 deletions

View File

@ -23,6 +23,10 @@ HISTORY
++ New features: ++ New features:
2007-04-11 Jonathan Larmour
* sys.h, api_lib.c: Provide new sys_mbox_tryfetch function. Require ports to provide new
sys_arch_mbox_tryfetch function to get a message if one is there.
2007-04-06 Frédéric Bernon, Simon Goldschmidt 2007-04-06 Frédéric Bernon, Simon Goldschmidt
* opt.h, tcpip.h, tcpip.c, netifapi.h, netifapi.c: New configuration option LWIP_NETIF_API * opt.h, tcpip.h, tcpip.c, netifapi.h, netifapi.c: New configuration option LWIP_NETIF_API
allow to use thread-safe functions to add/remove netif in list, and to start/stop dhcp allow to use thread-safe functions to add/remove netif in list, and to start/stop dhcp

View File

@ -284,7 +284,7 @@ netconn_delete(struct netconn *conn)
/* Drain the recvmbox. */ /* Drain the recvmbox. */
if (conn->recvmbox != SYS_MBOX_NULL) { if (conn->recvmbox != SYS_MBOX_NULL) {
while (sys_arch_mbox_fetch(conn->recvmbox, &mem, 1) != SYS_ARCH_TIMEOUT) { while (sys_mbox_tryfetch(conn->recvmbox, &mem) != SYS_MBOX_EMPTY) {
if (conn->type == NETCONN_TCP) { if (conn->type == NETCONN_TCP) {
if(mem != NULL) if(mem != NULL)
pbuf_free((struct pbuf *)mem); pbuf_free((struct pbuf *)mem);
@ -299,7 +299,7 @@ netconn_delete(struct netconn *conn)
/* Drain the acceptmbox. */ /* Drain the acceptmbox. */
if (conn->acceptmbox != SYS_MBOX_NULL) { if (conn->acceptmbox != SYS_MBOX_NULL) {
while (sys_arch_mbox_fetch(conn->acceptmbox, &mem, 1) != SYS_ARCH_TIMEOUT) { while (sys_mbox_tryfetch(conn->acceptmbox, &mem) != SYS_MBOX_EMPTY) {
netconn_delete((struct netconn *)mem); netconn_delete((struct netconn *)mem);
} }
sys_mbox_free(conn->acceptmbox); sys_mbox_free(conn->acceptmbox);

View File

@ -67,6 +67,11 @@ struct sys_timeo {u8_t dummy;};
/** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */ /** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */
#define SYS_ARCH_TIMEOUT 0xffffffffUL #define SYS_ARCH_TIMEOUT 0xffffffffUL
/* sys_mbox_tryfetch returns SYS_MBOX_EMPTY if appropriate.
* For now we use the same magic value, but we allow this to change in future.
*/
#define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT
typedef void (* sys_timeout_handler)(void *arg); typedef void (* sys_timeout_handler)(void *arg);
struct sys_timeo { struct sys_timeo {
@ -116,6 +121,11 @@ u32_t sys_jiffies(void); /* since power up. */
sys_mbox_t sys_mbox_new(void); sys_mbox_t sys_mbox_new(void);
void sys_mbox_post(sys_mbox_t mbox, void *msg); void sys_mbox_post(sys_mbox_t mbox, void *msg);
u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout); u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout);
#ifndef sys_arch_mbox_tryfetch /* Allow port to override with a macro */
u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg);
#endif
/* For now, we map straight to sys_arch implementation. */
#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 #if LWIP_SO_RCVTIMEO
void sys_mbox_fetch_timeout(sys_mbox_t mbox, void **msg, u32_t timeout); void sys_mbox_fetch_timeout(sys_mbox_t mbox, void **msg, u32_t timeout);