static void watchdog_on_timer(void) { int is_ap_mode; /* if timer is set to less than 1 sec, then check buttons only */ if (wd_itv.it_value.tv_sec == 0) { int i_ret = 0; /* handle buttons */ #if defined (BOARD_GPIO_BTN_RESET) i_ret |= btn_check_reset(); #endif #if defined (BOARD_GPIO_BTN_WPS) i_ret |= btn_check_wps(); #endif #if defined (BOARD_GPIO_BTN_WLTOG) i_ret |= btn_check_wlt(); #endif if (i_ret) { if (wd_itv.it_value.tv_usec != WD_URGENT_PERIOD) wd_alarmtimer(0, WD_URGENT_PERIOD); } else { wd_alarmtimer(WD_NORMAL_PERIOD, 0); } return; } is_ap_mode = get_ap_mode(); /* check for time-dependent services */ svc_timecheck(); /* http server check */ httpd_process_check(); /* DNS/DHCP server check */ if (!is_ap_mode) dnsmasq_process_check(); inet_handler(is_ap_mode); /* update kernel timezone daylight */ setkernel_tz(); storage_save_time(10); }
/* wathchdog is runned in NORMAL_PERIOD, 1 seconds * check in each NORMAL_PERIOD * 1. button * * check in each NORAML_PERIOD*10 * * 1. ntptime * 2. time-dependent service * 3. http-process */ static void watchdog(int sig) { /* handle button */ btn_check_reset(); btn_check_ez(); /* if timer is set to less than 1 sec, then bypass the following */ if (itv.it_value.tv_sec == 0) return; if (nvram_match("reboot", "1")) return; // watchdog interval = 10s watchdog_period = (watchdog_period + 1) % 10; if (watchdog_period) return; /* check for time-dependent services */ svc_timecheck(); /* http server check */ httpd_processcheck(); nmap_handler(); inet_handler(); }