@ -44,11 +44,8 @@ struct sswt_cb
} ;
# if LWIP_SO_RCVTIMEO
void sys_mbox_fetch_timeout ( sys_mbox_t mbox , void * * msg , u32_t timeout )
# else
void sys_mbox_fetch ( sys_mbox_t mbox , void * * msg )
# endif /* LWIP_SO_RCVTIMEO */
void
sys_mbox_fetch ( sys_mbox_t mbox , void * * msg )
{
u32_t time ;
struct sys_timeouts * timeouts ;
@ -60,38 +57,15 @@ void sys_mbox_fetch(sys_mbox_t mbox, void **msg)
timeouts = sys_arch_timeouts ( ) ;
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 ) ;
# endif /* LWIP_SO_RCVTIMEO */
} else {
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 ) ;
# endif /* LWIP_SO_RCVTIMEO */
} else {
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
could be fetched . We should now call the timeout handler and
deallocate the memory allocated for the timeout . */
@ -104,16 +78,9 @@ void sys_mbox_fetch(sys_mbox_t mbox, void **msg)
LWIP_DEBUGF ( SYS_DEBUG , ( " smf calling h=%p(%p) \n " , ( void * ) h , ( void * ) 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. */
goto again ;
# if LWIP_SO_RCVTIMEO
}
# endif /* LWIP_SO_RCVTIMEO */
} else {
/* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout
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 ;
}
}
}
# if LWIP_SO_RCVTIMEO
if ( ( time = = SYS_ARCH_TIMEOUT ) & & ( msg ) )
{ ( * msg ) = NULL ;
}
# endif /* LWIP_SO_RCVTIMEO */
}
void