Bug in run_events()

Gerald (Jerry) Carter jerry at samba.org
Tue Apr 3 04:14:12 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Guys,

The current run_events() in the samba-3.0.25 tree claims to
run all events but currently does not as it breaks out at
the first event that is not ready to run ignoring any
remaining events in the list.

I've tested the attached patch with some other changes
to winbindd_cred_ccache.c and it fixes the krb5 ticket
refresh bug I'm seeing.

Comments?

Note that resetting the iterator at the end of the
processing loop could cause us to rescan previously
future events, but this is the same behavior as we
had previously when relying on the event to remove
itself from (and possibly re-add itself to the list).





cheers, jerry
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGEdSUIR7qMdg1EfYRAmZjAJ9zhkPUZNtE1a0IcQJZAidrd4XIvACg5SeD
9vwEHAHBKVmTouYJRVal2Ik=
=rFd2
-----END PGP SIGNATURE-----
-------------- next part --------------
Index: lib/events.c
===================================================================
--- lib/events.c	(revision 14277)
+++ lib/events.c	(working copy)
@@ -220,30 +220,36 @@
 {
 	BOOL fired = False;
 	struct fd_event *fde, *next;
+	struct timed_event *te = event_ctx->timed_events;	
 
 	/* Run all events that are pending, not just one (as we
 	   did previously. */
 
-	while (event_ctx->timed_events) {
+	while (te) {
 		struct timeval now;
 		GetTimeOfDay(&now);
 
-		if (timeval_compare(
-			    &now, &event_ctx->timed_events->when) < 0) {
-			/* Nothing to do yet */
+		if (timeval_compare(&now, &te->when) < 0) {
+			/* Nothing to do for this event.  Go
+			   on to the next*/
 			DEBUG(11, ("run_events: Nothing to do\n"));
-			break;
+			te = te->next;
+			continue;
 		}
 
 		DEBUG(10, ("Running event \"%s\" %lx\n",
-			   event_ctx->timed_events->event_name,
-			   (unsigned long)event_ctx->timed_events));
+			   te->event_name,
+			   (unsigned long)te));
 
-		event_ctx->timed_events->handler(
-			event_ctx,
-			event_ctx->timed_events, &now,
-			event_ctx->timed_events->private_data);
+		/* Firing an event handler should remove itself from 
+		   the list (and possibly re-add itself to the end) */
 
+		te->handler(event_ctx, te, &now, te->private_data);
+
+		/* reset the iterator */
+
+		te = event_ctx->timed_events;
+
 		fired = True;
 	}
 


More information about the samba-technical mailing list