Skip to contentSkip to conversation

CLD: regression in unified cld_timer

PATCH Applied Pete Zaitcev 2 participants 2 messages Feb 9, 2010 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CLD: regression in unified cld_timer

The common timer implementation had a bug whereas it overwrote the list of timers when a timer callback added its own timer -- which just about every one of them does. The most visible result was that sessions stopped expiring correctly and left dangling file locks. Also, every new session failed after 2 minutes 35 seconds.

The fix is not to keep a local copy of the list head across invocations of the callback.

---
 lib/libtimer.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Jeff & Colin: sorry to waste your time with inferences that the change to XDR was somehow involved. I guess I did not update the CLD on the server since before the common timer.

lib/libtimer.c +3 -2
index 9fcab4f..c6f5241 100644
@@ -84,6 +84,7 @@ time_t cld_timers_run(struct cld_timer_list *tlist)
 
 		timer->on_list = false;
 	}
+	tlist->list = timer_list;
 
 	tmp = exec_list;
 	while (tmp) {
@@ -94,7 +95,8 @@ time_t cld_timers_run(struct cld_timer_list *tlist)
 		timer->cb(timer);
 	}
 
-	if (timer_list) {
+	if (tlist->list) {
+		timer_list = tlist->list;
 		timer = timer_list->data;
 		if (timer->expires > now)
 			next_timeout = (timer->expires - now);
@@ -102,7 +104,6 @@ time_t cld_timers_run(struct cld_timer_list *tlist)
 			next_timeout = 1;
 	}
 
-	tlist->list = timer_list;
 	return next_timeout;
 }
 
Applied
#1 lore raw
Quoted 11 lines · Pete Zaitcev

The common timer implementation had a bug whereas it overwrote the list of timers when a timer callback added its own timer -- which just about every one of them does. The most visible result was that sessions stopped expiring correctly and left dangling file locks. Also, every new session failed after 2 minutes 35 seconds.

The fix is not to keep a local copy of the list head across invocations of the callback.

Quoted 7 lines
---
  lib/libtimer.c |    5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

Jeff& Colin: sorry to waste your time with inferences that the change to XDR was somehow involved. I guess I did not update the CLD on the server since before the common timer.

applied