]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Some debugging logs seem to indicate that asynchronous calls are fired
authorrousskov <>
Fri, 27 Jul 2007 10:40:51 +0000 (10:40 +0000)
committerrousskov <>
Fri, 27 Jul 2007 10:40:51 +0000 (10:40 +0000)
out of order. The code cannot (and probably should not) handle that.

This out-of-order calls may be happening because async calls are implemented
using time-based events, and events are using wall clock (current_dtime)
when looking for the right place in the event queue. The wall clock may
go backwards, placing a later call earlier in the event queue.

This change forces async call-looking events to use absolute timestamp of
zero, so nothing (including a later async call) can get in front of them.

src/event.cc

index f6027a4e96fafad7e28bb6b2e5574cdf8e7d32ed..fa6ad79a280d21de4fd0f0a09a97132f1a4e67be 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: event.cc,v 1.47 2007/04/12 23:25:07 wessels Exp $
+ * $Id: event.cc,v 1.48 2007/07/27 04:40:51 rousskov Exp $
  *
  * DEBUG: section 41    Event Processing
  * AUTHOR: Henrik Nordstrom
@@ -305,8 +305,11 @@ EventScheduler::GetInstance()
 void
 EventScheduler::schedule(const char *name, EVH * func, void *arg, double when, int weight, bool cbdata)
 {
-
-    struct ev_entry *event = new ev_entry(name, func, arg, current_dtime + when, weight, cbdata);
+    // Use zero timestamp for when=0 events: Many of them are async calls that
+    // must fire in the submission order. We cannot use current_dtime for them
+    // because it may decrease if system clock is adjusted backwards.
+    const double timestamp = when > 0.0 ? current_dtime + when : 0;
+    struct ev_entry *event = new ev_entry(name, func, arg, timestamp, weight, cbdata);
 
     struct ev_entry **E;
     debugs(41, 7, HERE << "schedule: Adding '" << name << "', in " << when << " seconds");