]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
DW:
authorwessels <>
Thu, 6 Jul 2000 06:08:28 +0000 (06:08 +0000)
committerwessels <>
Thu, 6 Jul 2000 06:08:28 +0000 (06:08 +0000)
 - In storeDiskdSend() we used to loop on storeDiskdDirCallback(sd)
   if we were over the magic2 limit.  There were two problems with
   that approach.  The loop was at CPU speed; there were no delays.
   When this condition occurs, Squid could hog the CPU when it would
   be better to give some cycles to the diskd processes.  Also, we
   need to check callbacks for *all* swap directories, not just the
   current one.

   This patch calls storeDirCallback() instead.  It also adds an
   exponentially increasing delay between calls, with a 500ms limit.
   select is used as a somewhat portable microsecond sleep timer.

src/fs/diskd/store_io_diskd.cc

index 5153ef83e176de300c2f4919481507b236720b38..4fd6eb0bb9041a489001a16390c765f2806eba30 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_io_diskd.cc,v 1.12 2000/06/27 22:06:25 hno Exp $
+ * $Id: store_io_diskd.cc,v 1.13 2000/07/06 00:08:28 wessels Exp $
  *
  * DEBUG: section 81    Squid-side DISKD I/O functions.
  * AUTHOR: Duane Wessels
@@ -468,8 +468,20 @@ storeDiskdSend(int mtype, SwapDir * sd, int id, storeIOState * sio, int size, in
      * then we can have a lot of messages in the queue (probably
      * up to 2*magic1) and we can run out of shared memory buffers.
      */
-    while (diskdinfo->away > diskdinfo->magic2)
-       storeDiskdDirCallback(sd);
+    /*
+     * Note that we call storeDirCallback (for all SDs), rather
+     * than storeDiskdDirCallback for just this SD, so that while
+     * we're "blocking" on this SD we can also handle callbacks
+     * from other SDs that might be ready.
+     */
+    while (diskdinfo->away > diskdinfo->magic2) {
+       struct timeval delay =
+       {0, 1};
+       select(0, NULL, NULL, NULL, &delay);
+       storeDirCallback();
+       if (delay.tv_usec < 1000000)
+           delay.tv_usec <<= 1;
+    }
     return x;
 }