diff options
| author | sg <goldsimon@gmx.de> | 2015-02-12 22:22:32 +0100 |
|---|---|---|
| committer | sg <goldsimon@gmx.de> | 2015-02-12 22:22:32 +0100 |
| commit | 9a8c3c0283b1481d436d3b360fd07ef05ff30662 (patch) | |
| tree | cfa5cf8a7b692efa12eb23d932b978e683d8127a | |
| parent | 338c5c0a680c598d09d9f261c6be1253854b0b33 (diff) | |
| download | lwip-contrib-9a8c3c0283b1481d436d3b360fd07ef05ff30662.tar.gz | |
patch by chrysn: fixed bug #40245 (unix port minimal project has abundant timers)
| -rw-r--r-- | ports/unix/proj/minimal/lwipopts.h | 5 | ||||
| -rw-r--r-- | ports/unix/proj/minimal/main.c | 23 | ||||
| -rw-r--r-- | ports/unix/proj/minimal/timer.c | 89 | ||||
| -rw-r--r-- | ports/unix/proj/minimal/timer.h | 7 |
4 files changed, 2 insertions, 122 deletions
diff --git a/ports/unix/proj/minimal/lwipopts.h b/ports/unix/proj/minimal/lwipopts.h index 544d388..10ed26f 100644 --- a/ports/unix/proj/minimal/lwipopts.h +++ b/ports/unix/proj/minimal/lwipopts.h @@ -122,11 +122,6 @@ #define MEMP_NUM_ARP_QUEUE 2 /** - * MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. - */ -#define MEMP_NUM_SYS_TIMEOUT 3 - -/** * MEMP_NUM_NETBUF: the number of struct netbufs. * (only needed if you use the sequential API, like api_lib.c) */ diff --git a/ports/unix/proj/minimal/main.c b/ports/unix/proj/minimal/main.c index 2842482..3870ecf 100644 --- a/ports/unix/proj/minimal/main.c +++ b/ports/unix/proj/minimal/main.c @@ -192,11 +192,6 @@ main(int argc, char **argv) echo_init(); timer_init(); - timer_set_interval(TIMER_EVT_ETHARPTMR, ARP_TMR_INTERVAL / 10); - timer_set_interval(TIMER_EVT_TCPTMR, TCP_TMR_INTERVAL / 10); -#if IP_REASSEMBLY - timer_set_interval(TIMER_EVT_IPREASSTMR, IP_TMR_INTERVAL / 10); -#endif printf("Applications started.\n"); @@ -225,22 +220,8 @@ main(int argc, char **argv) /* ... end critical section */ sigprocmask(SIG_SETMASK, &oldmask, NULL); } - - if(timer_testclr_evt(TIMER_EVT_TCPTMR)) - { - tcp_tmr(); - } -#if IP_REASSEMBLY - if(timer_testclr_evt(TIMER_EVT_IPREASSTMR)) - { - ip_reass_tmr(); - } -#endif - if(timer_testclr_evt(TIMER_EVT_ETHARPTMR)) - { - etharp_tmr(); - } - + + sys_check_timeouts(); } return 0; diff --git a/ports/unix/proj/minimal/timer.c b/ports/unix/proj/minimal/timer.c index 9f14e32..6a2e65f 100644 --- a/ports/unix/proj/minimal/timer.c +++ b/ports/unix/proj/minimal/timer.c @@ -43,16 +43,6 @@ static struct itimerval tmr; -struct itmr -{ - volatile unsigned int interval; - volatile unsigned int cnt; - volatile unsigned char event; -}; - -static struct itmr timers[TIMER_NUM]; - - void sigalarm_handler(int sig); /** @@ -61,18 +51,6 @@ void sigalarm_handler(int sig); void timer_init(void) { - unsigned char i; - struct itmr *tp; - - tp = &timers[TIMER_NUM-1]; - for(i = TIMER_NUM; i > 0; i--) - { - tp->event = 0; - tp->interval = 0; - tp->cnt = 0; - tp--; - } - signal(SIGALRM,sigalarm_handler); /* timer reload is in 10msec steps */ @@ -86,78 +64,11 @@ timer_init(void) } /** - * Configures timer. - * - * @param tmr the timer number from timer.h - * @param interval when > 0 enables this timer, 0 disables. - */ -void -timer_set_interval(unsigned char tmr_num, unsigned int interval) -{ - if (tmr_num < TIMER_NUM) - { - timers[tmr_num].interval = interval; - } -} - - -/** - * Returns timer event and restarts timer. - */ -unsigned char -timer_testclr_evt(unsigned char tmr_num) -{ - if (tmr_num < TIMER_NUM) - { - unsigned char evt; - struct itmr *tp; - - tp = &timers[tmr_num]; - - evt = tp->event; - if (tp->event != 0) - { - tp->event = 0; - tp->cnt = tp->interval; - } - return evt; - } - else - { - return 0; - } -} - -/** * interrupting (!) sigalarm handler */ void sigalarm_handler(int sig) { - unsigned char i; - struct itmr *tp; - LWIP_UNUSED_ARG(sig); - snmp_inc_sysuptime(); - - tp = &timers[TIMER_NUM-1]; - for(i = TIMER_NUM; i > 0; i--) - { - if (tp->interval != 0) - { - /* timer is running */ - if (tp->cnt == 0) - { - /* timer expired */ - tp->event |= 1; - } - else - { - /* timer ticking */ - tp->cnt--; - } - } - tp--; - } } diff --git a/ports/unix/proj/minimal/timer.h b/ports/unix/proj/minimal/timer.h index bdad881..75a2b27 100644 --- a/ports/unix/proj/minimal/timer.h +++ b/ports/unix/proj/minimal/timer.h @@ -1,13 +1,6 @@ #ifndef LWIP_TIMER_H_ #define LWIP_TIMER_H_ -#define TIMER_EVT_ETHARPTMR 0 -#define TIMER_EVT_TCPTMR 1 -#define TIMER_EVT_IPREASSTMR 2 -#define TIMER_NUM 3 - void timer_init(void); -void timer_set_interval(unsigned char tmr, unsigned int interval); -unsigned char timer_testclr_evt(unsigned char tmr); #endif |
