]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Resurrected Duanes old sleep_after_fork patch. This needed or we will
authorhno <>
Fri, 28 Sep 2001 03:59:22 +0000 (03:59 +0000)
committerhno <>
Fri, 28 Sep 2001 03:59:22 +0000 (03:59 +0000)
race with ourselves for swap space when restarting helpers. The hello
test is not really sufficient, we must also wait for the child to actually
exec() before forking again. In the event that we are starting many
helpers who uses CPU it is not too unlikely to see a newly started child
to be context switched before exec().

Anyway, default configuration does nothing. To activate this one must
configure sleep_after_fork in squid.conf so it is a quite harmless patch,
and if it helps some people, fine.

src/cf.data.pre
src/ipc.cc
src/structs.h

index 0cbff10cdb571cc284d6dc9dcb3851753d63db0a..0fe5aafd2ebe2f01a3c341bc89a726a6cad390f9 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.224 2001/08/19 16:33:17 wessels Exp $
+# $Id: cf.data.pre,v 1.225 2001/09/27 21:59:22 hno Exp $
 #
 #
 # SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -3656,5 +3656,21 @@ DOC_START
        objects not intended for caching to get cached.
 DOC_END
 
+NAME: sleep_after_fork 
+COMMENT: (microseconds) 
+TYPE: int 
+LOC: Config.sleep_after_fork 
+DEFAULT: 0 
+DOC_START 
+       When this is set to a non-zero value, the main Squid process 
+       sleeps the specified number of microseconds after a fork() 
+       system call. This sleep may help the situation where your 
+       system reports fork() failures due to lack of (virtual) 
+       memory. Note, however, that if you have a lot of child 
+       processes, then these sleep delays will add up and your 
+       Squid will not service requests for some amount of time 
+       until all the child processes have been started. 
+DOC_END 
+
 EOF
 
index 3f08510e3228a5010f367665ce1efe1105b46e34..5be079ca8f159190bd6e57e4e1ee1fcd2e4ca13e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ipc.cc,v 1.23 2001/08/29 14:57:35 robertc Exp $
+ * $Id: ipc.cc,v 1.24 2001/09/27 21:59:22 hno Exp $
  *
  * DEBUG: section 54    Interprocess Communication
  * AUTHOR: Duane Wessels
@@ -204,6 +204,13 @@ ipcCreate(int type, const char *prog, char *const args[], const char *name, int
            *wfd = pwfd;
        fd_table[prfd].flags.ipc = 1;
        fd_table[pwfd].flags.ipc = 1;
+       if (Config.sleep_after_fork) {
+           /* XXX emulation of usleep() */
+           struct timeval sl;
+           sl.tv_sec = Config.sleep_after_fork / 1000000;
+           sl.tv_usec = Config.sleep_after_fork % 1000000;
+           select(0, NULL, NULL, NULL, &sl);
+       }
        return pid;
     }
     /* child */
index 74a1f325cceb221b2ea51ec4eeb7237d1748b70a..9fc8a0a6777ce79ee70d4ccaa4fb2bc6ce24e1e5 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.399 2001/09/07 18:02:48 adrian Exp $
+ * $Id: structs.h,v 1.400 2001/09/27 21:59:22 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -664,6 +664,7 @@ struct _SquidConfig {
        size_t high_memory;
     } warnings;
     char *store_dir_select_algorithm;
+    int sleep_after_fork;      /* microseconds */
 };
 
 struct _SquidConfig2 {