From 0f8a2d64184deb59b0431845624bfff9cc69b8e7 Mon Sep 17 00:00:00 2001 From: fbernon Date: Wed, 16 May 2007 14:12:52 +0000 Subject: [PATCH] tcpip.c, igmp.h, igmp.c: Fixed bug "#19800 : IGMP: igmp_tick() will not work with NO_SYS=1". Note that igmp_init is always in tcpip_thread (and not in tcpip_init) because we have to be sure that network interfaces are already added (mac filter is updated only in igmp_init for the moment). --- CHANGELOG | 6 ++++++ src/api/tcpip.c | 23 ++++++++++++++++++----- src/core/ipv4/igmp.c | 14 ++------------ src/include/ipv4/lwip/igmp.h | 4 ++-- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 392101e6..31aaf0e0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -158,6 +158,12 @@ HISTORY ++ Bug fixes: + 2007-05-16 Frédéric Bernon + * tcpip.c, igmp.h, igmp.c: Fixed bug "#19800 : IGMP: igmp_tick() will not work + with NO_SYS=1". Note that igmp_init is always in tcpip_thread (and not in + tcpip_init) because we have to be sure that network interfaces are already + added (mac filter is updated only in igmp_init for the moment). + 2007-05-16 Simon Goldschmidt * mem.c, memp.c: Removed semaphores from memp, changed sys_sem_wait calls into sys_arch_sem_wait calls to prevent timers from running while waiting diff --git a/src/api/tcpip.c b/src/api/tcpip.c index 33af507c..430e85e6 100644 --- a/src/api/tcpip.c +++ b/src/api/tcpip.c @@ -127,6 +127,17 @@ dhcp_timer_fine(void *arg) } #endif /* LWIP_DHCP */ +#if LWIP_IGMP +static void +igmp_timer(void *arg) +{ + LWIP_UNUSED_ARG(arg); + LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip: igmp_tmr()\n")); + igmp_tmr(); + sys_timeout( IGMP_TMR_INTERVAL, igmp_timer, NULL); +} +#endif /* LWIP_IGMP */ + #if ETHARP_TCPIP_ETHINPUT static void ethernet_input(struct pbuf *p, struct netif *netif) @@ -180,17 +191,19 @@ tcpip_thread(void *arg) sys_timeout( ARP_TMR_INTERVAL, arp_timer, NULL); #endif /* LWIP_ARP */ #if LWIP_DHCP - sys_timeout(DHCP_COARSE_TIMER_SECS*1000, dhcp_timer_coarse, NULL); - sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL); + sys_timeout( DHCP_COARSE_TIMER_SECS*1000, dhcp_timer_coarse, NULL); + sys_timeout( DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL); #endif /* LWIP_DHCP */ -#if LWIP_IGMP - igmp_init(); -#endif /* LWIP_IGMP */ if (tcpip_init_done != NULL) { tcpip_init_done(tcpip_init_done_arg); } +#if LWIP_IGMP + igmp_init(); + sys_timeout( IGMP_TMR_INTERVAL, igmp_timer, NULL); +#endif /* LWIP_IGMP */ + while (1) { /* MAIN Loop */ sys_mbox_fetch(mbox, (void *)&msg); switch (msg->type) { diff --git a/src/core/ipv4/igmp.c b/src/core/ipv4/igmp.c index 30b2ff77..5aca3f03 100644 --- a/src/core/ipv4/igmp.c +++ b/src/core/ipv4/igmp.c @@ -121,10 +121,6 @@ void igmp_init(void) } } } - - /* Start the 10 millisecond tick */ - /* we can optimise this to only run when timers are active later on */ - sys_timeout( IGMP_TICK, igmp_tick, NULL); } /*----------------------------------------------------------------------------- @@ -356,13 +352,11 @@ err_t igmp_leavegroup( struct netif *ifp, struct ip_addr *groupaddr) } /*----------------------------------------------------------------------------- - * igmp_tick + * igmp_tmr *----------------------------------------------------------------------------*/ -void igmp_tick(void *arg) +void igmp_tmr() { struct igmp_group *group = GroupList; - arg = arg; - while (group) { if (group->timer != 0) { group->timer -=1; @@ -372,10 +366,6 @@ void igmp_tick(void *arg) } group = group->next; } - - /* 100 millisecond tick handler */ - /* go down the list of all groups here and check for timeouts */ - sys_timeout (IGMP_TICK, igmp_tick, NULL); } /*----------------------------------------------------------------------------- diff --git a/src/include/ipv4/lwip/igmp.h b/src/include/ipv4/lwip/igmp.h index 870c467c..06e18322 100644 --- a/src/include/ipv4/lwip/igmp.h +++ b/src/include/ipv4/lwip/igmp.h @@ -71,7 +71,7 @@ struct igmpmsg { #define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */ /* Timer */ -#define IGMP_TICK 100 /* Milliseconds */ +#define IGMP_TMR_INTERVAL 100 /* Milliseconds */ /* MAC Filter Actions */ #define IGMP_DEL_MAC_FILTER 0 @@ -137,7 +137,7 @@ err_t igmp_joingroup( struct netif* ifp, struct ip_addr *groupaddr); err_t igmp_leavegroup( struct netif* ifp, struct ip_addr *groupaddr); -void igmp_tick(void *arg); +void igmp_tmr(); void igmp_timeout( struct igmp_group *group);