luci-0.9: merge r4892

This commit is contained in:
Jo-Philipp Wich 2009-06-22 19:34:49 +00:00
parent 2396520413
commit 579505b1d0
3 changed files with 93 additions and 91 deletions

View file

@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=freifunk-watchdog
PKG_RELEASE:=4
PKG_RELEASE:=5
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_BUILD_DEPENDS := uci

View file

@ -31,14 +31,6 @@ static void shutdown_watchdog(int sig)
{
syslog(LOG_INFO, "Stopping watchdog timer");
write(wdfd, &wshutdown, 1);
/* Older Kamikaze versions are compiled with
* CONFIG_WATCHDOG_NOWAYOUT=y, this can be
* harmful if we're in the middle of an upgrade.
* Increase the watchdog timeout to 3600 seconds
* here to avoid unplanned reboots. */
ioctl(wdfd, WDIOC_SETTIMEOUT, &wdelay);
close(wdfd);
wdfd = -1;
}
@ -191,11 +183,9 @@ static int check_uci_update(const char *config, time_t *mtime)
*mtime = s.st_mtime;
return 1;
}
return 0;
}
return -1;
return 0;
}
/* Add tuple */
@ -290,7 +280,7 @@ static wifi_tuple_t * load_wifi_uci(wifi_tuple_t *ifs, time_t *modtime)
static int do_daemon(void)
{
static int wdtrigger = 1;
static int wdtimeout = INTERVAL * 2;
static int wdtimeout = BASE_INTERVAL * 2;
static const char wdkeepalive = WATCH_KEEPALIVE;
int iwfd;
@ -301,6 +291,7 @@ static int do_daemon(void)
wifi_tuple_t *ifs = NULL, *curif;
time_t modtime = 0;
int action_intv = 0;
int restart_wifi = 0;
int restart_cron = 0;
int restart_sshd = 0;
@ -320,7 +311,7 @@ static int do_daemon(void)
if( (wdfd = open(WATCH_DEVICE, O_WRONLY)) > -1 )
{
syslog(LOG_INFO, "Opened %s - polling every %i seconds",
WATCH_DEVICE, INTERVAL);
WATCH_DEVICE, BASE_INTERVAL);
/* Install signal handler to halt watchdog on shutdown */
sa.sa_handler = shutdown_watchdog;
@ -338,6 +329,12 @@ static int do_daemon(void)
while( 1 )
{
/* Check/increment action interval */
if( ++action_intv >= ACTION_INTERVAL )
{
/* Reset action interval */
action_intv = 0;
/* Check average load */
if( find_loadavg() >= LOAD_TRESHOLD )
loadavg_panic++;
@ -424,12 +421,14 @@ static int do_daemon(void)
else
EXEC(LOAD_ACTION);
}
}
/* Reset watchdog timer */
if( wdfd > -1 )
write(wdfd, &wdkeepalive, 1);
sleep(INTERVAL);
sleep(BASE_INTERVAL);
}
shutdown_watchdog(0);

View file

@ -39,8 +39,11 @@
#include "wireless.22.h"
/* Check interval */
#define INTERVAL 30
/* Watchdog poll interval */
#define BASE_INTERVAL 5
/* Action interval (N * BASE_INTERVAL) */
#define ACTION_INTERVAL 6
/* Hysteresis */
#define HYSTERESIS 3