From 2e18a9be633260166874c64c119084f1b577d837 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Wed, 14 Apr 2010 07:02:26 +0000 Subject: [PATCH] Added an overridable define to get informed when the tcpip_thread processes messages or timeouts to implement a watchdog. --- CHANGELOG | 4 ++++ src/api/tcpip.c | 1 + src/core/timers.c | 1 + src/include/lwip/tcpip.h | 6 ++++++ 4 files changed, 12 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index a29017bd..ae761e06 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,10 @@ HISTORY ++ New features: + 2010-04-14: Simon Goldschmidt + * tcpip.h/.c, timers.c: Added an overridable define to get informed when the + tcpip_thread processes messages or timeouts to implement a watchdog. + 2010-03-28: Simon Goldschmidt * ip_frag.c: create a new (contiguous) PBUF_RAM for every outgoing fragment if LWIP_NETIF_TX_SINGLE_PBUF==1 diff --git a/src/api/tcpip.c b/src/api/tcpip.c index 188eb506..857e7d9b 100644 --- a/src/api/tcpip.c +++ b/src/api/tcpip.c @@ -83,6 +83,7 @@ tcpip_thread(void *arg) LOCK_TCPIP_CORE(); while (1) { /* MAIN Loop */ UNLOCK_TCPIP_CORE(); + LWIP_TCPIP_THREAD_ALIVE(); /* wait for a message, timeouts are processed while waiting */ sys_timeouts_mbox_fetch(&mbox, (void **)&msg); LOCK_TCPIP_CORE(); diff --git a/src/core/timers.c b/src/core/timers.c index 1cb4c8ec..433e4adb 100644 --- a/src/core/timers.c +++ b/src/core/timers.c @@ -467,6 +467,7 @@ sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg) h(arg); UNLOCK_TCPIP_CORE(); } + LWIP_TCPIP_THREAD_ALIVE(); /* We try again to fetch a message from the mbox. */ goto again; diff --git a/src/include/lwip/tcpip.h b/src/include/lwip/tcpip.h index b112767c..995ba8ad 100644 --- a/src/include/lwip/tcpip.h +++ b/src/include/lwip/tcpip.h @@ -48,6 +48,12 @@ extern "C" { #endif +/** Define this to something that triggers a watchdog. This is called from + * tcpip_thread after processing a message. */ +#ifndef LWIP_TCPIP_THREAD_ALIVE +#define LWIP_TCPIP_THREAD_ALIVE() +#endif + #if LWIP_TCPIP_CORE_LOCKING /** The global semaphore to lock the stack. */ extern sys_mutex_t lock_tcpip_core;