--------------------- PatchSet 1602 Date: 2005/08/25 17:55:18 Author: rousskov Branch: squid3-icap Tag: (none) Log: - Calculate select loop timeout after all callbacks have been called because callbacks can set new events, including events more urgent than the ones left after all of the pre-callback events were run. The original code resulted in a ~800msec/sequential-transaction delay when ICAP was enabled because ICAP uses a lot of zero-delay events. Members: src/main.cc:1.51->1.51.2.1 Index: squid3/src/main.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/main.cc,v retrieving revision 1.51 retrieving revision 1.51.2.1 diff -u -r1.51 -r1.51.2.1 --- squid3/src/main.cc 21 Jul 2005 02:14:18 -0000 1.51 +++ squid3/src/main.cc 25 Aug 2005 17:55:18 -0000 1.51.2.1 @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.51 2005/07/21 02:14:18 squidadm Exp $ + * $Id: main.cc,v 1.51.2.1 2005/08/25 17:55:18 rousskov Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -47,6 +47,7 @@ #include "DiskIO/DiskIOModule.h" #include "comm.h" #include "SwapDir.h" +#include "Debug.h" #if USE_WIN32_SERVICE @@ -1146,10 +1147,6 @@ } eventRun(); - int loop_delay = eventNextTime(); - - if (loop_delay < 0) - loop_delay = 0; /* Attempt any pending storedir IO */ Store::Root().callback(); @@ -1163,6 +1160,11 @@ if (comm_iocallbackpending()) comm_calliocallback(); + int loop_delay = eventNextTime(); + if (loop_delay < 0) + loop_delay = 0; + debugs(1, 9, "select loop delay: " << loop_delay << "msec"); + switch (comm_select(loop_delay)) { case COMM_OK: