From: rousskov <> Date: Fri, 27 Jul 2007 10:40:51 +0000 (+0000) Subject: Some debugging logs seem to indicate that asynchronous calls are fired X-Git-Tag: SQUID_3_0_PRE7~144 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5a02499e55d8a725a13f7512884c943ebc0d909;p=thirdparty%2Fsquid.git Some debugging logs seem to indicate that asynchronous calls are fired 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. --- diff --git a/src/event.cc b/src/event.cc index f6027a4e96..fa6ad79a28 100644 --- a/src/event.cc +++ b/src/event.cc @@ -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");