Hi,
I found out when setting the system clock backwards (not forwards), delaying of tasks that are registered with snmp_alarm_register. The tasks which are scheduled to run at certain time seem to be held back until the new time catches up with old time again. Didn't see anyone post a patch for this problem, so shared here is a quick patch implemented. There is probably a better solution, but this solved my problem.
Net-snmp version: 5.2.1.2
Linux version: 2.6.8.1
diff -Naur snmp_alarm.c snmp_alarm.c.new > snmp_alarm.c.patch
--- snmp_alarm.c 2005-09-28 11:03:28.000000000 -0700
+++ snmp_alarm.c.new 2005-09-22 09:37:17.000000000 -0700
@@ -223,6 +223,8 @@
return NULL;
}
+static unsigned long t_last_run_alarms = 0;
void
run_alarms(void)
{
@@ -231,6 +233,14 @@
unsigned int clientreg;
struct timeval t_now;
+ // added to fix the set time back bug. Betty
+ int timeBackFlag = 0;
+ gettimeofday(&t_now, NULL);
+ if( (t_now.tv_sec*1000+t_now.tv_usec) < t_last_run_alarms) { // we have a clock going back reset the timers
+ timeBackFlag =1;
+ }
+ t_last_run_alarms = t_now.tv_sec*1000+t_now.tv_usec ;
+
/*
* Loop through everything we have repeatedly looking for the next thing to
* call until all events are finally in the future again.
@@ -243,13 +253,14 @@
gettimeofday(&t_now, NULL);
- if ((a->t_next.tv_sec < t_now.tv_sec) ||
+ if ( timeBackFlag || (a->t_next.tv_sec < t_now.tv_sec) ||
((a->t_next.tv_sec == t_now.tv_sec) &&
(a->t_next.tv_usec < t_now.tv_usec))) {
clientreg = a->clientreg;
DEBUGMSGTL(("snmp_alarm", "run alarm %d\n", clientreg));
(*(a->thecallback)) (clientreg, a->clientarg);
DEBUGMSGTL(("snmp_alarm", "alarm %d completed\n", clientreg));
+ timeBackFlag = 0;
if ((a = sa_find_specific(clientreg)) != NULL) {
a->t_last.tv_sec = t_now.tv_sec;
Betty Juan
Motorola, Inc
Broadband Communications Sector
55 Las Colinas Lane
San Jose, Ca 95119
Phone: (408) 284-6113
