From a86883277640d2eeaa534d1a16425a6aaf3c0a97 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Thu, 8 Mar 2007 10:37:31 +0000 Subject: [PATCH] Initialize dhcp timers in tcpip_thread (if LWIP_DHCP) to protect the stack from concurrent access. --- CHANGELOG | 4 ++++ src/api/tcpip.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 5fa50a18..e7b974b4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -45,6 +45,10 @@ HISTORY ++ Bug fixes: + 2007-03-06 Simon Goldschmidt + * tcpip.c: Initialize dhcp timers in tcpip_thread (if LWIP_DHCP) to protect + the stack from concurrent access. + 2007-03-06 Frédéric Bernon, Dmitry Potapov * tcpip.c, ip_frag.c, ethernetif.c: Fix some build problems, and a redundancy call to "lwip_stats.link.recv++;" in low_level_input() & ethernetif_input(). diff --git a/src/api/tcpip.c b/src/api/tcpip.c index 7c0f8d24..129f5fed 100644 --- a/src/api/tcpip.c +++ b/src/api/tcpip.c @@ -102,6 +102,24 @@ arp_timer(void *arg) sys_timeout( ARP_TMR_INTERVAL, arp_timer, NULL); } +#if LWIP_DHCP +static void +dhcp_timer_coarse(void *arg) +{ + LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip: dhcp_coarse_tmr()\n")); + dhcp_coarse_tmr(); + sys_timeout(DHCP_COARSE_TIMER_SECS*1000, dhcp_timer_coarse, NULL); +} + +static void +dhcp_timer_fine(void *arg) +{ + LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip: dhcp_fine_tmr()\n")); + dhcp_fine_tmr(); + sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL); +} +#endif + #if ETHARP_TCPIP_ETHINPUT static void ethernet_input(struct pbuf *p, struct netif *netif) @@ -146,6 +164,10 @@ tcpip_thread(void *arg) sys_timeout( IP_TMR_INTERVAL, ip_timer, NULL); #endif sys_timeout( ARP_TMR_INTERVAL, arp_timer, NULL); +#if LWIP_DHCP + sys_timeout(DHCP_COARSE_TIMER_SECS*1000, dhcp_timer_coarse, NULL); + sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL); +#endif if (tcpip_init_done != NULL) { tcpip_init_done(tcpip_init_done_arg);