~mojocode/apache2/peruser

« back to all changes in this revision

Viewing changes to debian/mpm-peruser/patches/002-mpm-peruser-rc2.patch

  • Committer: Morton Jonuschat
  • Date: 2011-11-06 08:59:32 UTC
  • Revision ID: packages@mojocode.de-20111106085932-2c09nk5p2enptbuz
Integrate MPM Peruser 0.4.0rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff -urN peruser.rc1/docs/conf/extra/httpd-mpm.conf.in peruser.rc2/docs/conf/extra/httpd-mpm.conf.in
 
2
--- peruser.rc1/docs/conf/extra/httpd-mpm.conf.in       2011-11-06 09:45:44.000000000 +0100
 
3
+++ peruser.rc2/docs/conf/extra/httpd-mpm.conf.in       2011-11-05 18:16:00.000000000 +0100
 
4
@@ -27,24 +27,6 @@
 
5
 # active mpm.
 
6
 #
 
7
 
 
8
-# peruser MPM
 
9
-# IdleTimeout: maximum time before a child is killed after being idle, 0 to disable
 
10
-# ExpireTimeout: maximum time a child can live, 0 to disable
 
11
-# MinSpareProcessors: minimum number of idle children, to handle request spikes
 
12
-# MaxProcessors: Maximum number of processors per vhost
 
13
-# ServerLimit: maximum value of MaxClients for this run of Apache
 
14
-# MaxClients: maximum number of children alive at the same time
 
15
-# MaxMultiplexers: maximum number of multiplexers the server can have
 
16
-<IfModule mpm_peruser_module>
 
17
-    IdleTimeout 900
 
18
-    ExpireTimeout 1800
 
19
-    MinSpareProcessors 2
 
20
-    MaxProcessors 10
 
21
-    ServerLimit 256
 
22
-    MaxClients 256
 
23
-    MaxMultiplexers 20
 
24
-</IfModule>
 
25
-
 
26
 # prefork MPM
 
27
 # StartServers: number of server processes to start
 
28
 # MinSpareServers: minimum number of server processes which are kept spare
 
29
diff -urN peruser.rc1/modules/generators/mod_status.c peruser.rc2/modules/generators/mod_status.c
 
30
--- peruser.rc1/modules/generators/mod_status.c 2011-11-06 09:45:44.000000000 +0100
 
31
+++ peruser.rc2/modules/generators/mod_status.c 2011-11-06 09:44:35.000000000 +0100
 
32
@@ -201,11 +201,11 @@
 
33
 
 
34
 /* ID values for command table */
 
35
 
 
36
-#define STAT_OPT_END     -1
 
37
-#define STAT_OPT_REFRESH  0
 
38
-#define STAT_OPT_NOTABLE  1
 
39
-#define STAT_OPT_AUTO     2
 
40
-#define STAT_OPT_STATS    3
 
41
+#define STAT_OPT_END              -1
 
42
+#define STAT_OPT_REFRESH          0
 
43
+#define STAT_OPT_NOTABLE          1
 
44
+#define STAT_OPT_AUTO             2
 
45
+#define STAT_OPT_PERUSER_STATS    3
 
46
 
 
47
 struct stat_opt {
 
48
     int id;
 
49
@@ -218,7 +218,7 @@
 
50
     {STAT_OPT_REFRESH, "refresh", "Refresh"},
 
51
     {STAT_OPT_NOTABLE, "notable", NULL},
 
52
     {STAT_OPT_AUTO, "auto", NULL},
 
53
-    {STAT_OPT_STATS, "stats", NULL},
 
54
+    {STAT_OPT_PERUSER_STATS, "peruser_stats", NULL},
 
55
     {STAT_OPT_END, NULL, NULL}
 
56
 };
 
57
 
 
58
@@ -243,7 +243,7 @@
 
59
 #endif
 
60
     int short_report;
 
61
     int no_table_report;
 
62
-       int stats_report;
 
63
+    int peruser_stats;
 
64
     worker_score *ws_record;
 
65
     process_score *ps_record;
 
66
     char *stat_buffer;
 
67
@@ -271,8 +271,8 @@
 
68
     kbcount = 0;
 
69
     short_report = 0;
 
70
     no_table_report = 0;
 
71
-       stats_report=0;
 
72
-       
 
73
+    peruser_stats=0;
 
74
+
 
75
     pid_buffer = apr_palloc(r->pool, server_limit * sizeof(pid_t));
 
76
     stat_buffer = apr_palloc(r->pool, server_limit * thread_limit * sizeof(char));
 
77
 
 
78
@@ -316,8 +316,8 @@
 
79
                 case STAT_OPT_NOTABLE:
 
80
                     no_table_report = 1;
 
81
                     break;
 
82
-               case STAT_OPT_STATS:
 
83
-                    stats_report = 1;
 
84
+               case STAT_OPT_PERUSER_STATS:
 
85
+                    peruser_stats = 1;
 
86
                     break;
 
87
                 case STAT_OPT_AUTO:
 
88
                     ap_set_content_type(r, "text/plain; charset=ISO-8859-1");
 
89
@@ -827,7 +827,7 @@
 
90
             (short_report ? AP_STATUS_SHORT : 0) |
 
91
             (no_table_report ? AP_STATUS_NOTABLE : 0) |
 
92
             (ap_extended_status ? AP_STATUS_EXTENDED : 0) |
 
93
-            (stats_report ? AP_STATUS_STATS : 0);
 
94
+            (peruser_stats ? AP_STATUS_PERUSER_STATS : 0);
 
95
 
 
96
         ap_run_status_hook(r, flags);
 
97
     }
 
98
diff -urN peruser.rc1/modules/generators/mod_status.h peruser.rc2/modules/generators/mod_status.h
 
99
--- peruser.rc1/modules/generators/mod_status.h 2011-11-06 09:45:44.000000000 +0100
 
100
+++ peruser.rc2/modules/generators/mod_status.h 2011-11-06 09:44:35.000000000 +0100
 
101
@@ -29,10 +29,10 @@
 
102
 #include "ap_config.h"
 
103
 #include "httpd.h"
 
104
 
 
105
-#define AP_STATUS_SHORT    (0x1)  /* short, non-HTML report requested */
 
106
-#define AP_STATUS_NOTABLE  (0x2)  /* HTML report without tables */
 
107
-#define AP_STATUS_EXTENDED (0x4)  /* detailed report */
 
108
-#define AP_STATUS_STATS    (0x8)  /* extended user statistics report */
 
109
+#define AP_STATUS_SHORT            (0x1)  /* short, non-HTML report requested */
 
110
+#define AP_STATUS_NOTABLE          (0x2)  /* HTML report without tables */
 
111
+#define AP_STATUS_EXTENDED         (0x4)  /* detailed report */
 
112
+#define AP_STATUS_PERUSER_STATS    (0x8)  /* peruser mpm extended status */
 
113
 
 
114
 #if !defined(WIN32)
 
115
 #define STATUS_DECLARE(type)            type
 
116
diff -urN peruser.rc1/server/mpm/experimental/peruser/mpm.h peruser.rc2/server/mpm/experimental/peruser/mpm.h
 
117
--- peruser.rc1/server/mpm/experimental/peruser/mpm.h   2011-11-06 09:45:44.000000000 +0100
 
118
+++ peruser.rc2/server/mpm/experimental/peruser/mpm.h   2011-11-06 09:44:35.000000000 +0100
 
119
@@ -96,11 +96,6 @@
 
120
 #define SERVER_DYING 1
 
121
 #define SERVER_ALIVE 2
 
122
 
 
123
-typedef struct ap_ctable {
 
124
-    pid_t pid;
 
125
-    unsigned char status;
 
126
-} ap_ctable;
 
127
-
 
128
 static const char* child_clone();
 
129
 
 
130
 
 
131
diff -urN peruser.rc1/server/mpm/experimental/peruser/peruser.c peruser.rc2/server/mpm/experimental/peruser/peruser.c
 
132
--- peruser.rc1/server/mpm/experimental/peruser/peruser.c       2011-11-06 09:45:44.000000000 +0100
 
133
+++ peruser.rc2/server/mpm/experimental/peruser/peruser.c       2011-11-06 09:44:35.000000000 +0100
 
134
@@ -1,4 +1,3 @@
 
135
-
 
136
 /* ====================================================================
 
137
  * The Apache Software License, Version 1.1
 
138
  *
 
139
@@ -121,7 +120,6 @@
 
140
 #error "Peruser MPM requres shared memory support."
 
141
 #endif
 
142
 
 
143
-
 
144
 /* should be APR-ized */
 
145
 #include <grp.h>
 
146
 #include <pwd.h>
 
147
@@ -132,7 +130,6 @@
 
148
 #include <signal.h>
 
149
 #include <sys/times.h>
 
150
 
 
151
-
 
152
 #ifdef MPM_PERUSER_DEBUG
 
153
 # define _DBG(text,par...) \
 
154
     ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, \
 
155
@@ -162,7 +159,6 @@
 
156
 #define AP_PERUSER_THISCHILD -1
 
157
 #define AP_PERUSER_OTHERCHILD -2
 
158
 
 
159
-
 
160
 /* Limit on the total --- clients will be locked out if more servers than
 
161
  * this are needed.  It is intended solely to keep the server from crashing
 
162
  * when things get out of hand.
 
163
@@ -206,20 +202,20 @@
 
164
 
 
165
 /* config globals */
 
166
 
 
167
-int ap_threads_per_child=0;         /* Worker threads per child */
 
168
+int ap_threads_per_child = 0; /* Worker threads per child */
 
169
 static apr_proc_mutex_t *accept_mutex;
 
170
-static int ap_min_processors=DEFAULT_MIN_PROCESSORS;
 
171
-static int ap_min_free_processors=DEFAULT_MIN_FREE_PROCESSORS;
 
172
-static int ap_max_free_processors=DEFAULT_MAX_FREE_PROCESSORS;
 
173
-static int ap_max_processors=DEFAULT_MAX_PROCESSORS;
 
174
-static int ap_min_multiplexers=DEFAULT_MIN_MULTIPLEXERS;
 
175
-static int ap_max_multiplexers=DEFAULT_MAX_MULTIPLEXERS;
 
176
-static int ap_daemons_limit=0;      /* MaxClients */
 
177
-static int expire_timeout=DEFAULT_EXPIRE_TIMEOUT;
 
178
-static int idle_timeout=DEFAULT_IDLE_TIMEOUT;
 
179
-static int multiplexer_idle_timeout=DEFAULT_MULTIPLEXER_IDLE_TIMEOUT;
 
180
-static int processor_wait_timeout=DEFAULT_PROCESSOR_WAIT_TIMEOUT;
 
181
-static int processor_wait_steps=DEFAULT_PROCESSOR_WAIT_STEPS;
 
182
+static int ap_min_processors = DEFAULT_MIN_PROCESSORS;
 
183
+static int ap_min_free_processors = DEFAULT_MIN_FREE_PROCESSORS;
 
184
+static int ap_max_free_processors = DEFAULT_MAX_FREE_PROCESSORS;
 
185
+static int ap_max_processors = DEFAULT_MAX_PROCESSORS;
 
186
+static int ap_min_multiplexers = DEFAULT_MIN_MULTIPLEXERS;
 
187
+static int ap_max_multiplexers = DEFAULT_MAX_MULTIPLEXERS;
 
188
+static int ap_daemons_limit = 0; /* MaxClients */
 
189
+static int expire_timeout = DEFAULT_EXPIRE_TIMEOUT;
 
190
+static int idle_timeout = DEFAULT_IDLE_TIMEOUT;
 
191
+static int multiplexer_idle_timeout = DEFAULT_MULTIPLEXER_IDLE_TIMEOUT;
 
192
+static int processor_wait_timeout = DEFAULT_PROCESSOR_WAIT_TIMEOUT;
 
193
+static int processor_wait_steps = DEFAULT_PROCESSOR_WAIT_STEPS;
 
194
 static int server_limit = DEFAULT_SERVER_LIMIT;
 
195
 static int first_server_limit;
 
196
 static int changed_limit_at_restart;
 
197
@@ -233,11 +229,11 @@
 
198
 {
 
199
     int processor_id;
 
200
 
 
201
-    const char *name;  /* Server environment's unique string identifier */
 
202
+    const char *name; /* Server environment's unique string identifier */
 
203
 
 
204
     /* security settings */
 
205
-    uid_t uid;          /* user id */
 
206
-    gid_t gid;          /* group id */
 
207
+    uid_t uid; /* user id */
 
208
+    gid_t gid; /* group id */
 
209
     const char *chroot; /* directory to chroot() to, can be null */
 
210
     short nice_lvl;
 
211
     const char *cgroup; /* cgroup directory, can be null */
 
212
@@ -250,13 +246,18 @@
 
213
     short availability;
 
214
 
 
215
     /* sockets */
 
216
-    int input;          /* The socket descriptor */
 
217
-    int output;         /* The socket descriptor */
 
218
+    int input;  /* The socket descriptor */
 
219
+    int output; /* The socket descriptor */
 
220
 
 
221
     /* error flags */
 
222
     /* we use these to reduce log clutter (report only on first failure) */
 
223
     short error_cgroup; /* When writing pid to cgroup fails */
 
224
-    short error_pass;   /* When unable to pass request to the processor (eg all workers busy) */
 
225
+    short error_pass;   /* When unable to pass request to the processor */
 
226
+
 
227
+    /* statistics */
 
228
+    unsigned long stats_requests;    /* requests handled */
 
229
+    unsigned long stats_connections; /* connections handled */
 
230
+    unsigned long stats_dropped;     /* connections dropped because multiplexer was not able to pass */
 
231
 } server_env_t;
 
232
 
 
233
 typedef struct
 
234
@@ -270,13 +271,12 @@
 
235
     server_env_t *table;
 
236
 } server_env;
 
237
 
 
238
-
 
239
 typedef struct
 
240
 {
 
241
     /* identification */
 
242
-    int id;            /* index in child_info_table */
 
243
-    pid_t pid;         /* process id */
 
244
-    int status;                /* status of child */
 
245
+    int id;             /* index in child_info_table */
 
246
+    pid_t pid;          /* process id */
 
247
+    int status;         /* status of child */
 
248
     int type;           /* multiplexer or processor */
 
249
     server_env_t *senv;
 
250
 
 
251
@@ -289,16 +289,6 @@
 
252
 
 
253
 typedef struct
 
254
 {
 
255
-    /* identification */
 
256
-    int id;            /* index in child_info_table */
 
257
-    pid_t pid;         /* process id */
 
258
-    int status;                /* status of child */
 
259
-    int type;           /* multiplexer or processor */
 
260
-    apr_time_t last_used;
 
261
-} child_grace_info_t;
 
262
-
 
263
-typedef struct
 
264
-{
 
265
     apr_size_t num;
 
266
 } child_info_control;
 
267
 
 
268
@@ -314,22 +304,18 @@
 
269
     short missing_senv_reported;
 
270
 } peruser_server_conf;
 
271
 
 
272
-
 
273
 typedef struct peruser_header
 
274
 {
 
275
     char *headers;
 
276
     apr_pool_t *p;
 
277
 } peruser_header;
 
278
 
 
279
-
 
280
 /* Tables used to determine the user and group each child process should
 
281
  * run as.  The hash table is used to correlate a server name with a child
 
282
  * process.
 
283
  */
 
284
 static apr_size_t child_info_size;
 
285
 static child_info *child_info_image = NULL;
 
286
-static child_grace_info_t *child_grace_info_table;
 
287
-struct ap_ctable *ap_child_table;
 
288
 
 
289
 #define NUM_CHILDS (child_info_image != NULL ? child_info_image->control->num : 0)
 
290
 #define CHILD_INFO_TABLE (child_info_image != NULL ? child_info_image->table : NULL)
 
291
@@ -344,16 +330,10 @@
 
292
 #ifndef WIN32
 
293
 static /* but must be exported to mpm_winnt */
 
294
 #endif
 
295
-        apr_shm_t *child_info_shm = NULL;
 
296
-        apr_shm_t *server_env_shm = NULL;
 
297
+apr_shm_t *child_info_shm = NULL;
 
298
+apr_shm_t *server_env_shm = NULL;
 
299
 #endif
 
300
 
 
301
-/*
 
302
- * The max child slot ever assigned, preserved across restarts.  Necessary
 
303
- * to deal with MaxClients changes across AP_SIG_GRACEFUL restarts.  We 
 
304
- * use this value to optimize routines that have to scan the entire scoreboard.
 
305
- */
 
306
-int ap_max_daemons_limit = -1;
 
307
 server_rec *ap_server_conf;
 
308
 
 
309
 module AP_MODULE_DECLARE_DATA mpm_peruser_module;
 
310
@@ -362,7 +342,6 @@
 
311
 static apr_file_t *pipe_of_death_in = NULL;
 
312
 static apr_file_t *pipe_of_death_out = NULL;
 
313
 
 
314
-
 
315
 /* one_process --- debugging mode variable; can be set from the command line
 
316
  * with the -X flag.  If set, this gets you the child_main loop running
 
317
  * in the process which originally started up (no detach, no make_child),
 
318
@@ -376,13 +355,13 @@
 
319
 
 
320
 static int one_process = 0;
 
321
 
 
322
-static apr_pool_t *pconf;              /* Pool for config stuff */
 
323
-static apr_pool_t *pchild;             /* Pool for httpd child stuff */
 
324
+static apr_pool_t *pconf; /* Pool for config stuff */
 
325
+static apr_pool_t *pchild; /* Pool for httpd child stuff */
 
326
 
 
327
-static pid_t ap_my_pid;        /* it seems silly to call getpid all the time */
 
328
+static pid_t ap_my_pid; /* it seems silly to call getpid all the time */
 
329
 static pid_t parent_pid;
 
330
 static int my_child_num;
 
331
-ap_generation_t volatile ap_my_generation=0;
 
332
+ap_generation_t volatile ap_my_generation = 0;
 
333
 
 
334
 #ifdef TPF
 
335
 int tpf_child = 0;
 
336
@@ -391,12 +370,11 @@
 
337
 
 
338
 static int die_now = 0;
 
339
 
 
340
-int grace_children = 0;
 
341
-int grace_children_alive = 0;
 
342
 int server_env_cleanup = 1;
 
343
 const char *multiplexer_chroot = NULL;
 
344
+server_env_t *multiplexer_senv;
 
345
 
 
346
-// function added to mod_ssl and exported (there was nothing useful for us in the current api)
 
347
+/* function added to mod_ssl and exported (there was nothing useful for us) */
 
348
 typedef int (*ssl_server_is_https_t)(server_rec*);
 
349
 ssl_server_is_https_t ssl_server_is_https = NULL;
 
350
 
 
351
@@ -409,28 +387,28 @@
 
352
  */
 
353
 static void chdir_for_gprof(void)
 
354
 {
 
355
-    core_server_config *sconf = 
 
356
-       ap_get_module_config(ap_server_conf->module_config, &core_module);    
 
357
+    core_server_config *sconf =
 
358
+    ap_get_module_config(ap_server_conf->module_config, &core_module);
 
359
     char *dir = sconf->gprof_dir;
 
360
     const char *use_dir;
 
361
 
 
362
     if(dir) {
 
363
         apr_status_t res;
 
364
-       char buf[512];
 
365
-       int len = strlen(sconf->gprof_dir) - 1;
 
366
-       if(*(dir + len) == '%') {
 
367
-           dir[len] = '\0';
 
368
-           apr_snprintf(buf, sizeof(buf), "%sgprof.%d", dir, (int)getpid());
 
369
-       } 
 
370
-       use_dir = ap_server_root_relative(pconf, buf[0] ? buf : dir);
 
371
-       res = apr_dir_make(use_dir, 0755, pconf);
 
372
-       if(res != APR_SUCCESS && !APR_STATUS_IS_EEXIST(res)) {
 
373
-           ap_log_error(APLOG_MARK, APLOG_ERR, errno, ap_server_conf,
 
374
-                        "gprof: error creating directory %s", dir);
 
375
-       }
 
376
+        char buf[512];
 
377
+        int len = strlen(sconf->gprof_dir) - 1;
 
378
+        if(*(dir + len) == '%') {
 
379
+            dir[len] = '\0';
 
380
+            apr_snprintf(buf, sizeof(buf), "%sgprof.%d", dir, (int)getpid());
 
381
+        }
 
382
+        use_dir = ap_server_root_relative(pconf, buf[0] ? buf : dir);
 
383
+        res = apr_dir_make(use_dir, 0755, pconf);
 
384
+        if(res != APR_SUCCESS && !APR_STATUS_IS_EEXIST(res)) {
 
385
+            ap_log_error(APLOG_MARK, APLOG_ERR, errno, ap_server_conf,
 
386
+                    "gprof: error creating directory %s", dir);
 
387
+        }
 
388
     }
 
389
     else {
 
390
-       use_dir = ap_server_root_relative(pconf, DEFAULT_REL_RUNTIMEDIR);
 
391
+        use_dir = ap_server_root_relative(pconf, DEFAULT_REL_RUNTIMEDIR);
 
392
     }
 
393
 
 
394
     chdir(use_dir);
 
395
@@ -441,11 +419,13 @@
 
396
 
 
397
 char* child_type_string(int type)
 
398
 {
 
399
-    switch(type)
 
400
-    {
 
401
-        case CHILD_TYPE_MULTIPLEXER: return "MULTIPLEXER";
 
402
-        case CHILD_TYPE_PROCESSOR:   return "PROCESSOR";
 
403
-        case CHILD_TYPE_WORKER:      return "WORKER";
 
404
+    switch (type) {
 
405
+    case CHILD_TYPE_MULTIPLEXER:
 
406
+        return "MULTIPLEXER";
 
407
+    case CHILD_TYPE_PROCESSOR:
 
408
+        return "PROCESSOR";
 
409
+    case CHILD_TYPE_WORKER:
 
410
+        return "WORKER";
 
411
     }
 
412
 
 
413
     return "UNKNOWN";
 
414
@@ -453,32 +433,47 @@
 
415
 
 
416
 char* child_status_string(int status)
 
417
 {
 
418
-    switch(status)
 
419
-    {
 
420
-        case CHILD_STATUS_STANDBY:  return "STANDBY";
 
421
-        case CHILD_STATUS_STARTING: return "STARTING";
 
422
-        case CHILD_STATUS_READY:    return "READY";
 
423
-        case CHILD_STATUS_ACTIVE:   return "ACTIVE";
 
424
-        case CHILD_STATUS_RESTART:  return "RESTART";
 
425
+    switch (status) {
 
426
+    case CHILD_STATUS_STANDBY:
 
427
+        return "STANDBY";
 
428
+    case CHILD_STATUS_STARTING:
 
429
+        return "STARTING";
 
430
+    case CHILD_STATUS_READY:
 
431
+        return "READY";
 
432
+    case CHILD_STATUS_ACTIVE:
 
433
+        return "ACTIVE";
 
434
+    case CHILD_STATUS_RESTART:
 
435
+        return "RESTART";
 
436
     }
 
437
 
 
438
     return "UNKNOWN";
 
439
 }
 
440
 
 
441
-char* scoreboard_status_string(int status) {
 
442
-    switch(status)
 
443
-    {
 
444
-        case SERVER_DEAD:  return "DEAD";
 
445
-        case SERVER_STARTING: return "STARTING";
 
446
-        case SERVER_READY:    return "READY";
 
447
-        case SERVER_BUSY_READ:   return "BUSY_READ";
 
448
-        case SERVER_BUSY_WRITE:   return "BUSY_WRITE";
 
449
-        case SERVER_BUSY_KEEPALIVE:   return "BUSY_KEEPALIVE";
 
450
-        case SERVER_BUSY_LOG:   return "BUSY_LOG";
 
451
-        case SERVER_BUSY_DNS:   return "BUSY_DNS";
 
452
-        case SERVER_CLOSING:   return "CLOSING";
 
453
-        case SERVER_GRACEFUL:   return "GRACEFUL";
 
454
-        case SERVER_NUM_STATUS:   return "NUM_STATUS";
 
455
+char* scoreboard_status_string(int status)
 
456
+{
 
457
+    switch (status) {
 
458
+    case SERVER_DEAD:
 
459
+        return "DEAD";
 
460
+    case SERVER_STARTING:
 
461
+        return "STARTING";
 
462
+    case SERVER_READY:
 
463
+        return "READY";
 
464
+    case SERVER_BUSY_READ:
 
465
+        return "BUSY_READ";
 
466
+    case SERVER_BUSY_WRITE:
 
467
+        return "BUSY_WRITE";
 
468
+    case SERVER_BUSY_KEEPALIVE:
 
469
+        return "BUSY_KEEPALIVE";
 
470
+    case SERVER_BUSY_LOG:
 
471
+        return "BUSY_LOG";
 
472
+    case SERVER_BUSY_DNS:
 
473
+        return "BUSY_DNS";
 
474
+    case SERVER_CLOSING:
 
475
+        return "CLOSING";
 
476
+    case SERVER_GRACEFUL:
 
477
+        return "GRACEFUL";
 
478
+    case SERVER_NUM_STATUS:
 
479
+        return "NUM_STATUS";
 
480
     }
 
481
 
 
482
     return "UNKNOWN";
 
483
@@ -487,43 +482,44 @@
 
484
 void dump_child_table()
 
485
 {
 
486
 #ifdef MPM_PERUSER_DEBUG
 
487
-  int x;
 
488
-  server_env_t *senv;
 
489
+    int x;
 
490
+    server_env_t *senv;
 
491
 
 
492
-  _DBG("%-3s %-5s %-8s %-12s %-4s %-4s %-25s %5s %6s %7s",
 
493
-    "ID", "PID", "STATUS", "TYPE", "UID", "GID", "CHROOT", "INPUT", "OUTPUT", "SOCK_FD");
 
494
+    _DBG("%-3s %-5s %-8s %-12s %-4s %-4s %-25s %5s %6s %7s",
 
495
+         "ID", "PID", "STATUS", "TYPE", "UID", "GID", "CHROOT", "INPUT",
 
496
+         "OUTPUT", "SOCK_FD");
 
497
 
 
498
-  for(x = 0; x < NUM_CHILDS; x++)
 
499
-  {
 
500
-    senv = CHILD_INFO_TABLE[x].senv;
 
501
-    _DBG("%-3d %-5d %-8s %-12s %-4d %-4d %-25s %-5d %-6d %-7d",
 
502
-      CHILD_INFO_TABLE[x].id,
 
503
-      CHILD_INFO_TABLE[x].pid,
 
504
-      child_status_string(CHILD_INFO_TABLE[x].status),
 
505
-      child_type_string(CHILD_INFO_TABLE[x].type),
 
506
-      senv == NULL ? -1 : senv->uid,
 
507
-      senv == NULL ? -1 : senv->gid,
 
508
-      senv == NULL ? NULL : senv->chroot,
 
509
-      senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->input,
 
510
-      senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->output,
 
511
-      CHILD_INFO_TABLE[x].sock_fd);
 
512
-  }
 
513
+    for(x = 0; x < NUM_CHILDS; x++)
 
514
+    {
 
515
+        senv = CHILD_INFO_TABLE[x].senv;
 
516
+        _DBG("%-3d %-5d %-8s %-12s %-4d %-4d %-25s %-5d %-6d %-7d",
 
517
+                CHILD_INFO_TABLE[x].id,
 
518
+                CHILD_INFO_TABLE[x].pid,
 
519
+                child_status_string(CHILD_INFO_TABLE[x].status),
 
520
+                child_type_string(CHILD_INFO_TABLE[x].type),
 
521
+                senv == NULL ? -1 : senv->uid,
 
522
+                senv == NULL ? -1 : senv->gid,
 
523
+                senv == NULL ? NULL : senv->chroot,
 
524
+                senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->input,
 
525
+                senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->output,
 
526
+                CHILD_INFO_TABLE[x].sock_fd);
 
527
+    }
 
528
 #endif
 
529
 }
 
530
 
 
531
 void dump_server_env_image()
 
532
 {
 
533
 #ifdef MPM_PERUSER_DEBUG
 
534
-  int x;
 
535
-  _DBG("%-3s %-7s %-7s %-7s", "N", "INPUT", "OUTPUT", "CHROOT");
 
536
-  for(x = 0; x < NUM_SENV; x++)
 
537
-  {
 
538
-      _DBG("%-3d %-7d %-7d %-7s", x, SENV[x].input, SENV[x].output, SENV[x].chroot);
 
539
-  }
 
540
+    int x;
 
541
+    _DBG("%-3s %-7s %-7s %-7s", "N", "INPUT", "OUTPUT", "CHROOT");
 
542
+    for(x = 0; x < NUM_SENV; x++)
 
543
+    {
 
544
+        _DBG("%-3d %-7d %-7d %-7s", x, SENV[x].input, SENV[x].output,
 
545
+             SENV[x].chroot);
 
546
+    }
 
547
 #endif
 
548
 }
 
549
 
 
550
-
 
551
 /* XXX - I don't know if TPF will ever use this module or not, so leave
 
552
  * the ap_check_signals calls in but disable them - manoj */
 
553
 #define ap_check_signals() 
 
554
@@ -536,20 +532,20 @@
 
555
 
 
556
     mpm_state = AP_MPMQ_STOPPING;
 
557
 
 
558
-    if (CHILD_INFO_TABLE[my_child_num].type != CHILD_TYPE_MULTIPLEXER &&
 
559
-        CHILD_INFO_TABLE[my_child_num].senv)
 
560
+    if (CHILD_INFO_TABLE[my_child_num].type != CHILD_TYPE_MULTIPLEXER
 
561
+            && CHILD_INFO_TABLE[my_child_num].senv)
 
562
     {
 
563
-      retval = close(CHILD_INFO_TABLE[my_child_num].senv->input);
 
564
-      _DBG("close(CHILD_INFO_TABLE[%d].senv->input) = %d",
 
565
-           my_child_num, retval);
 
566
-
 
567
-      retval = close(CHILD_INFO_TABLE[my_child_num].senv->output);
 
568
-      _DBG("close(CHILD_INFO_TABLE[%d].senv->output) = %d",
 
569
-           my_child_num, retval);
 
570
+        retval = close(CHILD_INFO_TABLE[my_child_num].senv->input);
 
571
+        _DBG("close(CHILD_INFO_TABLE[%d].senv->input) = %d",
 
572
+                my_child_num, retval);
 
573
+
 
574
+        retval = close(CHILD_INFO_TABLE[my_child_num].senv->output);
 
575
+        _DBG("close(CHILD_INFO_TABLE[%d].senv->output) = %d",
 
576
+                my_child_num, retval);
 
577
     }
 
578
 
 
579
     if (pchild) {
 
580
-       apr_pool_destroy(pchild);
 
581
+        apr_pool_destroy(pchild);
 
582
     }
 
583
     ap_mpm_pod_close(pod);
 
584
     chdir_for_gprof();
 
585
@@ -562,8 +558,8 @@
 
586
     if (rv != APR_SUCCESS) {
 
587
         const char *msg = "couldn't grab the accept mutex";
 
588
 
 
589
-        if (ap_my_generation != 
 
590
-            ap_scoreboard_image->global->running_generation) {
 
591
+        if (ap_my_generation != ap_scoreboard_image->global->running_generation)
 
592
+        {
 
593
             ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, NULL, msg);
 
594
             clean_child_exit(0);
 
595
         }
 
596
@@ -580,8 +576,8 @@
 
597
     if (rv != APR_SUCCESS) {
 
598
         const char *msg = "couldn't release the accept mutex";
 
599
 
 
600
-        if (ap_my_generation != 
 
601
-            ap_scoreboard_image->global->running_generation) {
 
602
+        if (ap_my_generation != ap_scoreboard_image->global->running_generation)
 
603
+        {
 
604
             ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, NULL, msg);
 
605
             /* don't exit here... we have a connection to
 
606
              * process, after which point we'll see that the
 
607
@@ -608,65 +604,65 @@
 
608
 
 
609
 AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result)
 
610
 {
 
611
-    switch(query_code){
 
612
-        case AP_MPMQ_MAX_DAEMON_USED:
 
613
-            *result = ap_daemons_limit;
 
614
-            return APR_SUCCESS;
 
615
-        case AP_MPMQ_IS_THREADED:
 
616
-            *result = AP_MPMQ_NOT_SUPPORTED;
 
617
-            return APR_SUCCESS;
 
618
-        case AP_MPMQ_IS_FORKED:
 
619
-            *result = AP_MPMQ_DYNAMIC;
 
620
-            return APR_SUCCESS;
 
621
-        case AP_MPMQ_HARD_LIMIT_DAEMONS:
 
622
-            *result = server_limit;
 
623
-            return APR_SUCCESS;
 
624
-        case AP_MPMQ_HARD_LIMIT_THREADS:
 
625
-            *result = HARD_THREAD_LIMIT;
 
626
-            return APR_SUCCESS;
 
627
-        case AP_MPMQ_MAX_THREADS:
 
628
-            *result = 0;
 
629
-            return APR_SUCCESS;
 
630
-        case AP_MPMQ_MIN_SPARE_DAEMONS:
 
631
-            *result = ap_min_free_processors;
 
632
-            return APR_SUCCESS;
 
633
-        case AP_MPMQ_MIN_SPARE_THREADS:
 
634
-            *result = 0;
 
635
-            return APR_SUCCESS;
 
636
-        case AP_MPMQ_MAX_SPARE_THREADS:
 
637
-            *result = 0;
 
638
-            return APR_SUCCESS;
 
639
-        case AP_MPMQ_MAX_REQUESTS_DAEMON:
 
640
-            *result = ap_max_requests_per_child;
 
641
-            return APR_SUCCESS;
 
642
-        case AP_MPMQ_MAX_DAEMONS:
 
643
-            *result = server_limit;
 
644
-            return APR_SUCCESS;
 
645
-        case AP_MPMQ_MPM_STATE:
 
646
-            *result = mpm_state;
 
647
-            return APR_SUCCESS;
 
648
+    switch (query_code) {
 
649
+    case AP_MPMQ_MAX_DAEMON_USED:
 
650
+        *result = ap_daemons_limit;
 
651
+        return APR_SUCCESS;
 
652
+    case AP_MPMQ_IS_THREADED:
 
653
+        *result = AP_MPMQ_NOT_SUPPORTED;
 
654
+        return APR_SUCCESS;
 
655
+    case AP_MPMQ_IS_FORKED:
 
656
+        *result = AP_MPMQ_DYNAMIC;
 
657
+        return APR_SUCCESS;
 
658
+    case AP_MPMQ_HARD_LIMIT_DAEMONS:
 
659
+        *result = server_limit;
 
660
+        return APR_SUCCESS;
 
661
+    case AP_MPMQ_HARD_LIMIT_THREADS:
 
662
+        *result = HARD_THREAD_LIMIT;
 
663
+        return APR_SUCCESS;
 
664
+    case AP_MPMQ_MAX_THREADS:
 
665
+        *result = 0;
 
666
+        return APR_SUCCESS;
 
667
+    case AP_MPMQ_MIN_SPARE_DAEMONS:
 
668
+        *result = ap_min_free_processors;
 
669
+        return APR_SUCCESS;
 
670
+    case AP_MPMQ_MIN_SPARE_THREADS:
 
671
+        *result = 0;
 
672
+        return APR_SUCCESS;
 
673
+    case AP_MPMQ_MAX_SPARE_THREADS:
 
674
+        *result = 0;
 
675
+        return APR_SUCCESS;
 
676
+    case AP_MPMQ_MAX_REQUESTS_DAEMON:
 
677
+        *result = ap_max_requests_per_child;
 
678
+        return APR_SUCCESS;
 
679
+    case AP_MPMQ_MAX_DAEMONS:
 
680
+        *result = server_limit;
 
681
+        return APR_SUCCESS;
 
682
+    case AP_MPMQ_MPM_STATE:
 
683
+        *result = mpm_state;
 
684
+        return APR_SUCCESS;
 
685
     }
 
686
     return APR_ENOTIMPL;
 
687
 }
 
688
 
 
689
 #if defined(NEED_WAITPID)
 
690
 /*
 
691
-   Systems without a real waitpid sometimes lose a child's exit while waiting
 
692
-   for another.  Search through the scoreboard for missing children.
 
693
+ Systems without a real waitpid sometimes lose a child's exit while waiting
 
694
+ for another.  Search through the scoreboard for missing children.
 
695
  */
 
696
 int reap_children(int *exitcode, apr_exit_why_e *status)
 
697
 {
 
698
     int n, pid;
 
699
 
 
700
-    for (n = 0; n < ap_max_daemons_limit; ++n) {
 
701
-       if (ap_scoreboard_image->servers[n][0].status != SERVER_DEAD &&
 
702
-               kill((pid = ap_scoreboard_image->parent[n].pid), 0) == -1) {
 
703
-           ap_update_child_status_from_indexes(n, 0, SERVER_DEAD, NULL);
 
704
-           /* just mark it as having a successful exit status */
 
705
+    for (n = 0; n < NUM_CHILDS; ++n) {
 
706
+        if (ap_scoreboard_image->servers[n][0].status != SERVER_DEAD &&
 
707
+                kill((pid = ap_scoreboard_image->parent[n].pid), 0) == -1) {
 
708
+            ap_update_child_status_from_indexes(n, 0, SERVER_DEAD, NULL);
 
709
+            /* just mark it as having a successful exit status */
 
710
             *status = APR_PROC_EXIT;
 
711
             *exitcode = 0;
 
712
-           return(pid);
 
713
-       }
 
714
+            return(pid);
 
715
+        }
 
716
     }
 
717
     return 0;
 
718
 }
 
719
@@ -679,9 +675,8 @@
 
720
     retval = chdir(ap_coredump_dir);
 
721
     apr_signal(sig, SIG_DFL);
 
722
     if (ap_my_pid == parent_pid) {
 
723
-            ap_log_error(APLOG_MARK, APLOG_NOTICE,
 
724
-                         0, ap_server_conf,
 
725
-                         "seg fault or similar nasty error detected "
 
726
+        ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
 
727
+                     "seg fault or similar nasty error detected "
 
728
                          "in the parent process");
 
729
     }
 
730
     kill(getpid(), sig);
 
731
@@ -700,7 +695,7 @@
 
732
 
 
733
 static void just_die(int sig)
 
734
 {
 
735
-_DBG("function called");
 
736
+    _DBG("function called");
 
737
     clean_child_exit(0);
 
738
 }
 
739
 
 
740
@@ -713,11 +708,11 @@
 
741
 static void sig_term(int sig)
 
742
 {
 
743
     if (shutdown_pending == 1) {
 
744
-       /* Um, is this _probably_ not an error, if the user has
 
745
-        * tried to do a shutdown twice quickly, so we won't
 
746
-        * worry about reporting it.
 
747
-        */
 
748
-       return;
 
749
+        /* Um, is this _probably_ not an error, if the user has
 
750
+         * tried to do a shutdown twice quickly, so we won't
 
751
+         * worry about reporting it.
 
752
+         */
 
753
+        return;
 
754
     }
 
755
     shutdown_pending = 1;
 
756
 }
 
757
@@ -728,20 +723,16 @@
 
758
 static void restart(int sig)
 
759
 {
 
760
     if (restart_pending == 1) {
 
761
-       /* Probably not an error - don't bother reporting it */
 
762
-       return;
 
763
+        /* Probably not an error - don't bother reporting it */
 
764
+        return;
 
765
     }
 
766
     restart_pending = 1;
 
767
     is_graceful = (sig == AP_SIG_GRACEFUL);
 
768
 }
 
769
 
 
770
 /* Sets die_now if we received a character on the pipe_of_death */
 
771
-static apr_status_t check_pipe_of_death
 
772
-(
 
773
-    void **csd,
 
774
-    ap_listen_rec *lr,
 
775
-    apr_pool_t *ptrans
 
776
-)
 
777
+static apr_status_t check_pipe_of_death(void **csd, ap_listen_rec *lr,
 
778
+        apr_pool_t *ptrans)
 
779
 {
 
780
     int ret;
 
781
     char pipe_read_char;
 
782
@@ -749,24 +740,22 @@
 
783
 
 
784
     _DBG("WATCH: die_now=%d", die_now);
 
785
 
 
786
-    if (die_now) return APR_SUCCESS;
 
787
+    if (die_now)
 
788
+        return APR_SUCCESS;
 
789
 
 
790
     /* apr_thread_mutex_lock(pipe_of_death_mutex); */
 
791
     ret = apr_socket_recv(lr->sd, &pipe_read_char, &n);
 
792
-    if (APR_STATUS_IS_EAGAIN(ret))
 
793
-    {
 
794
-       /* It lost the lottery. It must continue to suffer
 
795
-        * through a life of servitude. */
 
796
-       _DBG("POD read EAGAIN");
 
797
-       return ret;
 
798
+    if (APR_STATUS_IS_EAGAIN(ret)) {
 
799
+        /* It lost the lottery. It must continue to suffer
 
800
+         * through a life of servitude. */
 
801
+        _DBG("POD read EAGAIN");
 
802
+        return ret;
 
803
     }
 
804
-    else
 
805
-    {
 
806
-       if (pipe_read_char != AP_PERUSER_CHAR_OF_DEATH)
 
807
-       {
 
808
-           _DBG("got wrong char %c", pipe_read_char);
 
809
-           return APR_SUCCESS;
 
810
-       }
 
811
+    else {
 
812
+        if (pipe_read_char != AP_PERUSER_CHAR_OF_DEATH) {
 
813
+            _DBG("got wrong char %c", pipe_read_char);
 
814
+            return APR_SUCCESS;
 
815
+        }
 
816
         /* It won the lottery (or something else is very
 
817
          * wrong). Embrace death with open arms. */
 
818
         die_now = 1;
 
819
@@ -785,53 +774,63 @@
 
820
     sa.sa_flags = 0;
 
821
 
 
822
     if (!one_process) {
 
823
-       sa.sa_handler = sig_coredump;
 
824
+        sa.sa_handler = sig_coredump;
 
825
 #if defined(SA_ONESHOT)
 
826
-       sa.sa_flags = SA_ONESHOT;
 
827
+        sa.sa_flags = SA_ONESHOT;
 
828
 #elif defined(SA_RESETHAND)
 
829
-       sa.sa_flags = SA_RESETHAND;
 
830
+        sa.sa_flags = SA_RESETHAND;
 
831
 #endif
 
832
-       if (sigaction(SIGSEGV, &sa, NULL) < 0)
 
833
-           ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGSEGV)");
 
834
+        if (sigaction(SIGSEGV, &sa, NULL) < 0)
 
835
+            ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
836
+                         "sigaction(SIGSEGV)");
 
837
 #ifdef SIGBUS
 
838
-       if (sigaction(SIGBUS, &sa, NULL) < 0)
 
839
-           ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGBUS)");
 
840
+        if (sigaction(SIGBUS, &sa, NULL) < 0)
 
841
+            ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
842
+                         "sigaction(SIGBUS)");
 
843
 #endif
 
844
 #ifdef SIGABORT
 
845
-       if (sigaction(SIGABORT, &sa, NULL) < 0)
 
846
-           ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGABORT)");
 
847
+        if (sigaction(SIGABORT, &sa, NULL) < 0)
 
848
+        ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
849
+                     "sigaction(SIGABORT)");
 
850
 #endif
 
851
 #ifdef SIGABRT
 
852
-       if (sigaction(SIGABRT, &sa, NULL) < 0)
 
853
-           ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGABRT)");
 
854
+        if (sigaction(SIGABRT, &sa, NULL) < 0)
 
855
+            ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
856
+                         "sigaction(SIGABRT)");
 
857
 #endif
 
858
 #ifdef SIGILL
 
859
-       if (sigaction(SIGILL, &sa, NULL) < 0)
 
860
-           ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGILL)");
 
861
+        if (sigaction(SIGILL, &sa, NULL) < 0)
 
862
+            ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
863
+                         "sigaction(SIGILL)");
 
864
 #endif
 
865
-       sa.sa_flags = 0;
 
866
+        sa.sa_flags = 0;
 
867
     }
 
868
     sa.sa_handler = sig_term;
 
869
     if (sigaction(SIGTERM, &sa, NULL) < 0)
 
870
-       ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGTERM)");
 
871
+        ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
872
+                     "sigaction(SIGTERM)");
 
873
 #ifdef SIGINT
 
874
     if (sigaction(SIGINT, &sa, NULL) < 0)
 
875
-        ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGINT)");
 
876
+        ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
877
+                     "sigaction(SIGINT)");
 
878
 #endif
 
879
 #ifdef SIGXCPU
 
880
     sa.sa_handler = SIG_DFL;
 
881
     if (sigaction(SIGXCPU, &sa, NULL) < 0)
 
882
-       ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGXCPU)");
 
883
+        ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
884
+                     "sigaction(SIGXCPU)");
 
885
 #endif
 
886
 #ifdef SIGXFSZ
 
887
     sa.sa_handler = SIG_IGN;
 
888
     if (sigaction(SIGXFSZ, &sa, NULL) < 0)
 
889
-       ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGXFSZ)");
 
890
+        ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
891
+                     "sigaction(SIGXFSZ)");
 
892
 #endif
 
893
 #ifdef SIGPIPE
 
894
     sa.sa_handler = SIG_IGN;
 
895
     if (sigaction(SIGPIPE, &sa, NULL) < 0)
 
896
-       ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGPIPE)");
 
897
+        ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
898
+                     "sigaction(SIGPIPE)");
 
899
 #endif
 
900
 
 
901
     /* we want to ignore HUPs and AP_SIG_GRACEFUL while we're busy 
 
902
@@ -840,29 +839,31 @@
 
903
     sigaddset(&sa.sa_mask, AP_SIG_GRACEFUL);
 
904
     sa.sa_handler = restart;
 
905
     if (sigaction(SIGHUP, &sa, NULL) < 0)
 
906
-       ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGHUP)");
 
907
+        ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
908
+                     "sigaction(SIGHUP)");
 
909
     if (sigaction(AP_SIG_GRACEFUL, &sa, NULL) < 0)
 
910
-        ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(" AP_SIG_GRACEFUL_STRING ")");
 
911
+        ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
912
+                     "sigaction(" AP_SIG_GRACEFUL_STRING ")");
 
913
 #else
 
914
     if (!one_process) {
 
915
-       apr_signal(SIGSEGV, sig_coredump);
 
916
+        apr_signal(SIGSEGV, sig_coredump);
 
917
 #ifdef SIGBUS
 
918
-       apr_signal(SIGBUS, sig_coredump);
 
919
+        apr_signal(SIGBUS, sig_coredump);
 
920
 #endif /* SIGBUS */
 
921
 #ifdef SIGABORT
 
922
-       apr_signal(SIGABORT, sig_coredump);
 
923
+        apr_signal(SIGABORT, sig_coredump);
 
924
 #endif /* SIGABORT */
 
925
 #ifdef SIGABRT
 
926
-       apr_signal(SIGABRT, sig_coredump);
 
927
+        apr_signal(SIGABRT, sig_coredump);
 
928
 #endif /* SIGABRT */
 
929
 #ifdef SIGILL
 
930
-       apr_signal(SIGILL, sig_coredump);
 
931
+        apr_signal(SIGILL, sig_coredump);
 
932
 #endif /* SIGILL */
 
933
 #ifdef SIGXCPU
 
934
-       apr_signal(SIGXCPU, SIG_DFL);
 
935
+        apr_signal(SIGXCPU, SIG_DFL);
 
936
 #endif /* SIGXCPU */
 
937
 #ifdef SIGXFSZ
 
938
-       apr_signal(SIGXFSZ, SIG_DFL);
 
939
+        apr_signal(SIGXFSZ, SIG_DFL);
 
940
 #endif /* SIGXFSZ */
 
941
     }
 
942
 
 
943
@@ -896,14 +897,12 @@
 
944
     return 0;
 
945
 }
 
946
 
 
947
-
 
948
 static int total_processors(int child_num)
 
949
 {
 
950
     int i, total;
 
951
 
 
952
-    for(i = 0, total = 0; i < NUM_CHILDS; ++i)
 
953
-    {
 
954
-        if(CHILD_INFO_TABLE[i].senv == CHILD_INFO_TABLE[child_num].senv)
 
955
+    for (i = 0, total = 0; i < NUM_CHILDS; ++i) {
 
956
+        if (CHILD_INFO_TABLE[i].senv == CHILD_INFO_TABLE[child_num].senv)
 
957
             total++;
 
958
     }
 
959
 
 
960
@@ -914,10 +913,11 @@
 
961
 {
 
962
     int i, total;
 
963
 
 
964
-    for(i = 0, total = 0; i < NUM_CHILDS; ++i)
 
965
-    {
 
966
-        if( (CHILD_INFO_TABLE[i].senv == CHILD_INFO_TABLE[child_num].senv) && (CHILD_INFO_TABLE[i].pid > 0 ) )
 
967
+    for (i = 0, total = 0; i < NUM_CHILDS; ++i) {
 
968
+        if (CHILD_INFO_TABLE[i].senv == CHILD_INFO_TABLE[child_num].senv
 
969
+            && CHILD_INFO_TABLE[i].pid > 0) {
 
970
             total++;
 
971
+        }
 
972
     }
 
973
 
 
974
     return total;
 
975
@@ -927,13 +927,15 @@
 
976
 {
 
977
     int i, total;
 
978
 
 
979
-    if(env_num >= NUM_SENV)
 
980
-      return -1;
 
981
+    if (env_num >= NUM_SENV) {
 
982
+        return -1;
 
983
+    }
 
984
 
 
985
-    for(i = 0, total = 0; i < NUM_CHILDS; ++i)
 
986
-    {
 
987
-        if((CHILD_INFO_TABLE[i].senv == &SENV[env_num]) && (CHILD_INFO_TABLE[i].pid > 0))
 
988
+    for (i = 0, total = 0; i < NUM_CHILDS; ++i) {
 
989
+        if (CHILD_INFO_TABLE[i].senv == &SENV[env_num]
 
990
+            && CHILD_INFO_TABLE[i].pid > 0) {
 
991
             total++;
 
992
+        }
 
993
     }
 
994
 
 
995
     return total;
 
996
@@ -943,11 +945,10 @@
 
997
 {
 
998
     int i, total;
 
999
 
 
1000
-    for(i = 0, total = 0; i < NUM_CHILDS; ++i)
 
1001
-    {
 
1002
-        if(CHILD_INFO_TABLE[i].senv == CHILD_INFO_TABLE[child_num].senv &&
 
1003
-           (CHILD_INFO_TABLE[i].status == CHILD_STATUS_READY))
 
1004
-        {
 
1005
+    for (i = 0, total = 0; i < NUM_CHILDS; ++i) {
 
1006
+        if (CHILD_INFO_TABLE[i].senv == CHILD_INFO_TABLE[child_num].senv
 
1007
+            && (CHILD_INFO_TABLE[i].status == CHILD_STATUS_READY
 
1008
+                || CHILD_INFO_TABLE[i].status == CHILD_STATUS_STARTING)) {
 
1009
             total++;
 
1010
         }
 
1011
     }
 
1012
@@ -959,69 +960,77 @@
 
1013
 {
 
1014
     int i, total;
 
1015
 
 
1016
-    for(i = 0, total = 0; i < NUM_CHILDS; ++i)
 
1017
-    {
 
1018
-        if(CHILD_INFO_TABLE[i].senv == &SENV[env_num] && (CHILD_INFO_TABLE[i].status == CHILD_STATUS_READY) )
 
1019
+    for (i = 0, total = 0; i < NUM_CHILDS; ++i) {
 
1020
+        if (CHILD_INFO_TABLE[i].senv == &SENV[env_num]
 
1021
+            && (CHILD_INFO_TABLE[i].status == CHILD_STATUS_READY
 
1022
+                || CHILD_INFO_TABLE[i].status == CHILD_STATUS_STARTING)) {
 
1023
             total++;
 
1024
+        }
 
1025
     }
 
1026
 
 
1027
     return total;
 
1028
 }
 
1029
 
 
1030
-
 
1031
-static int wait_for_workers(child_info_t *processor) {
 
1032
+static int wait_for_workers(child_info_t *processor)
 
1033
+{
 
1034
     int i, wait_step_size, wait_time;
 
1035
-    
 
1036
+
 
1037
     wait_step_size = 100 / processor_wait_steps;
 
1038
 
 
1039
     /* Check if the processor is available */
 
1040
-    if (total_processors(processor->id) == processor->senv->max_processors &&
 
1041
-        idle_processors(processor->id) == 0 && processor_wait_timeout > 0) {
 
1042
+    if (total_processors(processor->id) == processor->senv->max_processors
 
1043
+        && idle_processors(processor->id) == 0 && processor_wait_timeout > 0) {
 
1044
+
 
1045
         /* The processor is currently busy, try to wait (a little) */
 
1046
         _DBG("processor seems to be busy, trying to wait for it");
 
1047
 
 
1048
         if (processor->senv->availability == 0) {
 
1049
             processor->senv->availability = 0;
 
1050
 
 
1051
-            _DBG("processor is very busy (availability = 0) - not passing request");
 
1052
+            _DBG("processor is busy (availability = 0) - not passing request");
 
1053
 
 
1054
             if (processor->senv->error_pass == 0) {
 
1055
                 ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf,
 
1056
-                             "Too many requests for processor %s, increase MaxProcessors", processor->senv->name);
 
1057
+                             "Too many requests for processor %s, "
 
1058
+                             "increase MaxProcessors", processor->senv->name);
 
1059
             }
 
1060
-           
 
1061
+
 
1062
             /* No point in waiting for the processor, it's very busy */
 
1063
             return -1;
 
1064
         }
 
1065
-        
 
1066
-        /* We sleep a little (depending how available the processor usually is) */
 
1067
+
 
1068
+        /* We sleep a little (depending how available the processor is) */
 
1069
         wait_time = (processor_wait_timeout / processor_wait_steps) * 1000000;
 
1070
 
 
1071
-        for(i = 0; i <= processor->senv->availability; i += wait_step_size) {
 
1072
+        for (i = 0; i <= processor->senv->availability; i += wait_step_size) {
 
1073
             usleep(wait_time);
 
1074
 
 
1075
             /* Check if the processor is ready */
 
1076
-            if (total_processors(processor->id) < processor->senv->max_processors ||
 
1077
-                idle_processors(processor->id) > 0) {
 
1078
+            if (total_processors(processor->id)
 
1079
+                    < processor->senv->max_processors
 
1080
+                    || idle_processors(processor->id) > 0)
 
1081
+            {
 
1082
                 /* The processor has freed - lets use it */
 
1083
                 _DBG("processor freed before wait time expired");
 
1084
                 break;
 
1085
             }
 
1086
         }
 
1087
-        
 
1088
+
 
1089
         if (processor->senv->availability <= wait_step_size) {
 
1090
             processor->senv->availability = 0;
 
1091
         }
 
1092
-        else processor->senv->availability -= wait_step_size;
 
1093
-        
 
1094
+        else
 
1095
+            processor->senv->availability -= wait_step_size;
 
1096
+
 
1097
         /* Check if we waited all the time */
 
1098
         if (i > processor->senv->availability) {
 
1099
             _DBG("processor is busy - not passing request (availability = %d)",
 
1100
-                 processor->senv->availability);
 
1101
+                    processor->senv->availability);
 
1102
 
 
1103
             if (processor->senv->error_pass == 0) {
 
1104
                 ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf,
 
1105
-                             "Too many requests for processor %s, increase MaxProcessors", processor->senv->name);
 
1106
+                             "Too many requests for processor %s, "
 
1107
+                             "increase MaxProcessors", processor->senv->name);
 
1108
             }
 
1109
 
 
1110
             return -1;
 
1111
@@ -1033,10 +1042,12 @@
 
1112
     }
 
1113
     else {
 
1114
         /* Smoothly increment the availability back to 100 */
 
1115
-        if (processor->senv->availability >= 100-wait_step_size) {
 
1116
+        if (processor->senv->availability >= 100 - wait_step_size) {
 
1117
             processor->senv->availability = 100;
 
1118
         }
 
1119
-        else processor->senv->availability += wait_step_size;
 
1120
+        else {
 
1121
+            processor->senv->availability += wait_step_size;
 
1122
+        }
 
1123
     }
 
1124
 
 
1125
     return 0;
 
1126
@@ -1048,7 +1059,8 @@
 
1127
  * a socket or a whole request by inspecting the header_length of the
 
1128
  * message. If it is zero then only a socket was sent.
 
1129
  */
 
1130
-static int pass_socket(apr_socket_t *thesock, child_info_t *processor, apr_pool_t *pool)
 
1131
+static int pass_socket(apr_socket_t *thesock, child_info_t *processor,
 
1132
+        apr_pool_t *pool)
 
1133
 {
 
1134
     int rv;
 
1135
     struct msghdr msg;
 
1136
@@ -1061,63 +1073,64 @@
 
1137
     apr_size_t body_len = 0;
 
1138
     peruser_header h;
 
1139
 
 
1140
-    if (!processor)
 
1141
-    {
 
1142
+    if (!processor) {
 
1143
         _DBG("server %s in child %d has no child_info associated",
 
1144
-                "(unkonwn)", my_child_num);
 
1145
+                "(unknown)", my_child_num);
 
1146
         return -1;
 
1147
     }
 
1148
-    
 
1149
+
 
1150
     /* Make sure there are free workers on the other end */
 
1151
-    if (wait_for_workers(processor) == -1) return -1;
 
1152
+    if (wait_for_workers(processor) == -1) {
 
1153
+        return -1;
 
1154
+    }
 
1155
 
 
1156
     _DBG("passing request to another child.", 0);
 
1157
 
 
1158
     apr_os_sock_get(&sock_fd, thesock);
 
1159
+
 
1160
     /* passing remote_addr too, see comments below */
 
1161
     apr_socket_addr_get(&remote_addr, APR_REMOTE, thesock);
 
1162
-    
 
1163
+
 
1164
     header_len = 0;
 
1165
     body_len = 0;
 
1166
 
 
1167
     iov[0].iov_base = &header_len;
 
1168
-    iov[0].iov_len  = sizeof(header_len);
 
1169
+    iov[0].iov_len = sizeof(header_len);
 
1170
     iov[1].iov_base = &body_len;
 
1171
-    iov[1].iov_len  = sizeof(body_len);
 
1172
+    iov[1].iov_len = sizeof(body_len);
 
1173
     iov[2].iov_base = remote_addr;
 
1174
-    iov[2].iov_len  = sizeof(*remote_addr);
 
1175
+    iov[2].iov_len = sizeof(*remote_addr);
 
1176
     iov[3].iov_base = h.headers;
 
1177
-    iov[3].iov_len  = 0;
 
1178
+    iov[3].iov_len = 0;
 
1179
     iov[4].iov_base = body;
 
1180
-    iov[4].iov_len  = body_len;
 
1181
+    iov[4].iov_len = body_len;
 
1182
 
 
1183
-    msg.msg_name    = NULL;
 
1184
+    msg.msg_name = NULL;
 
1185
     msg.msg_namelen = 0;
 
1186
-    msg.msg_iov     = iov;
 
1187
-    msg.msg_iovlen  = 5;
 
1188
+    msg.msg_iov = iov;
 
1189
+    msg.msg_iovlen = 5;
 
1190
 
 
1191
     cmsg = apr_palloc(pool, sizeof(*cmsg) + sizeof(sock_fd));
 
1192
-    cmsg->cmsg_len   = CMSG_LEN(sizeof(sock_fd));
 
1193
+    cmsg->cmsg_len = CMSG_LEN(sizeof(sock_fd));
 
1194
     cmsg->cmsg_level = SOL_SOCKET;
 
1195
-    cmsg->cmsg_type  = SCM_RIGHTS;
 
1196
+    cmsg->cmsg_type = SCM_RIGHTS;
 
1197
 
 
1198
     memcpy(CMSG_DATA(cmsg), &sock_fd, sizeof(sock_fd));
 
1199
 
 
1200
-    msg.msg_control    = cmsg;
 
1201
+    msg.msg_control = cmsg;
 
1202
     msg.msg_controllen = cmsg->cmsg_len;
 
1203
 
 
1204
-    if (processor->status == CHILD_STATUS_STANDBY)
 
1205
-    {
 
1206
+    if (processor->status == CHILD_STATUS_STANDBY) {
 
1207
         _DBG("Activating child #%d", processor->id);
 
1208
         processor->status = CHILD_STATUS_STARTING;
 
1209
     }
 
1210
 
 
1211
-    _DBG("Writing message to %d, passing sock_fd:  %d", processor->senv->output, sock_fd);
 
1212
+    _DBG("Writing message to %d, passing sock_fd:  %d", processor->senv->output,
 
1213
+         sock_fd);
 
1214
     _DBG("header_len=%d headers=\"%s\"", header_len, h.headers);
 
1215
     _DBG("body_len=%d body=\"%s\"", body_len, body);
 
1216
 
 
1217
-    if ((rv = sendmsg(processor->senv->output, &msg, 0)) == -1)
 
1218
-    {
 
1219
+    if ((rv = sendmsg(processor->senv->output, &msg, 0)) == -1) {
 
1220
         apr_pool_destroy(pool);
 
1221
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
 
1222
                      "Writing message failed %d %d", rv, errno);
 
1223
@@ -1135,7 +1148,7 @@
 
1224
 }
 
1225
 
 
1226
 static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id,
 
1227
-                           apr_bucket_alloc_t *bucket_alloc, apr_pool_t *pool)
 
1228
+        apr_bucket_alloc_t *bucket_alloc, apr_pool_t *pool)
 
1229
 {
 
1230
     conn_rec *current_conn;
 
1231
     int sock_fd;
 
1232
@@ -1152,41 +1165,49 @@
 
1233
     current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id,
 
1234
                                             sbh, bucket_alloc);
 
1235
     _DBG("Looking up the right vhost");
 
1236
+
 
1237
     if (current_conn) {
 
1238
         ap_update_vhost_given_ip(current_conn);
 
1239
-        _DBG("Base server is %s, name based vhosts %s", current_conn->base_server->server_hostname,
 
1240
+        _DBG("Base server is %s, name based vhosts %s",
 
1241
+             current_conn->base_server->server_hostname,
 
1242
              current_conn->vhost_lookup_data ? "on" : "off");
 
1243
-        
 
1244
-        // check for ssl configuration for this server (ssl_server_is_https is NULL if we have no mod_ssl)
 
1245
-        if(ssl_server_is_https) ssl_on = ssl_server_is_https(current_conn->base_server);
 
1246
+
 
1247
+        /* check for ssl configuration for this server
 
1248
+         * (ssl_server_is_https is NULL if we have no mod_ssl) */
 
1249
+        if (ssl_server_is_https) {
 
1250
+            ssl_on = ssl_server_is_https(current_conn->base_server);
 
1251
+        }
 
1252
     }
 
1253
 
 
1254
-    if (current_conn && (!current_conn->vhost_lookup_data || ssl_on) && CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER) {
 
1255
-       _DBG("We are not using name based vhosts (or SSL is enabled), we'll directly pass the socket.");
 
1256
+    if (current_conn && (!current_conn->vhost_lookup_data || ssl_on)
 
1257
+            && CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER) {
 
1258
+        _DBG("We are not using name based vhosts (or SSL is enabled), "
 
1259
+             "we'll directly pass the socket.");
 
1260
 
 
1261
         sconf = PERUSER_SERVER_CONF(current_conn->base_server->module_config);
 
1262
 
 
1263
         if (sconf->senv != NULL) {
 
1264
             processor = &CHILD_INFO_TABLE[sconf->senv->processor_id];
 
1265
 
 
1266
-            _DBG("Forwarding without further inspection, processor %d", processor->id);
 
1267
-            if (processor->status == CHILD_STATUS_STANDBY)
 
1268
-              {
 
1269
-                  _DBG("Activating child #%d", processor->id);
 
1270
-                  processor->status = CHILD_STATUS_STARTING;
 
1271
-              }
 
1272
-            
 
1273
+            _DBG("Forwarding without further inspection, processor %d",
 
1274
+                 processor->id);
 
1275
+
 
1276
+            if (processor->status == CHILD_STATUS_STANDBY) {
 
1277
+                _DBG("Activating child #%d", processor->id);
 
1278
+                processor->status = CHILD_STATUS_STARTING;
 
1279
+            }
 
1280
+
 
1281
             _DBG("Creating new pool",0);
 
1282
             apr_pool_create(&ptrans, pool);
 
1283
 
 
1284
             _DBG("Passing request.",0);
 
1285
             if (pass_socket(sock, processor, ptrans) == -1) {
 
1286
                 if (processor->senv->error_pass == 0) {
 
1287
-                    ap_log_error(APLOG_MARK, APLOG_ERR, 0,
 
1288
-                                 ap_server_conf, "Could not pass request to proper "                             
 
1289
-                                 "child, request will not be honoured.");
 
1290
+                    ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf,
 
1291
+                                 "Could not pass request to proper child, "
 
1292
+                                 "request will not be honoured.");
 
1293
                 }
 
1294
-                
 
1295
+
 
1296
                 processor->senv->error_pass = 1;
 
1297
             }
 
1298
             else {
 
1299
@@ -1197,60 +1218,58 @@
 
1300
             _DBG("Base server has no senv set!");
 
1301
 
 
1302
             if (sconf->missing_senv_reported == 0) {
 
1303
-                ap_log_error(APLOG_MARK, APLOG_ERR, 0,
 
1304
-                             ap_server_conf, "Virtualhost %s has no server environment set, "                             
 
1305
-                             "request will not be honoured.", current_conn->base_server->server_hostname);
 
1306
+                ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf,
 
1307
+                             "Virtualhost %s has no server environment set, "
 
1308
+                             "request will not be honoured.",
 
1309
+                             current_conn->base_server->server_hostname);
 
1310
             }
 
1311
 
 
1312
             sconf->missing_senv_reported = 1;
 
1313
         }
 
1314
 
 
1315
-        if (current_conn)
 
1316
-        {
 
1317
-            _DBG("freeing connection",0);
 
1318
+        if (current_conn) {
 
1319
+            _DBG("freeing connection", 0);
 
1320
             ap_lingering_close(current_conn);
 
1321
         }
 
1322
 
 
1323
-        _DBG("doing longjmp",0);
 
1324
+        _DBG("doing longjmp", 0);
 
1325
         longjmp(CHILD_INFO_TABLE[my_child_num].jmpbuffer, 1);
 
1326
-       return;
 
1327
+        return;
 
1328
     }
 
1329
 
 
1330
-    if ((rv = apr_os_sock_get(&sock_fd, sock)) != APR_SUCCESS)
 
1331
-    {
 
1332
+    if ((rv = apr_os_sock_get(&sock_fd, sock)) != APR_SUCCESS) {
 
1333
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "apr_os_sock_get");
 
1334
     }
 
1335
 
 
1336
     _DBG("child_num=%d sock=%ld sock_fd=%d", my_child_num, sock, sock_fd);
 
1337
-    _DBG("type=%s %d", child_type_string(CHILD_INFO_TABLE[my_child_num].type), my_child_num);
 
1338
+    _DBG("type=%s %d", child_type_string(CHILD_INFO_TABLE[my_child_num].type),
 
1339
+         my_child_num);
 
1340
 
 
1341
 #ifdef _OSD_POSIX
 
1342
     if (sock_fd >= FD_SETSIZE)
 
1343
     {
 
1344
         ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL,
 
1345
-                     "new file descriptor %d is too large; you probably need "
 
1346
-                     "to rebuild Apache with a larger FD_SETSIZE "
 
1347
-                     "(currently %d)",
 
1348
-                     sock_fd, FD_SETSIZE);
 
1349
+                "new file descriptor %d is too large; you probably need "
 
1350
+                "to rebuild Apache with a larger FD_SETSIZE "
 
1351
+                "(currently %d)",
 
1352
+                sock_fd, FD_SETSIZE);
 
1353
         apr_socket_close(sock);
 
1354
         _DBG("child_num=%d: exiting with error", my_child_num);
 
1355
         return;
 
1356
     }
 
1357
 #endif
 
1358
 
 
1359
-    if (CHILD_INFO_TABLE[my_child_num].sock_fd < 0)
 
1360
-    {
 
1361
+    if (CHILD_INFO_TABLE[my_child_num].sock_fd < 0) {
 
1362
         ap_sock_disable_nagle(sock);
 
1363
     }
 
1364
 
 
1365
     if (!current_conn) {
 
1366
         ap_create_sb_handle(&sbh, p, conn_id, 0);
 
1367
-        current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id,
 
1368
-                                                sbh, bucket_alloc);
 
1369
+        current_conn = ap_run_create_connection(p, ap_server_conf, sock,
 
1370
+                                                conn_id, sbh, bucket_alloc);
 
1371
     }
 
1372
 
 
1373
-    if (current_conn)
 
1374
-    {
 
1375
+    if (current_conn) {
 
1376
         ap_process_connection(current_conn, sock);
 
1377
         ap_lingering_close(current_conn);
 
1378
     }
 
1379
@@ -1262,31 +1281,37 @@
 
1380
     apr_bucket_brigade *bb;
 
1381
     core_net_rec *net;
 
1382
 
 
1383
-    _DBG("function entered",0);
 
1384
+    _DBG("function entered", 0);
 
1385
 
 
1386
     /* -- fetch our sockets from the pool -- */
 
1387
-    apr_pool_userdata_get((void **)&bb, "PERUSER_SOCKETS", conn->pool);
 
1388
-    if (bb != NULL)
 
1389
-    {
 
1390
-        /* -- find the 'core' filter and give the socket data to it -- */
 
1391
-        for (filter = conn->output_filters; filter != NULL; filter = filter->next)
 
1392
-        {
 
1393
-            if (!strcmp(filter->frec->name, "core")) break;
 
1394
-        }
 
1395
-        if (filter != NULL)
 
1396
-        {
 
1397
-            net = filter->ctx;
 
1398
-            net->in_ctx = apr_palloc(conn->pool, sizeof(*net->in_ctx));
 
1399
-            net->in_ctx->b = bb;
 
1400
-            net->in_ctx->tmpbb = apr_brigade_create(net->in_ctx->b->p, 
 
1401
-                net->in_ctx->b->bucket_alloc);
 
1402
+    apr_pool_userdata_get((void **) &bb, "PERUSER_SOCKETS", conn->pool);
 
1403
+
 
1404
+    if (bb == NULL) {
 
1405
+        return DECLINED;
 
1406
+    }
 
1407
+
 
1408
+    /* -- find the 'core' filter and give the socket data to it -- */
 
1409
+    for (filter = conn->output_filters; filter != NULL;
 
1410
+         filter = filter->next) {
 
1411
+        if (!strcmp(filter->frec->name, "core")) {
 
1412
+            break;
 
1413
         }
 
1414
     }
 
1415
-    _DBG("leaving (DECLINED)", 0);
 
1416
+
 
1417
+    if (filter == NULL) {
 
1418
+        return DECLINED;
 
1419
+    }
 
1420
+
 
1421
+    net = filter->ctx;
 
1422
+    net->in_ctx = apr_palloc(conn->pool, sizeof(*net->in_ctx));
 
1423
+    net->in_ctx->b = bb;
 
1424
+    net->in_ctx->tmpbb = apr_brigade_create(net->in_ctx->b->p,
 
1425
+                                            net->in_ctx->b->bucket_alloc);
 
1426
+
 
1427
     return DECLINED;
 
1428
 }
 
1429
 
 
1430
-static int pass_request(request_rec *r, child_info_t *processor)
 
1431
+static int pass_request(request_rec *r, child_info_t *child)
 
1432
 {
 
1433
     int rv;
 
1434
     struct msghdr msg;
 
1435
@@ -1307,60 +1332,75 @@
 
1436
     const apr_table_entry_t *headers_in;
 
1437
     int counter;
 
1438
 
 
1439
-    apr_socket_t *thesock = ap_get_module_config(r->connection->conn_config, &core_module);
 
1440
+    apr_socket_t *thesock = ap_get_module_config(r->connection->conn_config,
 
1441
+                                                 &core_module);
 
1442
 
 
1443
-    if ((!r->the_request) || (!strlen(r->the_request)))
 
1444
-    {
 
1445
+    if (!r->the_request || !strlen(r->the_request)) {
 
1446
         _DBG("empty request. dropping it (%ld)", r->the_request);
 
1447
         return -1;
 
1448
     }
 
1449
 
 
1450
-    if (!processor)
 
1451
-    {
 
1452
+    if (!child) {
 
1453
         _DBG("server %s in child %d has no child_info associated",
 
1454
-                r->hostname, my_child_num);
 
1455
+             r->hostname, my_child_num);
 
1456
         return -1;
 
1457
     }
 
1458
 
 
1459
     _DBG("passing request to another child.  Vhost: %s, child %d %d",
 
1460
-      apr_table_get(r->headers_in, "Host"), my_child_num, processor->senv->output);
 
1461
-    _DBG("r->the_request=\"%s\" len=%d", r->the_request, strlen(r->the_request));
 
1462
+         apr_table_get(r->headers_in, "Host"), my_child_num,
 
1463
+         child->senv->output);
 
1464
+
 
1465
+    _DBG("r->the_request=\"%s\" len=%d", r->the_request,
 
1466
+         strlen(r->the_request));
 
1467
 
 
1468
     /* Make sure there are free workers on the other end */
 
1469
-    if (wait_for_workers(processor) == -1) return -1;
 
1470
+    if (child->type != CHILD_TYPE_MULTIPLEXER && wait_for_workers(child) == -1) {
 
1471
+        return -1;
 
1472
+    }
 
1473
+
 
1474
+    ap_get_brigade(r->connection->input_filters, bb, AP_MODE_EXHAUSTIVE,
 
1475
+                   APR_NONBLOCK_READ, len);
 
1476
 
 
1477
-    ap_get_brigade(r->connection->input_filters, bb, AP_MODE_EXHAUSTIVE, APR_NONBLOCK_READ, len);
 
1478
-    
 
1479
     /* Scan the brigade looking for heap-buckets */
 
1480
-    
 
1481
     _DBG("Scanning the brigade",0);
 
1482
     bucket = APR_BRIGADE_FIRST(bb);
 
1483
-    while (bucket != APR_BRIGADE_SENTINEL(bb) &&
 
1484
-           APR_BUCKET_IS_HEAP(bucket)) {
 
1485
-       _DBG("HEAP BUCKET is found, length=%d", bucket->length);
 
1486
+
 
1487
+    while (bucket != APR_BRIGADE_SENTINEL(bb) && APR_BUCKET_IS_HEAP(bucket)) {
 
1488
+        _DBG("HEAP BUCKET is found, length=%d", bucket->length);
 
1489
+
 
1490
         bucket = APR_BUCKET_NEXT(bucket);
 
1491
+
 
1492
         if (!APR_BUCKET_IS_HEAP(bucket)) {
 
1493
-            _DBG("NON-HEAP BUCKET is found, extracting the part of brigade before it",0);
 
1494
+            _DBG("NON-HEAP BUCKET is found, extracting the part of brigade "
 
1495
+                 "before it");
 
1496
+
 
1497
             body_bb = bb;
 
1498
             bb = apr_brigade_split(body_bb, bucket);
 
1499
+
 
1500
             /* Do we need to apr_destroy_brigade(bb) here?
 
1501
              * Yeah, I know we do apr_pool_destroy(r->pool) before return, but
 
1502
              * ap_get_brigade is in non-blocking mode (however len is zero).
 
1503
              */
 
1504
-            if (apr_brigade_pflatten(body_bb, &body, &body_len, r->pool) != APR_SUCCESS) {
 
1505
+            if (apr_brigade_pflatten(body_bb, &body, &body_len, r->pool)
 
1506
+                != APR_SUCCESS) {
 
1507
+
 
1508
                 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
 
1509
-                     "Unable to flatten brigade, declining request");
 
1510
+                             "Unable to flatten brigade, declining request");
 
1511
+
 
1512
                 apr_pool_destroy(r->pool);
 
1513
                 return DECLINED;
 
1514
             }
 
1515
+
 
1516
             _DBG("Brigade is flattened as body (body_len=%d)", body_len);
 
1517
         }
 
1518
     }
 
1519
-    _DBG("Scanning is finished",0);
 
1520
+
 
1521
+    _DBG("Scanning is finished");
 
1522
 
 
1523
     apr_os_sock_get(&sock_fd, thesock);
 
1524
+
 
1525
     /* looks like a bug while sending/receiving SCM_RIGHTS related to ipv6
 
1526
-       workaround: send remote_addr structure too */
 
1527
+     workaround: send remote_addr structure too */
 
1528
     apr_socket_addr_get(&remote_addr, APR_REMOTE, thesock);
 
1529
 
 
1530
     h.p = r->pool;
 
1531
@@ -1369,58 +1409,59 @@
 
1532
     headers_in = (const apr_table_entry_t *) headers_in_array->elts;
 
1533
 
 
1534
     h.headers = apr_pstrcat(h.p, r->the_request, CRLF, NULL);
 
1535
+
 
1536
     for (counter = 0; counter < headers_in_array->nelts; counter++) {
 
1537
-        if (headers_in[counter].key == NULL
 
1538
-         || headers_in[counter].val == NULL) {
 
1539
-             continue;
 
1540
-         }
 
1541
-         h.headers = apr_pstrcat(h.p, h.headers, headers_in[counter].key, ": ",
 
1542
-                                 headers_in[counter].val, CRLF, NULL);
 
1543
+        if (headers_in[counter].key == NULL ||
 
1544
+            headers_in[counter].val == NULL) {
 
1545
+            continue;
 
1546
+        }
 
1547
 
 
1548
+        h.headers = apr_pstrcat(h.p, h.headers, headers_in[counter].key, ": ",
 
1549
+                                headers_in[counter].val, CRLF, NULL);
 
1550
     }
 
1551
+
 
1552
     h.headers = apr_pstrcat(h.p, h.headers, CRLF, NULL);
 
1553
     ap_xlate_proto_to_ascii(h.headers, strlen(h.headers));
 
1554
 
 
1555
     header_len = strlen(h.headers);
 
1556
 
 
1557
     iov[0].iov_base = &header_len;
 
1558
-    iov[0].iov_len  = sizeof(header_len);
 
1559
+    iov[0].iov_len = sizeof(header_len);
 
1560
     iov[1].iov_base = &body_len;
 
1561
-    iov[1].iov_len  = sizeof(body_len);
 
1562
+    iov[1].iov_len = sizeof(body_len);
 
1563
     iov[2].iov_base = remote_addr;
 
1564
-    iov[2].iov_len  = sizeof(*remote_addr);
 
1565
+    iov[2].iov_len = sizeof(*remote_addr);
 
1566
     iov[3].iov_base = h.headers;
 
1567
-    iov[3].iov_len  = strlen(h.headers) + 1;
 
1568
+    iov[3].iov_len = strlen(h.headers) + 1;
 
1569
     iov[4].iov_base = body;
 
1570
-    iov[4].iov_len  = body_len;
 
1571
+    iov[4].iov_len = body_len;
 
1572
 
 
1573
-    msg.msg_name    = NULL;
 
1574
+    msg.msg_name = NULL;
 
1575
     msg.msg_namelen = 0;
 
1576
-    msg.msg_iov     = iov;
 
1577
-    msg.msg_iovlen  = 5;
 
1578
+    msg.msg_iov = iov;
 
1579
+    msg.msg_iovlen = 5;
 
1580
 
 
1581
     cmsg = apr_palloc(r->pool, sizeof(*cmsg) + sizeof(sock_fd));
 
1582
-    cmsg->cmsg_len   = CMSG_LEN(sizeof(sock_fd));
 
1583
+    cmsg->cmsg_len = CMSG_LEN(sizeof(sock_fd));
 
1584
     cmsg->cmsg_level = SOL_SOCKET;
 
1585
-    cmsg->cmsg_type  = SCM_RIGHTS;
 
1586
+    cmsg->cmsg_type = SCM_RIGHTS;
 
1587
 
 
1588
     memcpy(CMSG_DATA(cmsg), &sock_fd, sizeof(sock_fd));
 
1589
 
 
1590
-    msg.msg_control    = cmsg;
 
1591
+    msg.msg_control = cmsg;
 
1592
     msg.msg_controllen = cmsg->cmsg_len;
 
1593
 
 
1594
-    if (processor->status == CHILD_STATUS_STANDBY)
 
1595
-    {
 
1596
-        _DBG("Activating child #%d", processor->id);
 
1597
-        processor->status = CHILD_STATUS_STARTING;
 
1598
+    if (child->status == CHILD_STATUS_STANDBY) {
 
1599
+        _DBG("Activating child #%d", child->id);
 
1600
+        child->status = CHILD_STATUS_STARTING;
 
1601
     }
 
1602
 
 
1603
-    _DBG("Writing message to %d, passing sock_fd:  %d", processor->senv->output, sock_fd);
 
1604
+    _DBG("Writing message to %d, passing sock_fd:  %d", child->senv->output,
 
1605
+         sock_fd);
 
1606
     _DBG("header_len=%d headers=\"%s\"", header_len, h.headers);
 
1607
     _DBG("body_len=%d body=\"%s\"", body_len, body);
 
1608
 
 
1609
-    if ((rv = sendmsg(processor->senv->output, &msg, 0)) == -1)
 
1610
-    {
 
1611
+    if ((rv = sendmsg(child->senv->output, &msg, 0)) == -1) {
 
1612
         apr_pool_destroy(r->pool);
 
1613
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
 
1614
                      "Writing message failed %d %d", rv, errno);
 
1615
@@ -1437,12 +1478,9 @@
 
1616
     return 1;
 
1617
 }
 
1618
 
 
1619
-
 
1620
-static apr_status_t receive_from_multiplexer(
 
1621
-    void **trans_sock,  /* will be filled out w/ the received socket */
 
1622
-    ap_listen_rec *lr,  /* listener to receive from */
 
1623
-    apr_pool_t *ptrans  /* transaction wide pool */
 
1624
-)
 
1625
+static apr_status_t receive_connection(void **trans_sock,
 
1626
+                                             ap_listen_rec *lr,
 
1627
+                                             apr_pool_t *ptrans)
 
1628
 {
 
1629
     struct msghdr msg;
 
1630
     struct cmsghdr *cmsg;
 
1631
@@ -1459,27 +1497,27 @@
 
1632
 
 
1633
     /* -- bucket's, brigades and their allocators */
 
1634
     apr_bucket_alloc_t *alloc = apr_bucket_alloc_create(ptrans);
 
1635
-    apr_bucket_brigade *bb    = apr_brigade_create(ptrans, alloc);
 
1636
-    apr_bucket         *bucket;
 
1637
+    apr_bucket_brigade *bb = apr_brigade_create(ptrans, alloc);
 
1638
+    apr_bucket *bucket;
 
1639
 
 
1640
     /* prepare the buffers for receiving data from remote side */
 
1641
     iov[0].iov_base = &header_len;
 
1642
-    iov[0].iov_len  = sizeof(header_len);
 
1643
+    iov[0].iov_len = sizeof(header_len);
 
1644
     iov[1].iov_base = &body_len;
 
1645
-    iov[1].iov_len  = sizeof(body_len);
 
1646
+    iov[1].iov_len = sizeof(body_len);
 
1647
     iov[2].iov_base = &remote_addr;
 
1648
-    iov[2].iov_len  = sizeof(remote_addr);
 
1649
-    iov[3].iov_base = (char*)&buff;
 
1650
-    iov[3].iov_len  = HUGE_STRING_LEN;
 
1651
+    iov[2].iov_len = sizeof(remote_addr);
 
1652
+    iov[3].iov_base = (char*) &buff;
 
1653
+    iov[3].iov_len = HUGE_STRING_LEN;
 
1654
 
 
1655
     cmsg = apr_palloc(ptrans, sizeof(*cmsg) + sizeof(trans_sock_fd));
 
1656
     cmsg->cmsg_len = CMSG_LEN(sizeof(trans_sock_fd));
 
1657
 
 
1658
-    msg.msg_name       = NULL;
 
1659
-    msg.msg_namelen    = 0;
 
1660
-    msg.msg_iov        = iov;
 
1661
-    msg.msg_iovlen     = 4;
 
1662
-    msg.msg_control    = cmsg;
 
1663
+    msg.msg_name = NULL;
 
1664
+    msg.msg_namelen = 0;
 
1665
+    msg.msg_iov = iov;
 
1666
+    msg.msg_iovlen = 4;
 
1667
+    msg.msg_control = cmsg;
 
1668
     msg.msg_controllen = cmsg->cmsg_len;
 
1669
 
 
1670
     /* -- receive data from socket -- */
 
1671
@@ -1491,69 +1529,73 @@
 
1672
 
 
1673
     if (ret == -1 && errno == EAGAIN) {
 
1674
         _DBG("receive_from_multiplexer recvmsg() EAGAIN, someone was faster");
 
1675
-        
 
1676
+
 
1677
         return APR_EAGAIN;
 
1678
     }
 
1679
     else if (ret == -1) {
 
1680
         _DBG("recvmsg failed with error \"%s\"", strerror(errno));
 
1681
-        
 
1682
+
 
1683
         // Error, better kill this child to be on the safe side
 
1684
         return APR_EGENERAL;
 
1685
     }
 
1686
-    else _DBG("recvmsg returned %d", ret);
 
1687
+    else
 
1688
+        _DBG("recvmsg returned %d", ret);
 
1689
 
 
1690
     /* -- extract socket from the cmsg -- */
 
1691
     memcpy(&trans_sock_fd, CMSG_DATA(cmsg), sizeof(trans_sock_fd));
 
1692
+
 
1693
     /* here *trans_sock always == NULL (socket reset at got_fd), so
 
1694
-       we can use apr_os_sock_make() instead of apr_os_sock_put() */
 
1695
-    sockinfo.os_sock  = &trans_sock_fd;
 
1696
-    sockinfo.local    = NULL;
 
1697
-    sockinfo.remote   = (struct sockaddr *)&remote_addr.sa.sin;
 
1698
-    sockinfo.family   = remote_addr.family;
 
1699
-    sockinfo.type     = SOCK_STREAM;
 
1700
+     we can use apr_os_sock_make() instead of apr_os_sock_put() */
 
1701
+
 
1702
+    sockinfo.os_sock = &trans_sock_fd;
 
1703
+    sockinfo.local = NULL;
 
1704
+    sockinfo.remote = (struct sockaddr *) &remote_addr.sa.sin;
 
1705
+    sockinfo.family = remote_addr.family;
 
1706
+    sockinfo.type = SOCK_STREAM;
 
1707
 #ifdef APR_ENABLE_FOR_1_0
 
1708
     sockinfo.protocol = 0;
 
1709
 #endif
 
1710
-    apr_os_sock_make((apr_socket_t **)trans_sock, &sockinfo, ptrans);
 
1711
+    apr_os_sock_make((apr_socket_t **) trans_sock, &sockinfo, ptrans);
 
1712
     apr_os_sock_get(&fd_tmp, *trans_sock);
 
1713
 
 
1714
     _DBG("trans_sock=%ld fdx=%d sock_fd=%d",
 
1715
-         *trans_sock, trans_sock_fd, fd_tmp);
 
1716
+            *trans_sock, trans_sock_fd, fd_tmp);
 
1717
 
 
1718
     apr_cpystrn(headers, buff, header_len + 1);
 
1719
     _DBG("header_len=%d headers=\"%s\"", header_len, headers);
 
1720
 
 
1721
-    if (header_len) {    
 
1722
+    if (header_len) {
 
1723
         _DBG("header_len > 0, we got a request", 0);
 
1724
         /* -- store received data into an brigade and add
 
1725
-           it to the current transaction's pool -- */
 
1726
+         it to the current transaction's pool -- */
 
1727
         bucket = apr_bucket_eos_create(alloc);
 
1728
         APR_BRIGADE_INSERT_HEAD(bb, bucket);
 
1729
         bucket = apr_bucket_socket_create(*trans_sock, alloc);
 
1730
         APR_BRIGADE_INSERT_HEAD(bb, bucket);
 
1731
-        
 
1732
+
 
1733
         if (body_len) {
 
1734
-            body = (char*)&buff[header_len + 1];
 
1735
+            body = (char*) &buff[header_len + 1];
 
1736
             _DBG("body_len=%d body=\"%s\"", body_len, body);
 
1737
-            
 
1738
+
 
1739
             bucket = apr_bucket_heap_create(body, body_len, NULL, alloc);
 
1740
             APR_BRIGADE_INSERT_HEAD(bb, bucket);
 
1741
-        } else {
 
1742
+        }
 
1743
+        else {
 
1744
             _DBG("There is no body",0);
 
1745
         }
 
1746
-        
 
1747
+
 
1748
         bucket = apr_bucket_heap_create(headers, header_len, NULL, alloc);
 
1749
-        
 
1750
+
 
1751
         APR_BRIGADE_INSERT_HEAD(bb, bucket);
 
1752
         apr_pool_userdata_set(bb, "PERUSER_SOCKETS", NULL, ptrans);
 
1753
-    } else {
 
1754
+    }
 
1755
+    else {
 
1756
         _DBG("header_len == 0, we got a socket only", 0);
 
1757
     }
 
1758
-    _DBG("returning 0", 0);
 
1759
+
 
1760
     return 0;
 
1761
 }
 
1762
 
 
1763
-
 
1764
 /* Set group privileges.
 
1765
  *
 
1766
  * Note that we use the username as set in the config files, rather than
 
1767
@@ -1563,8 +1605,7 @@
 
1768
 
 
1769
 static int set_group_privs(uid_t uid, gid_t gid)
 
1770
 {
 
1771
-    if (!geteuid())
 
1772
-    {
 
1773
+    if (!geteuid()) {
 
1774
         struct passwd *ent;
 
1775
         const char *name;
 
1776
 
 
1777
@@ -1572,27 +1613,24 @@
 
1778
          * Set the GID before initgroups(), since on some platforms
 
1779
          * setgid() is known to zap the group list.
 
1780
          */
 
1781
-        if (setgid(gid) == -1)
 
1782
-        {
 
1783
+        if (setgid(gid) == -1) {
 
1784
             ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
 
1785
                          "setgid: unable to set group id to Group %u",
 
1786
-                         (unsigned)gid);
 
1787
+                         (unsigned) gid);
 
1788
             return -1;
 
1789
         }
 
1790
 
 
1791
         /* if getpwuid() fails, just skip initgroups() */
 
1792
 
 
1793
-        if ((ent = getpwuid(uid)) != NULL)
 
1794
-        {
 
1795
+        if ((ent = getpwuid(uid)) != NULL) {
 
1796
             name = ent->pw_name;
 
1797
 
 
1798
             /* Reset `groups' attributes. */
 
1799
 
 
1800
-            if (initgroups(name, gid) == -1)
 
1801
-            {
 
1802
+            if (initgroups(name, gid) == -1) {
 
1803
                 ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
 
1804
                              "initgroups: unable to set groups for User %s "
 
1805
-                             "and Group %u", name, (unsigned)gid);
 
1806
+                             "and Group %u", name, (unsigned) gid);
 
1807
                 return -1;
 
1808
             }
 
1809
         }
 
1810
@@ -1600,7 +1638,8 @@
 
1811
     return 0;
 
1812
 }
 
1813
 
 
1814
-static int peruser_setup_cgroup(int childnum, server_env_t *senv, apr_pool_t *pool)
 
1815
+static int peruser_setup_cgroup(int childnum, server_env_t *senv,
 
1816
+        apr_pool_t *pool)
 
1817
 {
 
1818
     apr_file_t *file;
 
1819
     int length;
 
1820
@@ -1612,22 +1651,23 @@
 
1821
     length = strlen(senv->cgroup) + CGROUP_TASKS_FILE_LEN;
 
1822
     tasks_file = malloc(length);
 
1823
 
 
1824
-    if (!tasks_file) return -1;
 
1825
+    if (!tasks_file) {
 
1826
+        return -1;
 
1827
+    }
 
1828
 
 
1829
     pos = apr_cpystrn(tasks_file, senv->cgroup, length);
 
1830
     apr_cpystrn(pos, CGROUP_TASKS_FILE, CGROUP_TASKS_FILE_LEN);
 
1831
 
 
1832
     /* Prepare the data to be written to tasks file */
 
1833
     content = apr_itoa(pool, ap_my_pid);
 
1834
-    content_len  = strlen(content);
 
1835
+    content_len = strlen(content);
 
1836
 
 
1837
     _DBG("writing pid %s to tasks file %s", content, tasks_file);
 
1838
 
 
1839
     if (apr_file_open(&file, tasks_file, APR_WRITE, APR_OS_DEFAULT, pool)) {
 
1840
         if (senv->error_cgroup == 0) {
 
1841
             ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
 
1842
-                         "cgroup: unable to open file %s",
 
1843
-                         tasks_file);
 
1844
+                         "cgroup: unable to open file %s", tasks_file);
 
1845
         }
 
1846
 
 
1847
         senv->error_cgroup = 1;
 
1848
@@ -1638,9 +1678,9 @@
 
1849
     if (apr_file_write(file, content, &content_len)) {
 
1850
         if (senv->error_cgroup == 0) {
 
1851
             ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
 
1852
-                         "cgroup: unable to write pid to file %s",
 
1853
-                         tasks_file);
 
1854
+                         "cgroup: unable to write pid to file %s", tasks_file);
 
1855
         }
 
1856
+
 
1857
         senv->error_cgroup = 1;
 
1858
     }
 
1859
     else {
 
1860
@@ -1664,17 +1704,17 @@
 
1861
         nice(senv->nice_lvl);
 
1862
     }
 
1863
 
 
1864
-    if(senv->chroot) {
 
1865
+    if (senv->chroot) {
 
1866
         _DBG("chdir to %s", senv->chroot);
 
1867
 
 
1868
-        if(chdir(senv->chroot)) {
 
1869
+        if (chdir(senv->chroot)) {
 
1870
             ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
 
1871
                          "chdir: unable to change to directory: %s",
 
1872
                          senv->chroot);
 
1873
             return -1;
 
1874
         }
 
1875
 
 
1876
-        if(chroot(senv->chroot)) {
 
1877
+        if (chroot(senv->chroot)) {
 
1878
             ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
 
1879
                          "chroot: unable to chroot to directory: %s",
 
1880
                          senv->chroot);
 
1881
@@ -1682,41 +1722,44 @@
 
1882
         }
 
1883
     }
 
1884
 
 
1885
-    if(senv->cgroup) {
 
1886
-       peruser_setup_cgroup(childnum, senv, pool);
 
1887
+    if (senv->cgroup) {
 
1888
+        peruser_setup_cgroup(childnum, senv, pool);
 
1889
     }
 
1890
 
 
1891
     if (senv->uid == -1 && senv->gid == -1) {
 
1892
         return unixd_setup_child();
 
1893
     }
 
1894
+
 
1895
     if (set_group_privs(senv->uid, senv->gid)) {
 
1896
         return -1;
 
1897
     }
 
1898
+
 
1899
     /* Only try to switch if we're running as root */
 
1900
-    if (!geteuid()
 
1901
-        && (
 
1902
+    if (!geteuid() && (
 
1903
 #ifdef _OSD_POSIX
 
1904
             os_init_job_environment(ap_server_conf, unixd_config.user_name,
 
1905
-                                    one_process) != 0 ||
 
1906
+                    one_process) != 0 ||
 
1907
 #endif
 
1908
             setuid(senv->uid) == -1)) {
 
1909
         ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
 
1910
-                     "setuid: unable to change to uid: %ld",
 
1911
-                     (long) senv->uid);
 
1912
+                     "setuid: unable to change to uid: %ld", (long) senv->uid);
 
1913
         return -1;
 
1914
     }
 
1915
+
 
1916
     return 0;
 
1917
 }
 
1918
 
 
1919
 static int check_signal(int signum)
 
1920
 {
 
1921
     _DBG("signum=%d", signum);
 
1922
+
 
1923
     switch (signum) {
 
1924
     case SIGTERM:
 
1925
     case SIGINT:
 
1926
         just_die(signum);
 
1927
         return 1;
 
1928
     }
 
1929
+
 
1930
     return 0;
 
1931
 }
 
1932
 
 
1933
@@ -1725,38 +1768,45 @@
 
1934
  * In other words, don't change this one without checking table_do in alloc.c.
 
1935
  * It returns true unless there was a write error of some kind.
 
1936
  */
 
1937
-static int peruser_header_field(peruser_header *h,
 
1938
-                             const char *fieldname, const char *fieldval)
 
1939
+static int peruser_header_field(peruser_header *h, const char *fieldname,
 
1940
+                                const char *fieldval)
 
1941
 {
 
1942
     apr_pstrcat(h->p, h->headers, fieldname, ": ", fieldval, CRLF, NULL);
 
1943
+
 
1944
     return 1;
 
1945
 }
 
1946
 
 
1947
-static inline ap_listen_rec* listen_add(apr_pool_t* pool, apr_socket_t *sock, void* accept_func)
 
1948
+static inline ap_listen_rec* listen_add(apr_pool_t* pool, apr_socket_t *sock,
 
1949
+        void* accept_func)
 
1950
 {
 
1951
     ap_listen_rec *lr_walk, *lr_new;
 
1952
 
 
1953
     _DBG("function entered", 0);
 
1954
+
 
1955
     /* -- create an new listener for this child -- */
 
1956
     lr_new = apr_palloc(pool, sizeof(*lr_new));
 
1957
-    lr_new->sd          = sock;
 
1958
-    lr_new->active      = 1;
 
1959
+    lr_new->sd = sock;
 
1960
+    lr_new->active = 1;
 
1961
     lr_new->accept_func = accept_func;
 
1962
-    lr_new->next        = NULL;
 
1963
+    lr_new->next = NULL;
 
1964
 
 
1965
     /* -- add the new listener_rec into the list -- */
 
1966
     /* FIXME: should we somehow lock this list ? */
 
1967
     lr_walk = ap_listeners;
 
1968
-    if (lr_walk)
 
1969
-    {
 
1970
-        while (lr_walk->next) lr_walk = lr_walk->next;
 
1971
+
 
1972
+    if (lr_walk) {
 
1973
+        while (lr_walk->next) {
 
1974
+            lr_walk = lr_walk->next;
 
1975
+        }
 
1976
+
 
1977
         lr_walk->next = lr_new;
 
1978
     }
 
1979
-    else
 
1980
-    {
 
1981
+    else {
 
1982
         ap_listeners = lr_walk = lr_new;
 
1983
     }
 
1984
+
 
1985
     num_listensocks++;
 
1986
+
 
1987
     return lr_new;
 
1988
 }
 
1989
 
 
1990
@@ -1767,13 +1817,13 @@
 
1991
     _DBG("function entered", 0);
 
1992
 
 
1993
     /* FIXME: should we somehow lock this list ? */
 
1994
-    while (ap_listeners)
 
1995
-    {
 
1996
+    while (ap_listeners) {
 
1997
         lr_walk = ap_listeners->next;
 
1998
         apr_socket_close(ap_listeners->sd);
 
1999
         ap_listeners = lr_walk;
 
2000
     }
 
2001
-    num_listensocks=0;
 
2002
+
 
2003
+    num_listensocks = 0;
 
2004
 }
 
2005
 
 
2006
 apr_status_t cleanup_child_info(void *d)
 
2007
@@ -1820,17 +1870,18 @@
 
2008
     apr_socket_t *sock = NULL;
 
2009
     apr_socket_t *pod_sock = NULL;
 
2010
 
 
2011
-    mpm_state = AP_MPMQ_STARTING; /* for benefit of any hooks that run as this
 
2012
-                                  * child initializes
 
2013
-                                  */
 
2014
+    /* for benefit of any hooks that run as this
 
2015
+     * child initializes
 
2016
+     */
 
2017
+    mpm_state = AP_MPMQ_STARTING;
 
2018
 
 
2019
     my_child_num = child_num_arg;
 
2020
     ap_my_pid = getpid();
 
2021
     requests_this_child = 0;
 
2022
 
 
2023
     _DBG("sock_fd_in=%d sock_fd_out=%d",
 
2024
-         CHILD_INFO_TABLE[my_child_num].senv->input,
 
2025
-         CHILD_INFO_TABLE[my_child_num].senv->output);
 
2026
+            CHILD_INFO_TABLE[my_child_num].senv->input,
 
2027
+            CHILD_INFO_TABLE[my_child_num].senv->output);
 
2028
 
 
2029
     /* Get a sub context for global allocations in this child, so that
 
2030
      * we can have cleanups occur when the child exits.
 
2031
@@ -1853,35 +1904,44 @@
 
2032
         clean_child_exit(APEXIT_CHILDFATAL);
 
2033
     }
 
2034
 
 
2035
-    switch(CHILD_INFO_TABLE[my_child_num].type)
 
2036
-    {
 
2037
-        case CHILD_TYPE_MULTIPLEXER:
 
2038
-            _DBG("MULTIPLEXER %d", my_child_num);
 
2039
-            break;
 
2040
-
 
2041
-        case CHILD_TYPE_PROCESSOR:
 
2042
-        case CHILD_TYPE_WORKER:
 
2043
-            _DBG("%s %d", child_type_string(CHILD_INFO_TABLE[my_child_num].type), my_child_num);
 
2044
-
 
2045
-            /* -- create new listener to receive from multiplexer -- */
 
2046
-            apr_os_sock_put(&sock, &CHILD_INFO_TABLE[my_child_num].senv->input, pconf);
 
2047
-            listen_clear();
 
2048
-            listen_add(pconf, sock, receive_from_multiplexer);
 
2049
-
 
2050
-            break;
 
2051
+    switch (CHILD_INFO_TABLE[my_child_num].type) {
 
2052
+    case CHILD_TYPE_MULTIPLEXER:
 
2053
+        _DBG("MULTIPLEXER %d", my_child_num);
 
2054
+
 
2055
+        /* -- create new listener to receive from workers -- */
 
2056
+        apr_os_sock_put(&sock, &CHILD_INFO_TABLE[my_child_num].senv->input,
 
2057
+                        pconf);
 
2058
+        listen_add(pconf, sock, receive_connection);
 
2059
+        break;
 
2060
+
 
2061
+    case CHILD_TYPE_PROCESSOR:
 
2062
+    case CHILD_TYPE_WORKER:
 
2063
+        _DBG("%s %d", child_type_string(CHILD_INFO_TABLE[my_child_num].type),
 
2064
+             my_child_num);
 
2065
+
 
2066
+        /* -- create new listener to receive from multiplexer -- */
 
2067
+        apr_os_sock_put(&sock, &CHILD_INFO_TABLE[my_child_num].senv->input,
 
2068
+                        pconf);
 
2069
+        listen_clear();
 
2070
+        listen_add(pconf, sock, receive_connection);
 
2071
+
 
2072
+        break;
 
2073
+
 
2074
+    default:
 
2075
+        _DBG("unspecified child type for %d sleeping a while ...",
 
2076
+             my_child_num);
 
2077
 
 
2078
-        default:
 
2079
-            _DBG("unspecified child type for %d sleeping a while ...", my_child_num);
 
2080
-            sleep(5);
 
2081
-            return;
 
2082
+        sleep(5);
 
2083
+        return;
 
2084
     }
 
2085
 
 
2086
     apr_os_file_get(&fd, pipe_of_death_in);
 
2087
     apr_os_sock_put(&pod_sock, &fd, pconf);
 
2088
     listen_add(pconf, pod_sock, check_pipe_of_death);
 
2089
 
 
2090
-    if(peruser_setup_child(my_child_num, pchild) != 0)
 
2091
+    if (peruser_setup_child(my_child_num, pchild) != 0) {
 
2092
         clean_child_exit(APEXIT_CHILDFATAL);
 
2093
+    }
 
2094
 
 
2095
     ap_run_child_init(pchild, ap_server_conf);
 
2096
 
 
2097
@@ -1889,8 +1949,8 @@
 
2098
     (void) ap_update_child_status(sbh, SERVER_READY, (request_rec *) NULL);
 
2099
 
 
2100
     /* Set up the pollfd array */
 
2101
-    listensocks = apr_pcalloc(pchild,
 
2102
-                            sizeof(*listensocks) * (num_listensocks));
 
2103
+    listensocks = apr_pcalloc(pchild, sizeof(*listensocks) * (num_listensocks));
 
2104
+
 
2105
     for (lr = ap_listeners, i = 0; i < num_listensocks; lr = lr->next, i++) {
 
2106
         listensocks[i].accept_func = lr->accept_func;
 
2107
         listensocks[i].sd = lr->sd;
 
2108
@@ -1909,29 +1969,30 @@
 
2109
     bucket_alloc = apr_bucket_alloc_create(pchild);
 
2110
 
 
2111
     while (!die_now) {
 
2112
-       /*
 
2113
-        * (Re)initialize this child to a pre-connection state.
 
2114
-        */
 
2115
+        /*
 
2116
+         * (Re)initialize this child to a pre-connection state.
 
2117
+         */
 
2118
 
 
2119
-       current_conn = NULL;
 
2120
+        current_conn = NULL;
 
2121
 
 
2122
-       apr_pool_clear(ptrans);
 
2123
+        apr_pool_clear(ptrans);
 
2124
 
 
2125
-       if (CHILD_INFO_TABLE[my_child_num].type != CHILD_TYPE_MULTIPLEXER
 
2126
-             && ap_max_requests_per_child > 0
 
2127
-            && requests_this_child++ >= ap_max_requests_per_child) {
 
2128
+        if (CHILD_INFO_TABLE[my_child_num].type != CHILD_TYPE_MULTIPLEXER
 
2129
+            && ap_max_requests_per_child > 0
 
2130
+            && requests_this_child++ >= ap_max_requests_per_child) {
 
2131
             _DBG("max requests reached, dying now", 0);
 
2132
-           clean_child_exit(0);
 
2133
-       }
 
2134
+            clean_child_exit(0);
 
2135
+        }
 
2136
 
 
2137
         (void) ap_update_child_status(sbh, SERVER_READY, (request_rec *) NULL);
 
2138
 
 
2139
         CHILD_INFO_TABLE[my_child_num].status = CHILD_STATUS_READY;
 
2140
-        _DBG("Child %d (%s) is now ready", my_child_num, child_type_string(CHILD_INFO_TABLE[my_child_num].type));
 
2141
+        _DBG("Child %d (%s) is now ready", my_child_num,
 
2142
+             child_type_string(CHILD_INFO_TABLE[my_child_num].type));
 
2143
 
 
2144
-       /*
 
2145
-        * Wait for an acceptable connection to arrive.
 
2146
-        */
 
2147
+        /*
 
2148
+         * Wait for an acceptable connection to arrive.
 
2149
+         */
 
2150
 
 
2151
         /* Lock around "accept", if necessary */
 
2152
         if (CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER) {
 
2153
@@ -1943,54 +2004,63 @@
 
2154
         }
 
2155
         else {
 
2156
             /* multiple listening sockets - need to poll */
 
2157
-           for (;;) {
 
2158
+            for (;;) {
 
2159
                 apr_status_t ret;
 
2160
                 apr_int32_t n;
 
2161
 
 
2162
                 ret = apr_poll(pollset, num_listensocks, &n, -1);
 
2163
+
 
2164
                 if (ret != APR_SUCCESS) {
 
2165
                     if (APR_STATUS_IS_EINTR(ret)) {
 
2166
                         continue;
 
2167
                     }
 
2168
-                   /* Single Unix documents select as returning errnos
 
2169
-                    * EBADF, EINTR, and EINVAL... and in none of those
 
2170
-                    * cases does it make sense to continue.  In fact
 
2171
-                    * on Linux 2.0.x we seem to end up with EFAULT
 
2172
-                    * occasionally, and we'd loop forever due to it.
 
2173
-                    */
 
2174
-                   ap_log_error(APLOG_MARK, APLOG_ERR, ret, ap_server_conf,
 
2175
-                             "apr_poll: (listen)");
 
2176
-                   clean_child_exit(1);
 
2177
+
 
2178
+                    /* Single Unix documents select as returning errnos
 
2179
+                     * EBADF, EINTR, and EINVAL... and in none of those
 
2180
+                     * cases does it make sense to continue.  In fact
 
2181
+                     * on Linux 2.0.x we seem to end up with EFAULT
 
2182
+                     * occasionally, and we'd loop forever due to it.
 
2183
+                     */
 
2184
+                    ap_log_error(APLOG_MARK, APLOG_ERR, ret, ap_server_conf,
 
2185
+                                 "apr_poll: (listen)");
 
2186
+                    clean_child_exit(1);
 
2187
                 }
 
2188
+
 
2189
                 /* find a listener */
 
2190
                 curr_pollfd = last_pollfd;
 
2191
                 do {
 
2192
                     curr_pollfd++;
 
2193
+
 
2194
                     if (curr_pollfd >= num_listensocks) {
 
2195
                         curr_pollfd = 0;
 
2196
                     }
 
2197
+
 
2198
                     /* XXX: Should we check for POLLERR? */
 
2199
                     if (pollset[curr_pollfd].rtnevents & APR_POLLIN) {
 
2200
                         last_pollfd = curr_pollfd;
 
2201
                         offset = curr_pollfd;
 
2202
                         goto got_fd;
 
2203
                     }
 
2204
-                } while (curr_pollfd != last_pollfd);
 
2205
+                }
 
2206
+                while (curr_pollfd != last_pollfd);
 
2207
 
 
2208
                 continue;
 
2209
             }
 
2210
         }
 
2211
-    got_fd:
 
2212
+
 
2213
+        got_fd:
 
2214
+
 
2215
         _DBG("input available ... resetting socket.",0);
 
2216
-        sock = NULL;    /* important! */
 
2217
+        sock = NULL; /* important! */
 
2218
 
 
2219
         /* if we accept() something we don't want to die, so we have to
 
2220
          * defer the exit
 
2221
          */
 
2222
-        status = listensocks[offset].accept_func((void *)&sock, &listensocks[offset], ptrans);
 
2223
+        status = listensocks[offset].accept_func((void *) &sock,
 
2224
+                                                 &listensocks[offset], ptrans);
 
2225
 
 
2226
         if (CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER) {
 
2227
-            SAFE_ACCEPT(accept_mutex_off());   /* unlock after "accept" */
 
2228
+            SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */
 
2229
         }
 
2230
 
 
2231
         if (status == APR_EGENERAL) {
 
2232
@@ -2003,45 +2073,48 @@
 
2233
 
 
2234
         if (CHILD_INFO_TABLE[my_child_num].status == CHILD_STATUS_READY) {
 
2235
             CHILD_INFO_TABLE[my_child_num].status = CHILD_STATUS_ACTIVE;
 
2236
-            _DBG("Child %d (%s) is now active", my_child_num, child_type_string(CHILD_INFO_TABLE[my_child_num].type));
 
2237
+            _DBG("Child %d (%s) is now active", my_child_num,
 
2238
+                 child_type_string(CHILD_INFO_TABLE[my_child_num].type));
 
2239
         }
 
2240
 
 
2241
-        if (CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_PROCESSOR ||
 
2242
-            CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_WORKER ||
 
2243
-            CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER)
 
2244
-        {
 
2245
-          _DBG("CHECKING IF WE SHOULD CLONE A CHILD...");
 
2246
+        if (CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_PROCESSOR
 
2247
+            || CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_WORKER
 
2248
+            || CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER) {
 
2249
+
 
2250
+            _DBG("CHECKING IF WE SHOULD CLONE A CHILD...");
 
2251
 
 
2252
-          _DBG("total_processors = %d, max_processors = %d",
 
2253
-            total_processors(my_child_num),
 
2254
-            CHILD_INFO_TABLE[my_child_num].senv->max_processors);
 
2255
-
 
2256
-          _DBG("idle_processors = %d, min_free_processors = %d",
 
2257
-            idle_processors(my_child_num),
 
2258
-            CHILD_INFO_TABLE[my_child_num].senv->min_free_processors);
 
2259
-
 
2260
-          if(total_processors(my_child_num) <
 
2261
-              CHILD_INFO_TABLE[my_child_num].senv->max_processors &&
 
2262
-            (idle_processors(my_child_num) <=
 
2263
-              CHILD_INFO_TABLE[my_child_num].senv->min_free_processors ||
 
2264
-             total_processors(my_child_num) <
 
2265
-              CHILD_INFO_TABLE[my_child_num].senv->min_processors
 
2266
-            ))
 
2267
-          {
 
2268
-              _DBG("CLONING CHILD");
 
2269
-              child_clone();
 
2270
-          }
 
2271
+            _DBG("total_processors = %d, max_processors = %d",
 
2272
+                    total_processors(my_child_num),
 
2273
+                    CHILD_INFO_TABLE[my_child_num].senv->max_processors);
 
2274
+
 
2275
+            _DBG("idle_processors = %d, min_free_processors = %d",
 
2276
+                    idle_processors(my_child_num),
 
2277
+                    CHILD_INFO_TABLE[my_child_num].senv->min_free_processors);
 
2278
+
 
2279
+            if (total_processors(my_child_num)
 
2280
+                < CHILD_INFO_TABLE[my_child_num].senv->max_processors
 
2281
+                && (idle_processors(my_child_num)
 
2282
+                <= CHILD_INFO_TABLE[my_child_num].senv->min_free_processors
 
2283
+                || total_processors(my_child_num)
 
2284
+                < CHILD_INFO_TABLE[my_child_num].senv->min_processors)) {
 
2285
+
 
2286
+                _DBG("CLONING CHILD");
 
2287
+                child_clone();
 
2288
+            }
 
2289
         }
 
2290
 
 
2291
-        if (!setjmp(CHILD_INFO_TABLE[my_child_num].jmpbuffer))
 
2292
-        {
 
2293
+        if (!setjmp(CHILD_INFO_TABLE[my_child_num].jmpbuffer)) {
 
2294
             _DBG("marked jmpbuffer",0);
 
2295
+
 
2296
+            CHILD_INFO_TABLE[my_child_num].senv->stats_connections++;
 
2297
+
 
2298
             _TRACE_CALL("process_socket()",0);
 
2299
+
 
2300
             process_socket(ptrans, sock, my_child_num, bucket_alloc, pchild);
 
2301
+
 
2302
             _TRACE_RET("process_socket()",0);
 
2303
         }
 
2304
-        else
 
2305
-        {
 
2306
+        else {
 
2307
             _DBG("landed from longjmp",0);
 
2308
             CHILD_INFO_TABLE[my_child_num].sock_fd = AP_PERUSER_THISCHILD;
 
2309
         }
 
2310
@@ -2055,17 +2128,17 @@
 
2311
             _DBG("ap_mpm_pod_check(pod) = APR_SUCCESS; dying now", 0);
 
2312
             die_now = 1;
 
2313
         }
 
2314
-        else if (ap_my_generation !=
 
2315
-                 ap_scoreboard_image->global->running_generation) { /* restart? */
 
2316
+        else if (ap_my_generation
 
2317
+                 != ap_scoreboard_image->global->running_generation) {
 
2318
             /* yeah, this could be non-graceful restart, in which case the
 
2319
              * parent will kill us soon enough, but why bother checking?
 
2320
              */
 
2321
-            _DBG("ap_my_generation != ap_scoreboard_image->global->running_generation; dying now", 0);
 
2322
+            _DBG("ap_my_generation !="
 
2323
+                 " ap_scoreboard_image->global->running_generation; dying now");
 
2324
             die_now = 1;
 
2325
         }
 
2326
 
 
2327
-        if(CHILD_INFO_TABLE[my_child_num].status == CHILD_STATUS_RESTART)
 
2328
-        {
 
2329
+        if (CHILD_INFO_TABLE[my_child_num].status == CHILD_STATUS_RESTART) {
 
2330
             _DBG("restarting", 0);
 
2331
             die_now = 1;
 
2332
         }
 
2333
@@ -2075,40 +2148,43 @@
 
2334
     clean_child_exit(0);
 
2335
 }
 
2336
 
 
2337
-static server_env_t* find_senv_by_name(const char *name) {
 
2338
+static server_env_t* find_senv_by_name(const char *name)
 
2339
+{
 
2340
     int i;
 
2341
 
 
2342
-    if (name == NULL) return NULL;
 
2343
+    if (name == NULL) {
 
2344
+        return NULL;
 
2345
+    }
 
2346
 
 
2347
     _DBG("name=%s", name);
 
2348
 
 
2349
-    for(i = 0; i < NUM_SENV; i++)
 
2350
-      {
 
2351
-          if(SENV[i].name != NULL && !strcmp(SENV[i].name, name)) {
 
2352
-              return &SENV[i];
 
2353
-          }
 
2354
-      }
 
2355
+    for (i = 0; i < NUM_SENV; i++) {
 
2356
+        if (SENV[i].name != NULL && !strcmp(SENV[i].name, name)) {
 
2357
+            return &SENV[i];
 
2358
+        }
 
2359
+    }
 
2360
 
 
2361
     return NULL;
 
2362
 }
 
2363
 
 
2364
-static server_env_t* find_matching_senv(server_env_t* senv) {
 
2365
+static server_env_t* find_matching_senv(server_env_t* senv)
 
2366
+{
 
2367
     int i;
 
2368
 
 
2369
-    _DBG("name=%s uid=%d gid=%d chroot=%s", senv->name, senv->uid, senv->gid, senv->chroot);
 
2370
+    _DBG("name=%s uid=%d gid=%d chroot=%s", senv->name, senv->uid, senv->gid,
 
2371
+         senv->chroot);
 
2372
 
 
2373
-    for(i = 0; i < NUM_SENV; i++)
 
2374
-      {
 
2375
-          if((senv->name != NULL && SENV[i].name != NULL && !strcmp(SENV[i].name, senv->name)) ||
 
2376
-             (senv->name == NULL && SENV[i].uid == senv->uid && SENV[i].gid == senv->gid &&
 
2377
-              (
 
2378
-               (SENV[i].chroot == NULL && senv->chroot == NULL) ||
 
2379
-               ((SENV[i].chroot != NULL || senv->chroot != NULL) && !strcmp(SENV[i].chroot, senv->chroot)))
 
2380
-              )
 
2381
-             ) {
 
2382
-              return &SENV[i];
 
2383
-          }
 
2384
-      }
 
2385
+    for (i = 0; i < NUM_SENV; i++) {
 
2386
+        if ((senv->name != NULL && SENV[i].name != NULL
 
2387
+             && !strcmp(SENV[i].name, senv->name))
 
2388
+            || (senv->name == NULL && SENV[i].uid == senv->uid
 
2389
+                && SENV[i].gid == senv->gid
 
2390
+                && ((SENV[i].chroot == NULL && senv->chroot == NULL)
 
2391
+                    || ((SENV[i].chroot != NULL || senv->chroot != NULL)
 
2392
+                    && !strcmp(SENV[i].chroot, senv->chroot))))) {
 
2393
+            return &SENV[i];
 
2394
+        }
 
2395
+    }
 
2396
 
 
2397
     return NULL;
 
2398
 }
 
2399
@@ -2124,15 +2200,16 @@
 
2400
 
 
2401
     if (old_senv) {
 
2402
         _DBG("Found existing senv");
 
2403
+
 
2404
         senv = old_senv;
 
2405
+
 
2406
         return old_senv;
 
2407
     }
 
2408
 
 
2409
-    if(NUM_SENV >= server_limit)
 
2410
-      {
 
2411
-          _DBG("server_limit reached!");
 
2412
-          return NULL;
 
2413
-      }
 
2414
+    if (NUM_SENV >= server_limit) {
 
2415
+        _DBG("server_limit reached!");
 
2416
+        return NULL;
 
2417
+    }
 
2418
 
 
2419
     _DBG("Creating new senv");
 
2420
 
 
2421
@@ -2141,32 +2218,31 @@
 
2422
     SENV[NUM_SENV].availability = 100;
 
2423
 
 
2424
     socketpair(PF_UNIX, SOCK_STREAM, 0, socks);
 
2425
-    SENV[NUM_SENV].input  = socks[0];
 
2426
+    SENV[NUM_SENV].input = socks[0];
 
2427
     SENV[NUM_SENV].output = socks[1];
 
2428
 
 
2429
     senv = &SENV[NUM_SENV];
 
2430
     return &SENV[server_env_image->control->num++];
 
2431
 }
 
2432
 
 
2433
-
 
2434
 static const char* child_clone()
 
2435
 {
 
2436
     int i;
 
2437
     child_info_t *this;
 
2438
     child_info_t *new;
 
2439
 
 
2440
-    for(i = 0; i < NUM_CHILDS; i++)
 
2441
-    {
 
2442
-      if(CHILD_INFO_TABLE[i].pid == 0 &&
 
2443
-         CHILD_INFO_TABLE[i].type == CHILD_TYPE_UNKNOWN) break;
 
2444
+    for (i = 0; i < NUM_CHILDS; i++) {
 
2445
+        if (CHILD_INFO_TABLE[i].pid == 0
 
2446
+            && CHILD_INFO_TABLE[i].type == CHILD_TYPE_UNKNOWN) {
 
2447
+            break;
 
2448
+        }
 
2449
     }
 
2450
-    
 
2451
-    if(i == NUM_CHILDS && NUM_CHILDS >= server_limit)
 
2452
-    {
 
2453
+
 
2454
+    if (i == NUM_CHILDS && NUM_CHILDS >= server_limit) {
 
2455
         _DBG("Trying to use more child ID's than ServerLimit.  "
 
2456
-               "Increase ServerLimit in your config file.");
 
2457
+                "Increase ServerLimit in your config file.");
 
2458
         return NULL;
 
2459
-    }    
 
2460
+    }
 
2461
 
 
2462
     _DBG("cloning child #%d from #%d", i, my_child_num);
 
2463
 
 
2464
@@ -2185,49 +2261,67 @@
 
2465
     new->sock_fd = this->sock_fd;
 
2466
     new->status = CHILD_STATUS_STARTING;
 
2467
 
 
2468
-    if(i == NUM_CHILDS) child_info_image->control->num++;
 
2469
+    if (i == NUM_CHILDS) {
 
2470
+        child_info_image->control->num++;
 
2471
+    }
 
2472
+
 
2473
     return NULL;
 
2474
 }
 
2475
 
 
2476
-static const char* child_add(int type, int status,
 
2477
-                             apr_pool_t *pool, server_env_t *senv)
 
2478
+static const char* child_add(int type, int status, apr_pool_t *pool,
 
2479
+                             server_env_t *senv)
 
2480
 {
 
2481
-    _DBG("adding child #%d", NUM_CHILDS);
 
2482
+    int i;
 
2483
 
 
2484
-    if(NUM_CHILDS >= server_limit)
 
2485
-    {
 
2486
+    for (i = 0; i < NUM_CHILDS; i++) {
 
2487
+        if (CHILD_INFO_TABLE[i].pid == 0
 
2488
+            && CHILD_INFO_TABLE[i].type == CHILD_TYPE_UNKNOWN) {
 
2489
+            break;
 
2490
+        }
 
2491
+    }
 
2492
+
 
2493
+    _DBG("adding child #%d", i);
 
2494
+
 
2495
+    if (i >= server_limit) {
 
2496
         return "Trying to use more child ID's than ServerLimit.  "
 
2497
-               "Increase ServerLimit in your config file.";
 
2498
+            "Increase ServerLimit in your config file.";
 
2499
     }
 
2500
 
 
2501
-       if (senv->chroot && !ap_is_directory(pool, senv->chroot))
 
2502
-               return apr_psprintf(pool, "Error: chroot directory [%s] does not exist", senv->chroot);
 
2503
+    if (senv->chroot && !ap_is_directory(pool, senv->chroot)) {
 
2504
+        return apr_psprintf(pool,
 
2505
+                            "Error: chroot directory [%s] does not exist",
 
2506
+                            senv->chroot);
 
2507
+    }
 
2508
 
 
2509
-    CHILD_INFO_TABLE[NUM_CHILDS].senv = senv_add(senv);
 
2510
+    CHILD_INFO_TABLE[i].senv = senv_add(senv);
 
2511
 
 
2512
-    if(CHILD_INFO_TABLE[NUM_CHILDS].senv == NULL)
 
2513
-    {
 
2514
+    if (CHILD_INFO_TABLE[i].senv == NULL) {
 
2515
         return "Trying to use more server environments than ServerLimit.  "
 
2516
-               "Increase ServerLimit in your config file.";
 
2517
+            "Increase ServerLimit in your config file.";
 
2518
+    }
 
2519
+
 
2520
+    if (type == CHILD_TYPE_MULTIPLEXER) {
 
2521
+        multiplexer_senv = CHILD_INFO_TABLE[i].senv;
 
2522
     }
 
2523
 
 
2524
-    if(type != CHILD_TYPE_WORKER)
 
2525
-        CHILD_INFO_TABLE[NUM_CHILDS].senv->processor_id = NUM_CHILDS;
 
2526
+    if (type != CHILD_TYPE_WORKER) {
 
2527
+        CHILD_INFO_TABLE[i].senv->processor_id = i;
 
2528
+    }
 
2529
 
 
2530
-    CHILD_INFO_TABLE[NUM_CHILDS].type = type;
 
2531
-    CHILD_INFO_TABLE[NUM_CHILDS].sock_fd = AP_PERUSER_THISCHILD;
 
2532
-    CHILD_INFO_TABLE[NUM_CHILDS].status = status;
 
2533
+    CHILD_INFO_TABLE[i].type = type;
 
2534
+    CHILD_INFO_TABLE[i].sock_fd = AP_PERUSER_THISCHILD;
 
2535
+    CHILD_INFO_TABLE[i].status = status;
 
2536
 
 
2537
-    _DBG("[%d] uid=%d gid=%d type=%d chroot=%s",
 
2538
-         NUM_CHILDS, senv->uid, senv->gid, type,
 
2539
-         senv->chroot);
 
2540
+    _DBG("[%d] uid=%d gid=%d type=%d chroot=%s", i, senv->uid,
 
2541
+         senv->gid, type, senv->chroot);
 
2542
 
 
2543
-    if (senv->uid == 0 || senv->gid == 0)
 
2544
-    {
 
2545
+    if (senv->uid == 0 || senv->gid == 0) {
 
2546
         _DBG("Assigning root user/group to a child.", 0);
 
2547
     }
 
2548
 
 
2549
-    child_info_image->control->num++;
 
2550
+    if (i >= NUM_CHILDS) {
 
2551
+        child_info_image->control->num = i + 1;
 
2552
+    }
 
2553
 
 
2554
     return NULL;
 
2555
 }
 
2556
@@ -2239,31 +2333,29 @@
 
2557
     _DBG("function entered", 0);
 
2558
     dump_server_env_image();
 
2559
 
 
2560
-    switch (CHILD_INFO_TABLE[slot].type)
 
2561
-    {
 
2562
-        case CHILD_TYPE_MULTIPLEXER: break;
 
2563
-        case CHILD_TYPE_PROCESSOR: break;
 
2564
-        case CHILD_TYPE_WORKER: break;
 
2565
-
 
2566
-        default:
 
2567
-            _DBG("no valid client in slot %d", slot);
 
2568
-            /* sleep(1); */
 
2569
-            return 0;
 
2570
-    }
 
2571
-
 
2572
-    if (slot + 1 > ap_max_daemons_limit) {
 
2573
-       ap_max_daemons_limit = slot + 1;
 
2574
+    switch (CHILD_INFO_TABLE[slot].type) {
 
2575
+    case CHILD_TYPE_MULTIPLEXER:
 
2576
+        break;
 
2577
+    case CHILD_TYPE_PROCESSOR:
 
2578
+        break;
 
2579
+    case CHILD_TYPE_WORKER:
 
2580
+        break;
 
2581
+
 
2582
+    default:
 
2583
+        _DBG("no valid client in slot %d", slot);
 
2584
+        /* sleep(1); */
 
2585
+        return 0;
 
2586
     }
 
2587
 
 
2588
     if (one_process) {
 
2589
-       apr_signal(SIGHUP, just_die);
 
2590
+        apr_signal(SIGHUP, just_die);
 
2591
         /* Don't catch AP_SIG_GRACEFUL in ONE_PROCESS mode :) */
 
2592
-       apr_signal(SIGINT, just_die);
 
2593
+        apr_signal(SIGINT, just_die);
 
2594
 #ifdef SIGQUIT
 
2595
-       apr_signal(SIGQUIT, SIG_DFL);
 
2596
+        apr_signal(SIGQUIT, SIG_DFL);
 
2597
 #endif
 
2598
-       apr_signal(SIGTERM, just_die);
 
2599
-       child_main(slot);
 
2600
+        apr_signal(SIGTERM, just_die);
 
2601
+        child_main(slot);
 
2602
     }
 
2603
 
 
2604
     (void) ap_update_child_status_from_indexes(slot, 0, SERVER_STARTING,
 
2605
@@ -2271,29 +2363,29 @@
 
2606
 
 
2607
     CHILD_INFO_TABLE[slot].status = CHILD_STATUS_READY;
 
2608
 
 
2609
-
 
2610
 #ifdef _OSD_POSIX
 
2611
     /* BS2000 requires a "special" version of fork() before a setuid() call */
 
2612
     if ((pid = os_fork(unixd_config.user_name)) == -1) {
 
2613
 #elif defined(TPF)
 
2614
-    if ((pid = os_fork(s, slot)) == -1) {
 
2615
+        if ((pid = os_fork(s, slot)) == -1) {
 
2616
 #else
 
2617
     if ((pid = fork()) == -1) {
 
2618
 #endif
 
2619
-       ap_log_error(APLOG_MARK, APLOG_ERR, errno, s, "fork: Unable to fork new process");
 
2620
+        ap_log_error(APLOG_MARK, APLOG_ERR, errno, s,
 
2621
+                     "fork: Unable to fork new process");
 
2622
 
 
2623
-       /* fork didn't succeed. Fix the scoreboard or else
 
2624
-        * it will say SERVER_STARTING forever and ever
 
2625
-        */
 
2626
-       (void) ap_update_child_status_from_indexes(slot, 0, SERVER_DEAD,
 
2627
+        /* fork didn't succeed. Fix the scoreboard or else
 
2628
+         * it will say SERVER_STARTING forever and ever
 
2629
+         */
 
2630
+        (void) ap_update_child_status_from_indexes(slot, 0, SERVER_DEAD,
 
2631
                                                    (request_rec *) NULL);
 
2632
 
 
2633
-       /* In case system resources are maxxed out, we don't want
 
2634
-          Apache running away with the CPU trying to fork over and
 
2635
-          over and over again. */
 
2636
-       sleep(10);
 
2637
+        /* In case system resources are maxxed out, we don't want
 
2638
+         Apache running away with the CPU trying to fork over and
 
2639
+         over and over again. */
 
2640
+        sleep(10);
 
2641
 
 
2642
-       return -1;
 
2643
+        return -1;
 
2644
     }
 
2645
 
 
2646
     if (!pid) {
 
2647
@@ -2301,38 +2393,33 @@
 
2648
         /* by default AIX binds to a single processor
 
2649
          * this bit unbinds children which will then bind to another cpu
 
2650
          */
 
2651
-       int status = bindprocessor(BINDPROCESS, (int)getpid(), 
 
2652
-                                  PROCESSOR_CLASS_ANY);
 
2653
-       if (status != OK) {
 
2654
-           ap_log_error(APLOG_MARK, APLOG_WARNING, errno, 
 
2655
-                         ap_server_conf, "processor unbind failed %d", status);
 
2656
-       }
 
2657
+        int status = bindprocessor(BINDPROCESS, (int)getpid(),
 
2658
+                PROCESSOR_CLASS_ANY);
 
2659
+        if (status != OK) {
 
2660
+            ap_log_error(APLOG_MARK, APLOG_WARNING, errno,
 
2661
+                    ap_server_conf, "processor unbind failed %d", status);
 
2662
+        }
 
2663
 #endif
 
2664
-       RAISE_SIGSTOP(MAKE_CHILD);
 
2665
-        AP_MONCONTROL(1);
 
2666
+        RAISE_SIGSTOP(MAKE_CHILD); AP_MONCONTROL(1);
 
2667
         /* Disable the parent's signal handlers and set up proper handling in
 
2668
          * the child.
 
2669
-        */
 
2670
-       apr_signal(SIGHUP, just_die);
 
2671
-       apr_signal(SIGTERM, just_die);
 
2672
+         */
 
2673
+        apr_signal(SIGHUP, just_die);
 
2674
+        apr_signal(SIGTERM, just_die);
 
2675
         /* The child process doesn't do anything for AP_SIG_GRACEFUL.  
 
2676
          * Instead, the pod is used for signalling graceful restart.
 
2677
          */
 
2678
         /* apr_signal(AP_SIG_GRACEFUL, restart); */
 
2679
-       child_main(slot);
 
2680
+        child_main(slot);
 
2681
         clean_child_exit(0);
 
2682
     }
 
2683
 
 
2684
     ap_scoreboard_image->parent[slot].pid = pid;
 
2685
-    CHILD_INFO_TABLE[slot].pid    = pid;
 
2686
-
 
2687
-    ap_child_table[slot].pid    = pid;
 
2688
-    ap_child_table[slot].status = SERVER_ALIVE;
 
2689
+    CHILD_INFO_TABLE[slot].pid = pid;
 
2690
 
 
2691
     return 0;
 
2692
 }
 
2693
 
 
2694
-
 
2695
 /*
 
2696
  * idle_spawn_rate is the number of children that will be spawned on the
 
2697
  * next maintenance cycle if there aren't enough idle servers.  It is
 
2698
@@ -2346,119 +2433,109 @@
 
2699
 static int total_processes(int child_num)
 
2700
 {
 
2701
     int i, total;
 
2702
-    for(i = 0, total = 0; i < NUM_CHILDS; ++i)
 
2703
-    {
 
2704
-        if(CHILD_INFO_TABLE[i].senv == CHILD_INFO_TABLE[child_num].senv &&
 
2705
-           (!(CHILD_INFO_TABLE[i].type == CHILD_TYPE_PROCESSOR &&
 
2706
-           CHILD_INFO_TABLE[i].status == CHILD_STATUS_STANDBY)))
 
2707
-        {
 
2708
-           total++;
 
2709
+
 
2710
+    for (i = 0, total = 0; i < NUM_CHILDS; ++i) {
 
2711
+        if (CHILD_INFO_TABLE[i].senv == CHILD_INFO_TABLE[child_num].senv
 
2712
+            && CHILD_INFO_TABLE[i].status != CHILD_STATUS_STANDBY) {
 
2713
+            total++;
 
2714
         }
 
2715
     }
 
2716
+
 
2717
     return total;
 
2718
 }
 
2719
 
 
2720
+static int determine_child_fate(int childnum, child_info_t *child,
 
2721
+                                worker_score *child_sb, apr_time_t now)
 
2722
+{
 
2723
+    time_t idle_time = apr_time_sec(now - child_sb->last_used);
 
2724
+
 
2725
+    if (total_processes(childnum) <= child->senv->min_processors) {
 
2726
+        /* We will not kill a child, if the senv needs live workers */
 
2727
+        return 0;
 
2728
+    }
 
2729
+
 
2730
+    if (child->type == CHILD_TYPE_PROCESSOR ||
 
2731
+        child->type == CHILD_TYPE_WORKER) {
 
2732
+
 
2733
+        if (idle_processors(childnum) <= child->senv->min_free_processors ||
 
2734
+            child->senv->min_free_processors == 0) {
 
2735
+            /* We will not kill a child, if the senv needs idle workers */
 
2736
+            return 0;
 
2737
+        }
 
2738
+
 
2739
+        if (expire_timeout > 0 && idle_time > expire_timeout) {
 
2740
+            /* Child has not handled a request for some time now, stop it */
 
2741
+            _DBG("Expire timeout reached for child #%d", childnum);
 
2742
+            return 1;
 
2743
+        }
 
2744
+
 
2745
+        if (idle_timeout > 0 && child_sb->status == SERVER_READY
 
2746
+            && idle_time > idle_timeout) {
 
2747
+            /* Child has been idle for too long, stop it */
 
2748
+            _DBG("Idle timeout reached for child #%d", childnum);
 
2749
+            return 1;
 
2750
+        }
 
2751
+
 
2752
+        if (child->senv->max_free_processors > 0
 
2753
+            && idle_processors(childnum) >= child->senv->max_free_processors) {
 
2754
+            /* Too many spare workers available */
 
2755
+            _DBG("Too many spare workers for processor %s, stopping child #%d",
 
2756
+                 child->senv->name, childnum);
 
2757
+            return 1;
 
2758
+        }
 
2759
+    } else if (child->type == CHILD_TYPE_MULTIPLEXER) {
 
2760
+        if (multiplexer_idle_timeout > 0 && child_sb->status == SERVER_READY
 
2761
+            && idle_time > multiplexer_idle_timeout) {
 
2762
+            /* Multiplexer has been idle for too long, stop it */
 
2763
+            _DBG("Stopping idle multiplexer #%d", childnum);
 
2764
+            return 1;
 
2765
+        }
 
2766
+    }
 
2767
+
 
2768
+    return 0;
 
2769
+}
 
2770
+
 
2771
 static void perform_idle_server_maintenance(apr_pool_t *p)
 
2772
 {
 
2773
-    int i;
 
2774
+    int i, stop_child;
 
2775
+    time_t idle_time;
 
2776
+    child_info_t *child;
 
2777
+    worker_score *child_sb;
 
2778
     apr_time_t now;
 
2779
 
 
2780
-    /* _DBG("function entered", 0); */
 
2781
-
 
2782
     now = apr_time_now();
 
2783
 
 
2784
-    for (i = 0; i < NUM_CHILDS; ++i)
 
2785
-    {
 
2786
-      if(CHILD_INFO_TABLE[i].pid == 0)
 
2787
-      {
 
2788
-        if(CHILD_INFO_TABLE[i].status == CHILD_STATUS_STARTING)
 
2789
-          make_child(ap_server_conf, i);
 
2790
-      }
 
2791
-      else if(
 
2792
-             (((CHILD_INFO_TABLE[i].type == CHILD_TYPE_PROCESSOR ||
 
2793
-                 CHILD_INFO_TABLE[i].type == CHILD_TYPE_WORKER)  &&
 
2794
-                ap_scoreboard_image->parent[i].pid > 1) &&
 
2795
-               (idle_processors (i) > CHILD_INFO_TABLE[i].senv->min_free_processors || CHILD_INFO_TABLE[i].senv->min_free_processors == 0) &&
 
2796
-               total_processes (i) > CHILD_INFO_TABLE[i].senv->min_processors && 
 
2797
-               (
 
2798
-                (expire_timeout > 0 &&  ap_scoreboard_image->servers[i][0].status != SERVER_DEAD && 
 
2799
-                 apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > expire_timeout) ||
 
2800
-                (idle_timeout >   0 &&  ap_scoreboard_image->servers[i][0].status == SERVER_READY &&  
 
2801
-                 apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > idle_timeout) ||
 
2802
-                (CHILD_INFO_TABLE[i].senv->max_free_processors > 0 && CHILD_INFO_TABLE[i].status == CHILD_STATUS_READY &&
 
2803
-                 idle_processors(i) > CHILD_INFO_TABLE[i].senv->max_free_processors))
 
2804
-               )
 
2805
-              || (CHILD_INFO_TABLE[i].type == CHILD_TYPE_MULTIPLEXER &&
 
2806
-                  (multiplexer_idle_timeout > 0 && ap_scoreboard_image->servers[i][0].status == SERVER_READY &&
 
2807
-                   apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > multiplexer_idle_timeout) &&
 
2808
-                  total_processors(i) > CHILD_INFO_TABLE[i].senv->min_processors
 
2809
-                  )
 
2810
-            )
 
2811
-      {
 
2812
-        CHILD_INFO_TABLE[i].pid = 0;
 
2813
-        CHILD_INFO_TABLE[i].status = CHILD_STATUS_STANDBY;
 
2814
+    for (i = 0; i < NUM_CHILDS; ++i) {
 
2815
+        child = &CHILD_INFO_TABLE[i];
 
2816
+        child_sb = &ap_scoreboard_image->servers[i][0];
 
2817
 
 
2818
-        if(CHILD_INFO_TABLE[i].type == CHILD_TYPE_WORKER || CHILD_INFO_TABLE[i].type == CHILD_TYPE_MULTIPLEXER)
 
2819
-        {
 
2820
-          /* completely free up this slot */
 
2821
+        if (child->status == CHILD_STATUS_STANDBY) {
 
2822
+            continue;
 
2823
+        }
 
2824
+
 
2825
+        if (child->pid == 0) {
 
2826
+            if (child->status == CHILD_STATUS_STARTING) {
 
2827
+                make_child(ap_server_conf, i);
 
2828
+            }
 
2829
 
 
2830
-          CHILD_INFO_TABLE[i].senv    = (server_env_t*)NULL;
 
2831
-          CHILD_INFO_TABLE[i].type    = CHILD_TYPE_UNKNOWN;
 
2832
-          CHILD_INFO_TABLE[i].sock_fd = -3; /* -1 and -2 are taken */
 
2833
+            continue;
 
2834
         }
 
2835
-        if(kill(ap_scoreboard_image->parent[i].pid, SIGTERM) == -1)
 
2836
-        {
 
2837
-          ap_log_error(APLOG_MARK, APLOG_WARNING, errno,
 
2838
-            ap_server_conf, "kill SIGTERM");
 
2839
+
 
2840
+        if (ap_scoreboard_image->parent[i].pid == 0) {
 
2841
+            continue;
 
2842
         }
 
2843
-       
 
2844
 
 
2845
-        ap_update_child_status_from_indexes(i, 0, SERVER_DEAD, NULL);
 
2846
-      }
 
2847
-    }
 
2848
-    
 
2849
-    for(i=0;i<grace_children;i++) {
 
2850
-       if (child_grace_info_table[i].pid > 0 && expire_timeout > 0 &&
 
2851
-                       apr_time_sec(now - child_grace_info_table[i].last_used) > expire_timeout) {
 
2852
-               
 
2853
-               _DBG("Killing a child from last graceful (pid=%d,childno=%d,last_used=%d)", 
 
2854
-                               child_grace_info_table[i].pid, child_grace_info_table[i].id,
 
2855
-                               child_grace_info_table[i].last_used);
 
2856
-            
 
2857
-               if(kill(child_grace_info_table[i].pid, SIGTERM) == -1)
 
2858
-            {
 
2859
-              ap_log_error(APLOG_MARK, APLOG_WARNING, errno,
 
2860
-                ap_server_conf, "kill SIGTERM");
 
2861
+        if (determine_child_fate(i, child, child_sb, now) == 1) {
 
2862
+            child->status = CHILD_STATUS_STANDBY;
 
2863
+
 
2864
+            if (kill(ap_scoreboard_image->parent[i].pid, SIGTERM) == -1) {
 
2865
+                ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
2866
+                             "kill SIGTERM");
 
2867
             }
 
2868
-               
 
2869
-               /*      We don't need to do remove_grace_child() here,
 
2870
-                *  because it will be automatically done once 
 
2871
-                *  the child dies by ap_mpm_run() */
 
2872
-       }
 
2873
+        }
 
2874
     }
 
2875
 }
 
2876
 
 
2877
-int remove_grace_child(int slot) {
 
2878
-       if (slot < grace_children) {
 
2879
-               child_grace_info_table[slot].id = 0;
 
2880
-               child_grace_info_table[slot].pid = 0;
 
2881
-               child_grace_info_table[slot].status = CHILD_STATUS_STANDBY;
 
2882
-               child_grace_info_table[slot].type = CHILD_TYPE_UNKNOWN;
 
2883
-               child_grace_info_table[slot].last_used = 0;
 
2884
-               grace_children_alive--;
 
2885
-               
 
2886
-               if (grace_children_alive <= 0) { /*     All children have returned from graceful        */
 
2887
-                       _DBG("Every child has returned from graceful restart - freeing child_grace_info_table");
 
2888
-                       grace_children_alive = 0;
 
2889
-                       is_graceful = 0;
 
2890
-                       grace_children = 0;
 
2891
-                       free(child_grace_info_table);
 
2892
-               }
 
2893
-               return 0;
 
2894
-       }
 
2895
-       return 1;
 
2896
-}
 
2897
-
 
2898
 /*****************************************************************
 
2899
  * Executive routines.
 
2900
  */
 
2901
@@ -2466,10 +2543,11 @@
 
2902
 int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
 
2903
 {
 
2904
     int i;
 
2905
-/*    int fd; */
 
2906
+    /*    int fd; */
 
2907
     apr_status_t rv;
 
2908
     apr_size_t one = 1;
 
2909
-/*    apr_socket_t *sock = NULL; */
 
2910
+    unsigned char status;
 
2911
+    /*    apr_socket_t *sock = NULL; */
 
2912
 
 
2913
     ap_log_pid(pconf, ap_pid_fname);
 
2914
 
 
2915
@@ -2488,7 +2566,7 @@
 
2916
                                  ap_server_root_relative(_pconf, ap_lock_fname),
 
2917
                                  ap_my_pid);
 
2918
 
 
2919
-    rv = apr_proc_mutex_create(&accept_mutex, ap_lock_fname, 
 
2920
+    rv = apr_proc_mutex_create(&accept_mutex, ap_lock_fname,
 
2921
                                ap_accept_lock_mech, _pconf);
 
2922
     if (rv != APR_SUCCESS) {
 
2923
         ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
 
2924
@@ -2498,8 +2576,8 @@
 
2925
     }
 
2926
 
 
2927
 #if APR_USE_SYSVSEM_SERIALIZE
 
2928
-    if (ap_accept_lock_mech == APR_LOCK_DEFAULT || 
 
2929
-        ap_accept_lock_mech == APR_LOCK_SYSVSEM) {
 
2930
+    if (ap_accept_lock_mech == APR_LOCK_DEFAULT ||
 
2931
+            ap_accept_lock_mech == APR_LOCK_SYSVSEM) {
 
2932
 #else
 
2933
     if (ap_accept_lock_mech == APR_LOCK_SYSVSEM) {
 
2934
 #endif
 
2935
@@ -2507,7 +2585,7 @@
 
2936
         if (rv != APR_SUCCESS) {
 
2937
             ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
 
2938
                          "Couldn't set permissions on cross-process lock; "
 
2939
-                         "check User and Group directives");
 
2940
+                             "check User and Group directives");
 
2941
             mpm_state = AP_MPMQ_STOPPING;
 
2942
             return 1;
 
2943
         }
 
2944
@@ -2524,15 +2602,6 @@
 
2945
         ap_scoreboard_image->global->running_generation = ap_my_generation;
 
2946
     }
 
2947
 
 
2948
-    /* Initialize the child table */
 
2949
-    if (!is_graceful)
 
2950
-    {
 
2951
-        for (i = 0; i < server_limit; i++)
 
2952
-        {
 
2953
-            ap_child_table[i].pid = 0;
 
2954
-        }
 
2955
-    }
 
2956
-
 
2957
     /* We need to put the new listeners at the end of the ap_listeners
 
2958
      * list.  If we don't, then the pool will be cleared before the
 
2959
      * open_logs phase is called for the second time, and ap_listeners
 
2960
@@ -2541,12 +2610,12 @@
 
2961
      * won't start.
 
2962
      */
 
2963
 
 
2964
-/*
 
2965
-    apr_os_file_get(&fd, pipe_of_death_in);
 
2966
-    apr_os_sock_put(&sock, &fd, pconf);
 
2967
+    /*
 
2968
+     apr_os_file_get(&fd, pipe_of_death_in);
 
2969
+     apr_os_sock_put(&sock, &fd, pconf);
 
2970
 
 
2971
-    listen_add(pconf, sock, check_pipe_of_death);
 
2972
-*/
 
2973
+     listen_add(pconf, sock, check_pipe_of_death);
 
2974
+     */
 
2975
     set_signals();
 
2976
 
 
2977
     if (one_process) {
 
2978
@@ -2554,15 +2623,15 @@
 
2979
     }
 
2980
 
 
2981
     ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
 
2982
-               "%s configured -- resuming normal operations",
 
2983
-               ap_get_server_version());
 
2984
-    ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
 
2985
-               "Server built: %s", ap_get_server_built());
 
2986
+                 "%s configured -- resuming normal operations",
 
2987
+                 ap_get_server_version());
 
2988
+    ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf, "Server built: %s",
 
2989
+                 ap_get_server_built());
 
2990
 #ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
 
2991
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
 
2992
-               "AcceptMutex: %s (default: %s)",
 
2993
-               apr_proc_mutex_name(accept_mutex),
 
2994
-               apr_proc_mutex_defname());
 
2995
+            "AcceptMutex: %s (default: %s)",
 
2996
+            apr_proc_mutex_name(accept_mutex),
 
2997
+            apr_proc_mutex_defname());
 
2998
 #endif
 
2999
     restart_pending = shutdown_pending = 0;
 
3000
 
 
3001
@@ -2571,105 +2640,113 @@
 
3002
     _DBG("sizeof(child_info_t) = %d", sizeof(child_info_t));
 
3003
 
 
3004
     while (!restart_pending && !shutdown_pending) {
 
3005
-       int child_slot;
 
3006
+        int child_slot = -1;
 
3007
         apr_exit_why_e exitwhy;
 
3008
-       int status, processed_status;
 
3009
+        int status, processed_status;
 
3010
         /* this is a memory leak, but I'll fix it later. */
 
3011
-       apr_proc_t pid;
 
3012
+        apr_proc_t pid;
 
3013
 
 
3014
         ap_wait_or_timeout(&exitwhy, &status, &pid, pconf);
 
3015
 
 
3016
-       /* XXX: if it takes longer than 1 second for all our children
 
3017
-        * to start up and get into IDLE state then we may spawn an
 
3018
-        * extra child
 
3019
-        */
 
3020
-       if (pid.pid != -1) {
 
3021
+        /* XXX: if it takes longer than 1 second for all our children
 
3022
+         * to start up and get into IDLE state then we may spawn an
 
3023
+         * extra child
 
3024
+         */
 
3025
+        if (pid.pid != -1) {
 
3026
             processed_status = ap_process_child_status(&pid, exitwhy, status);
 
3027
             if (processed_status == APEXIT_CHILDFATAL) {
 
3028
                 mpm_state = AP_MPMQ_STOPPING;
 
3029
                 return 1;
 
3030
             }
 
3031
-            
 
3032
-            if (grace_children > 0) {
 
3033
-               for(i=0;i<grace_children;i++) {
 
3034
-                       if (child_grace_info_table[i].pid == pid.pid) {
 
3035
-                               break;
 
3036
-                       }
 
3037
-               }
 
3038
-               if (i != grace_children) {
 
3039
-                       _DBG("Child returned from graceful (%d)", i);
 
3040
-                       remove_grace_child(i);
 
3041
-                       continue;
 
3042
-               }
 
3043
-            }
 
3044
 
 
3045
             /* non-fatal death... note that it's gone in the scoreboard. */
 
3046
-            child_slot = find_child_by_pid(&pid);
 
3047
-            _DBG("child #%d has died ...", child_slot);
 
3048
-
 
3049
-            for (i = 0; i < ap_max_daemons_limit; ++i)
 
3050
-            {
 
3051
-                if (ap_child_table[i].pid == pid.pid)
 
3052
-                {
 
3053
+            for (i = 0; i < NUM_CHILDS; ++i) {
 
3054
+                if (CHILD_INFO_TABLE[i].pid == pid.pid) {
 
3055
                     child_slot = i;
 
3056
                     break;
 
3057
                 }
 
3058
             }
 
3059
 
 
3060
-           if (child_slot >= 0) {
 
3061
-                ap_child_table[child_slot].pid = 0;
 
3062
+            _DBG("child #%d (pid=%d) has died", child_slot, pid.pid);
 
3063
+
 
3064
+            if (child_slot >= 0) {
 
3065
+                CHILD_INFO_TABLE[child_slot].pid = 0;
 
3066
+
 
3067
+                status = ap_scoreboard_image->servers[child_slot][0].status;
 
3068
+
 
3069
                 _TRACE_CALL("ap_update_child_status_from_indexes", 0);
 
3070
-               (void) ap_update_child_status_from_indexes(child_slot, 0, SERVER_DEAD,
 
3071
-                                                           (request_rec *) NULL);
 
3072
+
 
3073
+                (void)ap_update_child_status_from_indexes(child_slot, 0,
 
3074
+                                                          SERVER_DEAD,
 
3075
+                                                          (request_rec *)NULL);
 
3076
+
 
3077
                 _TRACE_RET("ap_update_child_status_from_indexes", 0);
 
3078
 
 
3079
                 if (processed_status == APEXIT_CHILDSICK) {
 
3080
-                    /* child detected a resource shortage (E[NM]FILE, ENOBUFS, etc)
 
3081
+                    /* child detected a resource shortage (E[NM]FILE, ENOBUFS,
 
3082
+                     * etc)
 
3083
                      * cut the fork rate to the minimum 
 
3084
                      */
 
3085
                     _DBG("processed_status = APEXIT_CHILDSICK", 0);
 
3086
-                    idle_spawn_rate = 1; 
 
3087
+                    idle_spawn_rate = 1;
 
3088
                 }
 
3089
-                else if (CHILD_INFO_TABLE[child_slot].status == CHILD_STATUS_STANDBY) {
 
3090
+                else if (status == SERVER_GRACEFUL) {
 
3091
+                    _DBG("cleaning child from last generation");
 
3092
+                    memset(&CHILD_INFO_TABLE[child_slot], 0, sizeof(child_info_t));
 
3093
+                    CHILD_INFO_TABLE[child_slot].id = child_slot;
 
3094
+                }
 
3095
+                else if (CHILD_INFO_TABLE[child_slot].status
 
3096
+                        == CHILD_STATUS_STANDBY)
 
3097
+                {
 
3098
                     _DBG("leaving child in standby state", 0);
 
3099
+
 
3100
+                    if (CHILD_INFO_TABLE[child_slot].type == CHILD_TYPE_WORKER
 
3101
+                        || CHILD_INFO_TABLE[child_slot].type == CHILD_TYPE_MULTIPLEXER) {
 
3102
+                        /* completely free up this slot */
 
3103
+                        CHILD_INFO_TABLE[child_slot].senv = (server_env_t*) NULL;
 
3104
+                        CHILD_INFO_TABLE[child_slot].type = CHILD_TYPE_UNKNOWN;
 
3105
+                        CHILD_INFO_TABLE[child_slot].sock_fd = -3; /* -1 and -2 are taken */
 
3106
+                    }
 
3107
                 }
 
3108
-                else if (child_slot < ap_daemons_limit &&
 
3109
-                         CHILD_INFO_TABLE[child_slot].type !=
 
3110
-                           CHILD_TYPE_UNKNOWN) {
 
3111
-                   /* we're still doing a 1-for-1 replacement of dead
 
3112
-                       * children with new children
 
3113
-                       */
 
3114
+                else if (child_slot < ap_daemons_limit
 
3115
+                        && CHILD_INFO_TABLE[child_slot].type
 
3116
+                                != CHILD_TYPE_UNKNOWN)
 
3117
+                {
 
3118
+                    /* we're still doing a 1-for-1 replacement of dead
 
3119
+                     * children with new children
 
3120
+                     */
 
3121
                     _DBG("replacing by new child ...", 0);
 
3122
-                   make_child(ap_server_conf, child_slot);
 
3123
-               }
 
3124
+                    make_child(ap_server_conf, child_slot);
 
3125
+                }
 
3126
 #if APR_HAS_OTHER_CHILD
 
3127
-           }
 
3128
-           else if (apr_proc_other_child_alert(&pid, APR_OC_REASON_DEATH, status) == APR_SUCCESS) {
 
3129
+            }
 
3130
+            else if (apr_proc_other_child_alert(&pid, APR_OC_REASON_DEATH,
 
3131
+                                                status) == APR_SUCCESS) {
 
3132
                 _DBG("Already handled", 0);
 
3133
-               /* handled */
 
3134
+                /* handled */
 
3135
 #endif
 
3136
-           }
 
3137
-           else if (is_graceful) {
 
3138
-               /* Great, we've probably just lost a slot in the
 
3139
-                   * scoreboard.  Somehow we don't know about this
 
3140
-                   * child.
 
3141
-                   */
 
3142
+            }
 
3143
+            else if (is_graceful) {
 
3144
+                /* Great, we've probably just lost a slot in the
 
3145
+                 * scoreboard.  Somehow we don't know about this
 
3146
+                 * child.
 
3147
+                 */
 
3148
                 _DBG("long lost child came home, whatever that means", 0);
 
3149
 
 
3150
-               ap_log_error(APLOG_MARK, APLOG_WARNING, 
 
3151
-                            0, ap_server_conf,
 
3152
-                           "long lost child came home! (pid %ld)", (long)pid.pid);
 
3153
-           }
 
3154
-           /* Don't perform idle maintenance when a child dies,
 
3155
-               * only do it when there's a timeout.  Remember only a
 
3156
-               * finite number of children can die, and it's pretty
 
3157
-               * pathological for a lot to die suddenly.
 
3158
-               */
 
3159
-           continue;
 
3160
-       }
 
3161
+                ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf,
 
3162
+                             "long lost child came home! (pid %ld)",
 
3163
+                             (long) pid.pid);
 
3164
+            }
 
3165
+            /* Don't perform idle maintenance when a child dies,
 
3166
+             * only do it when there's a timeout.  Remember only a
 
3167
+             * finite number of children can die, and it's pretty
 
3168
+             * pathological for a lot to die suddenly.
 
3169
+             */
 
3170
+            continue;
 
3171
+        }
 
3172
+
 
3173
+        perform_idle_server_maintenance(pconf);
 
3174
 
 
3175
-       perform_idle_server_maintenance(pconf);
 
3176
-       
 
3177
 #ifdef TPF
 
3178
         shutdown_pending = os_check_server(tpf_server_name);
 
3179
         ap_check_signals();
 
3180
@@ -2680,35 +2757,35 @@
 
3181
     mpm_state = AP_MPMQ_STOPPING;
 
3182
 
 
3183
     if (shutdown_pending) {
 
3184
-       /* Time to gracefully shut down:
 
3185
-        * Kill child processes, tell them to call child_exit, etc...
 
3186
-        */
 
3187
-       if (unixd_killpg(getpgrp(), SIGTERM) < 0) {
 
3188
-           ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "killpg SIGTERM");
 
3189
-       }
 
3190
-       ap_reclaim_child_processes(1);          /* Start with SIGTERM */
 
3191
-
 
3192
-       /* cleanup pid file on normal shutdown */
 
3193
-       {
 
3194
-           const char *pidfile = NULL;
 
3195
-           pidfile = ap_server_root_relative (pconf, ap_pid_fname);
 
3196
-           if ( pidfile != NULL && unlink(pidfile) == 0)
 
3197
-               ap_log_error(APLOG_MARK, APLOG_INFO,
 
3198
-                               0, ap_server_conf,
 
3199
-                               "removed PID file %s (pid=%ld)",
 
3200
-                               pidfile, (long)getpid());
 
3201
-       }
 
3202
-
 
3203
-       ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
 
3204
-                   "caught SIGTERM, shutting down");
 
3205
-       return 1;
 
3206
+        /* Time to gracefully shut down:
 
3207
+         * Kill child processes, tell them to call child_exit, etc...
 
3208
+         */
 
3209
+        if (unixd_killpg(getpgrp(), SIGTERM) < 0) {
 
3210
+            ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
3211
+                         "killpg SIGTERM");
 
3212
+        }
 
3213
+        ap_reclaim_child_processes(1); /* Start with SIGTERM */
 
3214
+
 
3215
+        /* cleanup pid file on normal shutdown */
 
3216
+        {
 
3217
+            const char *pidfile = NULL;
 
3218
+            pidfile = ap_server_root_relative(pconf, ap_pid_fname);
 
3219
+            if (pidfile != NULL && unlink(pidfile) == 0)
 
3220
+                ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
 
3221
+                             "removed PID file %s (pid=%ld)", pidfile,
 
3222
+                             (long) getpid());
 
3223
+        }
 
3224
+
 
3225
+        ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
 
3226
+                     "caught SIGTERM, shutting down");
 
3227
+        return 1;
 
3228
     }
 
3229
 
 
3230
     /* we've been told to restart */
 
3231
     apr_signal(SIGHUP, SIG_IGN);
 
3232
     if (one_process) {
 
3233
-       /* not worth thinking about */
 
3234
-       return 1;
 
3235
+        /* not worth thinking about */
 
3236
+        return 1;
 
3237
     }
 
3238
 
 
3239
     /* advance to the next generation */
 
3240
@@ -2717,7 +2794,7 @@
 
3241
      */
 
3242
     ++ap_my_generation;
 
3243
     ap_scoreboard_image->global->running_generation = ap_my_generation;
 
3244
-    
 
3245
+
 
3246
     /* cleanup sockets */
 
3247
     for (i = 0; i < NUM_SENV; i++) {
 
3248
         close(SENV[i].input);
 
3249
@@ -2727,100 +2804,45 @@
 
3250
     if (is_graceful) {
 
3251
         char char_of_death = AP_PERUSER_CHAR_OF_DEATH;
 
3252
 
 
3253
-       ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
 
3254
-                   "Graceful restart requested, doing restart");
 
3255
-
 
3256
-#if 0
 
3257
-       /* kill off the idle ones */
 
3258
-        ap_mpm_pod_killpg(pod, ap_max_daemons_limit);
 
3259
-
 
3260
-       /* This is mostly for debugging... so that we know what is still
 
3261
-           * gracefully dealing with existing request.  This will break
 
3262
-           * in a very nasty way if we ever have the scoreboard totally
 
3263
-           * file-based (no shared memory)
 
3264
-           */
 
3265
-       for (i = 0; i < ap_daemons_limit; ++i) {
 
3266
-           if (ap_scoreboard_image->servers[i][0].status != SERVER_DEAD) {
 
3267
-               ap_scoreboard_image->servers[i][0].status = SERVER_GRACEFUL;
 
3268
-           }
 
3269
-       }
 
3270
-#endif
 
3271
-
 
3272
-        ap_log_error(APLOG_MARK, APLOG_NOTICE, 0,
 
3273
-                     ap_server_conf, AP_SIG_GRACEFUL_STRING " received.  "
 
3274
-                     "Doing graceful restart");
 
3275
+        ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
 
3276
+                     "Graceful restart requested, doing restart");
 
3277
 
 
3278
         /* This is mostly for debugging... so that we know what is still
 
3279
-         * gracefully dealing with existing request.
 
3280
+         * gracefully dealing with existing request.  This will break
 
3281
+         * in a very nasty way if we ever have the scoreboard totally
 
3282
+         * file-based (no shared memory)
 
3283
          */
 
3284
-
 
3285
-        int alivechildren = 0;
 
3286
-        child_grace_info_t* old_grace_info;
 
3287
-
 
3288
-        for (i = 0; i < NUM_CHILDS; ++i)
 
3289
-        {
 
3290
-            ((ap_child_table[i].pid) && (ap_child_table[i].status = SERVER_DYING));
 
3291
-            
 
3292
-            if (CHILD_INFO_TABLE[i].pid) {
 
3293
-               alivechildren++;
 
3294
-            }
 
3295
-        }
 
3296
-        
 
3297
-        _DBG("Initializing child_grace_info_table", 0);
 
3298
-        
 
3299
-        if (alivechildren > 0) {
 
3300
-               if (grace_children > 0) {
 
3301
-                       old_grace_info = child_grace_info_table;
 
3302
-                       _DBG("%d children still living from last graceful "
 
3303
-                                       "- adding to new child_grace_info_table", 
 
3304
-                                       grace_children);
 
3305
-               }
 
3306
-               
 
3307
-               child_grace_info_table = (child_grace_info_t*)calloc(alivechildren+grace_children,
 
3308
-                               sizeof(child_grace_info_t));
 
3309
-               
 
3310
-               if (grace_children > 0) {
 
3311
-                       for(i=0;i<grace_children;i++) {
 
3312
-                               child_grace_info_table[i] = old_grace_info[i];
 
3313
-                       }
 
3314
-                       grace_children = i;
 
3315
-                       free(old_grace_info);
 
3316
-               }
 
3317
-               else grace_children = 0;
 
3318
-               
 
3319
+        for (i = 0; i < ap_daemons_limit; ++i) {
 
3320
+            if (ap_scoreboard_image->servers[i][0].status != SERVER_DEAD) {
 
3321
+                ap_scoreboard_image->servers[i][0].status = SERVER_GRACEFUL;
 
3322
+            }
 
3323
         }
 
3324
 
 
3325
+        ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
 
3326
+                     AP_SIG_GRACEFUL_STRING " received.  "
 
3327
+                     "Doing graceful restart");
 
3328
+
 
3329
         /* give the children the signal to die */
 
3330
-        for (i = 0; i < NUM_CHILDS;)
 
3331
-        {
 
3332
-            if ((rv = apr_file_write(pipe_of_death_out, &char_of_death, &one)) != APR_SUCCESS)
 
3333
-            {
 
3334
-                if (APR_STATUS_IS_EINTR(rv)) continue;
 
3335
+        for (i = 0; i < NUM_CHILDS;i++) {
 
3336
+            if ((rv = apr_file_write(pipe_of_death_out, &char_of_death, &one))
 
3337
+                    != APR_SUCCESS) {
 
3338
+                if (APR_STATUS_IS_EINTR(rv)) {
 
3339
+                    continue;
 
3340
+                }
 
3341
                 ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf,
 
3342
                              "write pipe_of_death");
 
3343
             }
 
3344
-            if (CHILD_INFO_TABLE[i].pid) {
 
3345
-               child_grace_info_table[grace_children].id               = CHILD_INFO_TABLE[i].id;
 
3346
-               child_grace_info_table[grace_children].pid              = CHILD_INFO_TABLE[i].pid;
 
3347
-               child_grace_info_table[grace_children].status   = CHILD_INFO_TABLE[i].status;
 
3348
-               child_grace_info_table[grace_children].type     = CHILD_INFO_TABLE[i].type;
 
3349
-               child_grace_info_table[grace_children].last_used= ap_scoreboard_image->servers[i][0].last_used;
 
3350
-               grace_children++;
 
3351
-               grace_children_alive++;
 
3352
-            }
 
3353
-            i++;
 
3354
         }
 
3355
-        _DBG("Total children of %d leaving behind for graceful restart (%d living)", 
 
3356
-                       grace_children, grace_children_alive);
 
3357
     }
 
3358
     else {
 
3359
-       /* Kill 'em off */
 
3360
-       if (unixd_killpg(getpgrp(), SIGHUP) < 0) {
 
3361
-           ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "killpg SIGHUP");
 
3362
-       }
 
3363
-       ap_reclaim_child_processes(0);          /* Not when just starting up */
 
3364
-       ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
 
3365
-                   "SIGHUP received.  Attempting to restart");
 
3366
+        /* Kill 'em off */
 
3367
+        if (unixd_killpg(getpgrp(), SIGHUP) < 0) {
 
3368
+            ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
3369
+                         "killpg SIGHUP");
 
3370
+        }
 
3371
+        ap_reclaim_child_processes(0); /* Not when just starting up */
 
3372
+        ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
 
3373
+                     "SIGHUP received.  Attempting to restart");
 
3374
     }
 
3375
 
 
3376
     return 0;
 
3377
@@ -2829,8 +2851,8 @@
 
3378
 /* == allocate an private server config structure == */
 
3379
 static void *peruser_create_config(apr_pool_t *p, server_rec *s)
 
3380
 {
 
3381
-    peruser_server_conf *c = (peruser_server_conf *)
 
3382
-                                  apr_pcalloc(p, sizeof(peruser_server_conf));
 
3383
+    peruser_server_conf *c =
 
3384
+            (peruser_server_conf *) apr_pcalloc(p, sizeof(peruser_server_conf));
 
3385
 
 
3386
     c->senv = NULL;
 
3387
     c->missing_senv_reported = 0;
 
3388
@@ -2841,7 +2863,8 @@
 
3389
 /* This really should be a post_config hook, but the error log is already
 
3390
  * redirected by that point, so we need to do this in the open_logs phase.
 
3391
  */
 
3392
-static int peruser_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
 
3393
+static int peruser_open_logs(apr_pool_t *p, apr_pool_t *plog,
 
3394
+        apr_pool_t *ptemp, server_rec *s)
 
3395
 {
 
3396
     apr_status_t rv;
 
3397
 
 
3398
@@ -2849,26 +2872,28 @@
 
3399
     ap_server_conf = s;
 
3400
 
 
3401
     if ((num_listensocks = ap_setup_listeners(ap_server_conf)) < 1) {
 
3402
-        ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_STARTUP, 0, 
 
3403
-                     NULL, "no listening sockets available, shutting down");
 
3404
-       return DONE;
 
3405
+        ap_log_error(APLOG_MARK, APLOG_ALERT | APLOG_STARTUP, 0, NULL,
 
3406
+                     "no listening sockets available, shutting down");
 
3407
+        return DONE;
 
3408
     }
 
3409
 
 
3410
     ap_log_pid(pconf, ap_pid_fname);
 
3411
 
 
3412
     if ((rv = ap_mpm_pod_open(pconf, &pod))) {
 
3413
-        ap_log_error(APLOG_MARK, APLOG_CRIT|APLOG_STARTUP, rv, NULL,
 
3414
-               "Could not open pipe-of-death.");
 
3415
+        ap_log_error(APLOG_MARK, APLOG_CRIT | APLOG_STARTUP, rv, NULL,
 
3416
+                     "Could not open pipe-of-death.");
 
3417
         return DONE;
 
3418
     }
 
3419
 
 
3420
-    if ((rv = apr_file_pipe_create(&pipe_of_death_in, &pipe_of_death_out,
 
3421
-                                   pconf)) != APR_SUCCESS) {
 
3422
+    if ((rv = apr_file_pipe_create(&pipe_of_death_in,
 
3423
+                                   &pipe_of_death_out, pconf))
 
3424
+            != APR_SUCCESS) {
 
3425
         ap_log_error(APLOG_MARK, APLOG_ERR, rv,
 
3426
                      (const server_rec*) ap_server_conf,
 
3427
                      "apr_file_pipe_create (pipe_of_death)");
 
3428
         exit(1);
 
3429
     }
 
3430
+
 
3431
     if ((rv = apr_file_pipe_timeout_set(pipe_of_death_in, 0)) != APR_SUCCESS) {
 
3432
         ap_log_error(APLOG_MARK, APLOG_ERR, rv,
 
3433
                      (const server_rec*) ap_server_conf,
 
3434
@@ -2880,7 +2905,8 @@
 
3435
 }
 
3436
 
 
3437
 static int restart_num = 0;
 
3438
-static int peruser_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
 
3439
+static int peruser_pre_config(apr_pool_t *p, apr_pool_t *plog,
 
3440
+        apr_pool_t *ptemp)
 
3441
 {
 
3442
     int no_detach, debug, foreground, i;
 
3443
     int tmp_server_limit = DEFAULT_SERVER_LIMIT;
 
3444
@@ -2897,8 +2923,7 @@
 
3445
         foreground = one_process = 1;
 
3446
         no_detach = 0;
 
3447
     }
 
3448
-    else
 
3449
-    {
 
3450
+    else {
 
3451
         no_detach = ap_exists_config_define("NO_DETACH");
 
3452
         one_process = ap_exists_config_define("ONE_PROCESS");
 
3453
         foreground = ap_exists_config_define("FOREGROUND");
 
3454
@@ -2908,7 +2933,8 @@
 
3455
     if (restart_num++ == 1) {
 
3456
         if (!one_process && !foreground) {
 
3457
             rv = apr_proc_detach(no_detach ? APR_PROC_DETACH_FOREGROUND
 
3458
-                                           : APR_PROC_DETACH_DAEMONIZE);
 
3459
+                    : APR_PROC_DETACH_DAEMONIZE);
 
3460
+
 
3461
             if (rv != APR_SUCCESS) {
 
3462
                 ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
 
3463
                              "apr_proc_detach failed");
 
3464
@@ -2933,7 +2959,7 @@
 
3465
     ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
 
3466
     ap_extended_status = 1;
 
3467
 #ifdef AP_MPM_WANT_SET_MAX_MEM_FREE
 
3468
-       ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED;
 
3469
+    ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED;
 
3470
 #endif
 
3471
 
 
3472
     expire_timeout = DEFAULT_EXPIRE_TIMEOUT;
 
3473
@@ -2942,21 +2968,16 @@
 
3474
     processor_wait_timeout = DEFAULT_PROCESSOR_WAIT_TIMEOUT;
 
3475
     processor_wait_steps = DEFAULT_PROCESSOR_WAIT_STEPS;
 
3476
 
 
3477
-
 
3478
     apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
 
3479
 
 
3480
     /* we need to know ServerLimit and ThreadLimit before we start processing
 
3481
      * the tree because we need to already have allocated child_info_table
 
3482
      */
 
3483
-    for (pdir = ap_conftree; pdir != NULL; pdir = pdir->next)
 
3484
-    {
 
3485
-        if (!strcasecmp(pdir->directive, "ServerLimit"))
 
3486
-        {
 
3487
-            if (atoi(pdir->args) > tmp_server_limit)
 
3488
-            {
 
3489
+    for (pdir = ap_conftree; pdir != NULL; pdir = pdir->next) {
 
3490
+        if (!strcasecmp(pdir->directive, "ServerLimit")) {
 
3491
+            if (atoi(pdir->args) > tmp_server_limit) {
 
3492
                 tmp_server_limit = atoi(pdir->args);
 
3493
-                if (tmp_server_limit > MAX_SERVER_LIMIT)
 
3494
-                {
 
3495
+                if (tmp_server_limit > MAX_SERVER_LIMIT) {
 
3496
                     tmp_server_limit = MAX_SERVER_LIMIT;
 
3497
                 }
 
3498
             }
 
3499
@@ -2975,9 +2996,11 @@
 
3500
 
 
3501
     if (!child_info_image) {
 
3502
         _DBG("Initializing child_info_table", 0);
 
3503
-        child_info_size = tmp_server_limit * sizeof(child_info_t) + sizeof(apr_size_t);
 
3504
+        child_info_size = tmp_server_limit * sizeof(child_info_t)
 
3505
+                          + sizeof(apr_size_t);
 
3506
 
 
3507
-        rv = apr_shm_create(&child_info_shm, child_info_size, NULL, global_pool);
 
3508
+        rv = apr_shm_create(&child_info_shm, child_info_size, NULL,
 
3509
+                            global_pool);
 
3510
 
 
3511
         /*  if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) { */
 
3512
         if (rv != APR_SUCCESS) {
 
3513
@@ -2997,38 +3020,42 @@
 
3514
             return HTTP_INTERNAL_SERVER_ERROR;
 
3515
         }
 
3516
 
 
3517
-        memset(shmem, 0, child_info_size);
 
3518
-        child_info_image = (child_info*)apr_palloc(global_pool, sizeof(child_info));
 
3519
-        child_info_image->control = (child_info_control*)shmem;
 
3520
+        child_info_image = (child_info*) apr_palloc(global_pool,
 
3521
+                                                    sizeof(child_info));
 
3522
+        child_info_image->control = (child_info_control*) shmem;
 
3523
         shmem += sizeof(child_info_control);
 
3524
-        child_info_image->table = (child_info_t*)shmem;
 
3525
-    }
 
3526
-
 
3527
-    _DBG("Clearing child_info_table");
 
3528
-    child_info_image->control->num = 0;
 
3529
+        child_info_image->table = (child_info_t*) shmem;
 
3530
 
 
3531
-    for (i = 0; i < tmp_server_limit; i++) {
 
3532
-        CHILD_INFO_TABLE[i].pid     = 0;
 
3533
-        CHILD_INFO_TABLE[i].senv    = (server_env_t*)NULL;
 
3534
-        CHILD_INFO_TABLE[i].type    = CHILD_TYPE_UNKNOWN;
 
3535
-        CHILD_INFO_TABLE[i].status  = CHILD_STATUS_STANDBY;
 
3536
-        CHILD_INFO_TABLE[i].sock_fd = -3; /* -1 and -2 are taken */
 
3537
-        CHILD_INFO_TABLE[i].id      = i;
 
3538
+        for (i = 0; i < tmp_server_limit; i++) {
 
3539
+            memset(&CHILD_INFO_TABLE[i], 0, sizeof(child_info_t));
 
3540
+            CHILD_INFO_TABLE[i].id = i;
 
3541
+        }
 
3542
+    }
 
3543
+    else {
 
3544
+        for (i = 0; i < NUM_CHILDS; i++) {
 
3545
+            if (!is_graceful || (CHILD_INFO_TABLE[i].pid == 0
 
3546
+                && CHILD_INFO_TABLE[i].status == CHILD_STATUS_STANDBY)) {
 
3547
+                memset(&CHILD_INFO_TABLE[i], 0, sizeof(child_info_t));
 
3548
+                CHILD_INFO_TABLE[i].id = i;
 
3549
+            }
 
3550
+        }
 
3551
     }
 
3552
 
 
3553
-    if (!server_env_image)
 
3554
-    {
 
3555
-       _DBG("Initializing server_environments_table", 0);
 
3556
-       server_env_size = tmp_server_limit * sizeof(server_env_t) + sizeof(apr_size_t);
 
3557
+    if (!server_env_image) {
 
3558
+        _DBG("Initializing server_environments_table", 0);
 
3559
 
 
3560
-       rv = apr_shm_create(&server_env_shm, server_env_size, NULL, global_pool);
 
3561
+        server_env_size = tmp_server_limit * sizeof(server_env_t)
 
3562
+                          + sizeof(apr_size_t);
 
3563
 
 
3564
-       if (rv != APR_SUCCESS) {
 
3565
-           _DBG("shared memory creation failed", 0);
 
3566
+        rv = apr_shm_create(&server_env_shm, server_env_size, NULL,
 
3567
+                            global_pool);
 
3568
 
 
3569
-           ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
 
3570
-                        "Unable to create shared memory segment "
 
3571
-                        "(anonymous shared memory failure)");
 
3572
+        if (rv != APR_SUCCESS) {
 
3573
+            _DBG("shared memory creation failed", 0);
 
3574
+
 
3575
+            ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
 
3576
+                         "Unable to create shared memory segment "
 
3577
+                         "(anonymous shared memory failure)");
 
3578
         }
 
3579
         else if (rv == APR_ENOTIMPL) {
 
3580
             _DBG("anonymous shared memory not available", 0);
 
3581
@@ -3041,38 +3068,39 @@
 
3582
         }
 
3583
 
 
3584
         memset(shmem, 0, server_env_size);
 
3585
-        server_env_image = (server_env*)apr_palloc(global_pool, sizeof(server_env));
 
3586
-        server_env_image->control = (server_env_control*)shmem;
 
3587
+        server_env_image = (server_env*) apr_palloc(global_pool,
 
3588
+                                                    sizeof(server_env));
 
3589
+        server_env_image->control = (server_env_control*) shmem;
 
3590
         shmem += sizeof(server_env_control);
 
3591
-        server_env_image->table = (server_env_t*)shmem;
 
3592
+        server_env_image->table = (server_env_t*) shmem;
 
3593
     }
 
3594
-    
 
3595
+
 
3596
     _DBG("Clearing server environment table");
 
3597
-    server_env_image->control->num = 0;    
 
3598
+    server_env_image->control->num = 0;
 
3599
 
 
3600
     for (i = 0; i < tmp_server_limit; i++) {
 
3601
         SENV[i].processor_id = -1;
 
3602
-        SENV[i].uid          = -1;
 
3603
-        SENV[i].gid          = -1;
 
3604
-        SENV[i].chroot       = NULL;
 
3605
-        SENV[i].input        = -1;
 
3606
-        SENV[i].output       = -1;
 
3607
+        SENV[i].uid = -1;
 
3608
+        SENV[i].gid = -1;
 
3609
+        SENV[i].chroot = NULL;
 
3610
+        SENV[i].input = -1;
 
3611
+        SENV[i].output = -1;
 
3612
         SENV[i].error_cgroup = 0;
 
3613
-        SENV[i].error_pass   = 0;
 
3614
+        SENV[i].error_pass = 0;
 
3615
     }
 
3616
 
 
3617
     return OK;
 
3618
 }
 
3619
 
 
3620
-static int peruser_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *server_list)
 
3621
+static int peruser_post_config(apr_pool_t *p, apr_pool_t *plog,
 
3622
+        apr_pool_t *ptemp, server_rec *server_list)
 
3623
 {
 
3624
-    server_env_t senv;
 
3625
     const char *r;
 
3626
-
 
3627
-    ap_child_table = (ap_ctable *)apr_pcalloc(p, server_limit * sizeof(ap_ctable));
 
3628
+    server_env_t senv;
 
3629
 
 
3630
     /* Retrieve the function from mod_ssl for detecting SSL virtualhosts */
 
3631
-    ssl_server_is_https = (ssl_server_is_https_t) apr_dynamic_fn_retrieve("ssl_server_is_https");
 
3632
+    ssl_server_is_https = (ssl_server_is_https_t) apr_dynamic_fn_retrieve(
 
3633
+                                                         "ssl_server_is_https");
 
3634
 
 
3635
     /* Create the server environment for multiplexers */
 
3636
     senv.uid = unixd_config.user_id;
 
3637
@@ -3081,17 +3109,20 @@
 
3638
     senv.cgroup = NULL;
 
3639
     senv.nice_lvl = 0;
 
3640
     senv.name = "Multiplexer";
 
3641
+    senv.stats_connections = 0;
 
3642
+    senv.stats_requests = 0;
 
3643
+    senv.stats_dropped = 0;
 
3644
+
 
3645
+    senv.min_processors = ap_min_multiplexers;
 
3646
+    senv.min_free_processors = ap_min_free_processors;
 
3647
+    senv.max_free_processors = ap_max_free_processors;
 
3648
+    senv.max_processors = ap_max_multiplexers;
 
3649
 
 
3650
-    senv.min_processors        = ap_min_multiplexers;
 
3651
-    senv.min_free_processors   = ap_min_free_processors;
 
3652
-    senv.max_free_processors    = ap_max_free_processors;
 
3653
-    senv.max_processors        = ap_max_multiplexers;
 
3654
-
 
3655
-    r = child_add(CHILD_TYPE_MULTIPLEXER, CHILD_STATUS_STARTING,
 
3656
-                     p, &senv);
 
3657
+    r = child_add(CHILD_TYPE_MULTIPLEXER, CHILD_STATUS_STARTING, p,
 
3658
+                  &senv);
 
3659
 
 
3660
     if (r != NULL) {
 
3661
-        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, p, r);
 
3662
+        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, r);
 
3663
         return -1;
 
3664
     }
 
3665
 
 
3666
@@ -3106,33 +3137,34 @@
 
3667
     child_info_t *processor;
 
3668
 
 
3669
     if (sconf->senv == NULL) {
 
3670
-        _DBG("Server environment not set on virtualhost %s", r->server->server_hostname);
 
3671
+        _DBG("Server environment not set on virtualhost %s",
 
3672
+             r->server->server_hostname);
 
3673
 
 
3674
         if (sconf->missing_senv_reported == 0) {
 
3675
             ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf,
 
3676
                          "Virtualhost %s has no server environment set, "
 
3677
-                         "request will not be honoured.", r->server->server_hostname);
 
3678
+                         "request will not be honoured.",
 
3679
+                         r->server->server_hostname);
 
3680
         }
 
3681
-        
 
3682
+
 
3683
         sconf->missing_senv_reported = 1;
 
3684
 
 
3685
         return HTTP_INTERNAL_SERVER_ERROR;
 
3686
     }
 
3687
 
 
3688
-    if(CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER)
 
3689
+    if (CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER) {
 
3690
         processor = &CHILD_INFO_TABLE[sconf->senv->processor_id];
 
3691
-    else
 
3692
+    }
 
3693
+    else {
 
3694
         processor = &CHILD_INFO_TABLE[r->connection->id];
 
3695
+    }
 
3696
 
 
3697
-
 
3698
-    if (!strlen(r->the_request))
 
3699
-    {
 
3700
+    if (!strlen(r->the_request)) {
 
3701
         _DBG("corrupt request. aborting",0);
 
3702
         return DECLINED;
 
3703
     }
 
3704
 
 
3705
-    if (processor->sock_fd != AP_PERUSER_THISCHILD)
 
3706
-    {
 
3707
+    if (processor->sock_fd != AP_PERUSER_THISCHILD) {
 
3708
         apr_socket_t *sock = NULL;
 
3709
 
 
3710
         apr_os_sock_put(&sock, &processor->sock_fd, r->connection->pool);
 
3711
@@ -3142,201 +3174,239 @@
 
3712
         return OK;
 
3713
     }
 
3714
 
 
3715
-    switch (CHILD_INFO_TABLE[my_child_num].type)
 
3716
+    switch (CHILD_INFO_TABLE[my_child_num].type) {
 
3717
+    case CHILD_TYPE_MULTIPLEXER:
 
3718
     {
 
3719
-        case CHILD_TYPE_MULTIPLEXER:
 
3720
-        {
 
3721
-            _DBG("MULTIPLEXER => Determining if request should be passed. "
 
3722
-                 "Child Num: %d, dest-child: %d, hostname from server: %s r->hostname=%s r->the_request=\"%s\"",
 
3723
-                my_child_num, processor->id, r->server->server_hostname, r->hostname, r->the_request);
 
3724
+        _DBG("MULTIPLEXER => Determining if request should be passed. "
 
3725
+                "Child Num: %d, dest-child: %d, hostname from server: %s "
 
3726
+                "r->hostname=%s r->the_request=\"%s\"",
 
3727
+                my_child_num, processor->id, r->server->server_hostname,
 
3728
+                r->hostname, r->the_request);
 
3729
+
 
3730
+        if (processor->id != my_child_num) {
 
3731
+            if (processor->status == CHILD_STATUS_STANDBY) {
 
3732
+                _DBG("Activating child #%d", processor->id);
 
3733
+                processor->status = CHILD_STATUS_STARTING;
 
3734
+            }
 
3735
 
 
3736
-            if (processor->id != my_child_num)
 
3737
-            {
 
3738
-                if (processor->status == CHILD_STATUS_STANDBY)
 
3739
-                {
 
3740
-                    _DBG("Activating child #%d", processor->id);
 
3741
-                    processor->status = CHILD_STATUS_STARTING;
 
3742
+            _DBG("Passing request.",0);
 
3743
+            if (pass_request(r, processor) == -1) {
 
3744
+                if (processor->senv->error_pass == 0) {
 
3745
+                    ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf,
 
3746
+                                 "Could not pass request to processor %s "
 
3747
+                                 "(virtualhost %s), "
 
3748
+                                 "request will not be honoured.",
 
3749
+                                 processor->senv->name, r->hostname);
 
3750
                 }
 
3751
 
 
3752
-                _DBG("Passing request.",0);
 
3753
-                if (pass_request(r, processor) == -1)
 
3754
-                {
 
3755
-                    if (processor->senv->error_pass == 0) {
 
3756
-                        ap_log_error(APLOG_MARK, APLOG_ERR, 0,
 
3757
-                                     ap_server_conf, "Could not pass request to processor %s (virtualhost %s), request will not be honoured.",
 
3758
-                                     processor->senv->name, r->hostname);
 
3759
-                    }
 
3760
+                processor->senv->error_pass = 1;
 
3761
+                processor->senv->stats_dropped++;
 
3762
 
 
3763
-                    processor->senv->error_pass = 1;
 
3764
+                return HTTP_SERVICE_UNAVAILABLE;
 
3765
+            }
 
3766
+            else {
 
3767
+                processor->senv->error_pass = 0;
 
3768
+            }
 
3769
 
 
3770
-                    return HTTP_SERVICE_UNAVAILABLE;
 
3771
-                }
 
3772
-                else {
 
3773
-                    processor->senv->error_pass = 0;
 
3774
+            _DBG("doing longjmp",0);
 
3775
+
 
3776
+            longjmp(CHILD_INFO_TABLE[my_child_num].jmpbuffer, 1);
 
3777
+
 
3778
+            _DBG("request declined at our site",0);
 
3779
+
 
3780
+            return DECLINED;
 
3781
+        }
 
3782
+
 
3783
+        _DBG("The server is assigned to the multiplexer! Dropping request");
 
3784
+
 
3785
+        return DECLINED;
 
3786
+    }
 
3787
+    case CHILD_TYPE_PROCESSOR:
 
3788
+    case CHILD_TYPE_WORKER:
 
3789
+    {
 
3790
+        if (sconf->senv != CHILD_INFO_TABLE[my_child_num].senv) {
 
3791
+            _DBG("request not for this worker - passing it back to the "
 
3792
+                 "multiplexer");
 
3793
+
 
3794
+            child_info_t *multiplexer = &CHILD_INFO_TABLE[multiplexer_senv->
 
3795
+                                                          processor_id];
 
3796
+
 
3797
+            if (pass_request(r, multiplexer) == -1) {
 
3798
+                if (multiplexer->senv->error_pass == 0) {
 
3799
+                    ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf,
 
3800
+                                 "Could not pass request to multiplexer, "
 
3801
+                                 "request will not be honoured (%s).",
 
3802
+                                 r->hostname);
 
3803
                 }
 
3804
 
 
3805
-                _DBG("doing longjmp",0);
 
3806
-                longjmp(CHILD_INFO_TABLE[my_child_num].jmpbuffer, 1);
 
3807
-                _DBG("request declined at our site",0);
 
3808
-                return DECLINED;
 
3809
+                multiplexer->senv->error_pass = 1;
 
3810
+                multiplexer->senv->stats_dropped++;
 
3811
+
 
3812
+                return HTTP_SERVICE_UNAVAILABLE;
 
3813
+            }
 
3814
+            else {
 
3815
+                multiplexer->senv->error_pass = 0;
 
3816
             }
 
3817
-            _DBG("WTF: the server is assigned to the multiplexer! ... dropping request",0);
 
3818
+            _DBG("doing longjmp",0);
 
3819
+
 
3820
+            longjmp(CHILD_INFO_TABLE[my_child_num].jmpbuffer, 1);
 
3821
+
 
3822
             return DECLINED;
 
3823
         }
 
3824
-        case CHILD_TYPE_PROCESSOR:
 
3825
-        case CHILD_TYPE_WORKER:
 
3826
-        {
 
3827
-               if (sconf->senv != CHILD_INFO_TABLE[my_child_num].senv) {
 
3828
-                       ap_log_error(APLOG_MARK, APLOG_WARNING, 
 
3829
-                                    0, ap_server_conf,
 
3830
-                                   "invalid virtualhost for this child! (%s)", r->hostname);
 
3831
-                       ap_lingering_close(r->connection);
 
3832
-                       return HTTP_REQUEST_TIME_OUT;
 
3833
-               }
 
3834
-               
 
3835
-            _DBG("%s %d", child_type_string(CHILD_INFO_TABLE[my_child_num].type), my_child_num);
 
3836
-            _DBG("request for %s / (server %s) seems to be for us", r->hostname, r->server->server_hostname);
 
3837
 
 
3838
-            if (server_env_cleanup)
 
3839
-            {
 
3840
-                int i;
 
3841
-                int input = sconf->senv->input;
 
3842
-                int output = sconf->senv->output;
 
3843
+        _DBG("%s %d", child_type_string(CHILD_INFO_TABLE[my_child_num].type),
 
3844
+             my_child_num);
 
3845
 
 
3846
-                _DBG("performing handle cleanup");
 
3847
-                for (i = 0; i < NUM_SENV; i++)
 
3848
-                {
 
3849
-                    if (SENV[i].input > 0 && SENV[i].input != input) {
 
3850
-                        int retval = close(SENV[i].input);
 
3851
-                        if (retval < 0) {
 
3852
-                            ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
3853
-                                         "close(%d) failed", SENV[i].input);
 
3854
-                        }
 
3855
+        _DBG("request for %s / (server %s) seems to be for us", r->hostname,
 
3856
+             r->server->server_hostname);
 
3857
+
 
3858
+        if (server_env_cleanup) {
 
3859
+            int i;
 
3860
+            int input = sconf->senv->input;
 
3861
+            int output = sconf->senv->output;
 
3862
+
 
3863
+            _DBG("performing handle cleanup");
 
3864
+            for (i = 0; i < NUM_SENV; i++) {
 
3865
+                if (&SENV[i] == multiplexer_senv) {
 
3866
+                    continue;
 
3867
+                }
 
3868
+
 
3869
+                if (SENV[i].input > 0 && SENV[i].input != input) {
 
3870
+                    int retval = close(SENV[i].input);
 
3871
+                    if (retval < 0) {
 
3872
+                        ap_log_error(APLOG_MARK, APLOG_WARNING, errno,
 
3873
+                                     ap_server_conf, "close(%d) failed",
 
3874
+                                     SENV[i].input);
 
3875
                     }
 
3876
-                    if (SENV[i].output > 0 && SENV[i].output != output) {
 
3877
-                        int retval = close(SENV[i].output);
 
3878
-                        if (retval < 0) {
 
3879
-                            ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
 
3880
-                                         "close(%d) failed", SENV[i].output);
 
3881
-                        }
 
3882
+                }
 
3883
+
 
3884
+                if (SENV[i].output > 0 && SENV[i].output != output) {
 
3885
+                    int retval = close(SENV[i].output);
 
3886
+                    if (retval < 0) {
 
3887
+                        ap_log_error(APLOG_MARK, APLOG_WARNING, errno,
 
3888
+                                     ap_server_conf, "close(%d) failed",
 
3889
+                                     SENV[i].output);
 
3890
                     }
 
3891
                 }
 
3892
-                server_env_cleanup = 0;
 
3893
             }
 
3894
-
 
3895
-            return OK;
 
3896
-        }
 
3897
-        default:
 
3898
-        {
 
3899
-            _DBG("unspecified child type %d in %d, dropping request",
 
3900
-                 CHILD_INFO_TABLE[my_child_num].type, my_child_num);
 
3901
-            return DECLINED;
 
3902
+            server_env_cleanup = 0;
 
3903
         }
 
3904
+
 
3905
+        CHILD_INFO_TABLE[my_child_num].senv->stats_requests++;
 
3906
+
 
3907
+        return OK;
 
3908
+    }
 
3909
+    default:
 
3910
+    {
 
3911
+        _DBG("unspecified child type %d in %d, dropping request",
 
3912
+             CHILD_INFO_TABLE[my_child_num].type, my_child_num);
 
3913
+        return DECLINED;
 
3914
+    }
 
3915
     }
 
3916
 
 
3917
     _DBG("THIS POINT SHOULD NOT BE REACHED!",0);
 
3918
+
 
3919
     return OK;
 
3920
 }
 
3921
 
 
3922
+int senv_active_cmp(const void *a, const void *b)
 
3923
+{
 
3924
+    _DBG("CMP %d %d", *(int *) a,*(int *) b);
 
3925
 
 
3926
-int senv_active_cmp(const void *a, const void *b) {
 
3927
-  _DBG("CMP %d %d", *(int *) a,*(int *)  b);
 
3928
-  return active_env_processors(*(int *)a)<active_env_processors(*(int *)b);
 
3929
+    return active_env_processors(*(int *) a)
 
3930
+            < active_env_processors(*(int *) b);
 
3931
 }
 
3932
 
 
3933
 static int peruser_status_hook(request_rec *r, int flags)
 
3934
 {
 
3935
     int x;
 
3936
+    child_info_t *child;
 
3937
     server_env_t *senv;
 
3938
 
 
3939
-    if (flags & AP_STATUS_SHORT)
 
3940
-           return OK;
 
3941
+    if (flags & AP_STATUS_SHORT) {
 
3942
+        return OK;
 
3943
+    }
 
3944
 
 
3945
+    if (flags & AP_STATUS_PERUSER_STATS) {
 
3946
+        int *sorted_senv;
 
3947
+        int i;
 
3948
+        sorted_senv = (int *) apr_palloc(r->pool, NUM_SENV * sizeof(int));
 
3949
 
 
3950
-       if (flags & AP_STATUS_STATS) {
 
3951
-               
 
3952
-               int *sorted_senv;
 
3953
-               int i;
 
3954
-               sorted_senv=(int *) apr_palloc(r->pool, NUM_SENV*sizeof(int));
 
3955
-               
 
3956
-               if(!sorted_senv) {
 
3957
-                       ap_rputs("peruser_status_hook(): Out of memory",r);
 
3958
-                       return OK;
 
3959
-               }
 
3960
-               /* Initial senv table */
 
3961
-               for(i=0; i < NUM_SENV; i++)
 
3962
-                       sorted_senv[i]=i;
 
3963
-
 
3964
-               /* sort env by number of processors */
 
3965
-               qsort(sorted_senv, NUM_SENV, sizeof(int), senv_active_cmp);
 
3966
-
 
3967
-               ap_rputs("<h3>Processors statistics:</h3><table border=\"0\"><tr><th>Environment</th><th>Pss</th><th>Avail</th></tr>", r);
 
3968
-               /* just a mockup to se what data will be usefull here will put code layter, yes I know we need to iterate ON ENV[] NUM_ENV times */
 
3969
-               for (x = 0; x < NUM_SENV; x++)
 
3970
-               {
 
3971
-                       senv = &SENV[sorted_senv[x]];
 
3972
-                       if(senv==NULL)
 
3973
-                               continue;
 
3974
-                       ap_rprintf(r, "<tr><td nowrap>%s</td><td nowrap>%d/%d/%d</td>"
 
3975
-                                       "<td>%d%%</td></tr>",
 
3976
-                                       senv == NULL ? NULL : ( senv->name == NULL ? "" : senv->name ),
 
3977
-                                       active_env_processors(sorted_senv[x]), idle_env_processors(sorted_senv[x]), senv == NULL ? 0 : senv->max_processors,
 
3978
-                                       senv == NULL ? 0 : senv->availability );
 
3979
-                       }
 
3980
-                       ap_rputs("</table><tr/>", r);
 
3981
-                       
 
3982
-                       ap_rputs("<hr/><table>"
 
3983
-                                       "<tr><th>Pss</th><td>Number of processors active/idle/max</td></tr>"
 
3984
-                                       "</table><hr/>",r);
 
3985
-       }else {
 
3986
-    ap_rputs("<hr>\n", r);
 
3987
-    ap_rputs("<h3>peruser status</h3>\n", r);
 
3988
-    ap_rputs("<table border=\"0\">\n", r);
 
3989
-    ap_rputs("<tr><th>ID</th><th>PID</th><th>STATUS</th><th>SB STATUS</th><th>Type</th><th>Processor</th>"
 
3990
-                   "<th>Pss</th>"
 
3991
-                   "<th>AVAIL</th>"
 
3992
-                   "</tr>\n", r);
 
3993
-    for (x = 0; x < NUM_CHILDS; x++)
 
3994
-        {
 
3995
-        senv = CHILD_INFO_TABLE[x].senv;
 
3996
-        ap_rprintf(r, "<tr><td>%3d</td><td>%5d</td><td>%8s</td><td>%8s</td><td>%12s</td><td nowrap>%48s</td>"
 
3997
-                       "<td>%d/%d/%d</td>"
 
3998
+        if (!sorted_senv) {
 
3999
+            ap_rputs("peruser_status_hook(): Out of memory", r);
 
4000
+            return OK;
 
4001
+        }
 
4002
+
 
4003
+        /* Initial senv table */
 
4004
+        for (i = 0; i < NUM_SENV; i++) {
 
4005
+            sorted_senv[i] = i;
 
4006
+        }
 
4007
+
 
4008
+        /* sort env by number of processors */
 
4009
+        qsort(sorted_senv, NUM_SENV, sizeof(int), senv_active_cmp);
 
4010
+
 
4011
+        ap_rputs("<h3>Processors statistics:</h3>"
 
4012
+                 "<table width=700 border=\"0\"><tr><th>Environment</th><th>Pss</th>"
 
4013
+                 "<th>Connections</th><th>Requests</th><th>Dropped (503)</th>"
 
4014
+                 "<th>Avail</th></tr>", r);
 
4015
+
 
4016
+        /* just a mockup to see what data will be useful here will put code
 
4017
+         * later, yes I know we need to iterate ON ENV[] NUM_ENV times */
 
4018
+        for (x = 0; x < NUM_SENV; x++) {
 
4019
+            senv = &SENV[sorted_senv[x]];
 
4020
+            if (senv == NULL) {
 
4021
+                continue;
 
4022
+            }
 
4023
+
 
4024
+            ap_rprintf(r, "<tr><td nowrap>%s</td><td nowrap>%d/%d/%d</td>"
 
4025
+                       "<td>%d</td><td>%d</td><td>%d</td><td>%d%%</td></tr>",
 
4026
+                       senv->name == NULL ? "" : senv->name,
 
4027
+                       active_env_processors(sorted_senv[x]),
 
4028
+                       idle_env_processors(sorted_senv[x]),
 
4029
+                       senv->max_processors, senv->stats_connections,
 
4030
+                       senv->stats_requests, senv->stats_dropped,
 
4031
+                       senv->availability);
 
4032
+        }
 
4033
+        ap_rputs("</table><tr/>", r);
 
4034
+
 
4035
+        ap_rputs("<hr/><table>"
 
4036
+            "<tr><th>Pss</th><td>Number of processors active/idle/max</td></tr>"
 
4037
+            "</table><hr/>", r);
 
4038
+    }
 
4039
+    else {
 
4040
+        ap_rputs("<hr>\n", r);
 
4041
+        ap_rputs("<h3>peruser status</h3>\n", r);
 
4042
+        ap_rputs("<table border=\"0\">\n", r);
 
4043
+        ap_rputs("<tr><th>ID</th><th>PID</th><th>STATUS</th><th>SB STATUS</th>"
 
4044
+                 "<th>Type</th><th>Processor</th><th>Pss</th><th>AVAIL</th>"
 
4045
+                 "</tr>\n", r);
 
4046
+
 
4047
+        for (x = 0; x < NUM_CHILDS; x++) {
 
4048
+            child = &CHILD_INFO_TABLE[x];
 
4049
+            senv = child->senv;
 
4050
+            ap_rprintf(r,
 
4051
+                       "<tr><td>%3d</td><td>%5d</td><td>%8s</td><td>%8s</td>"
 
4052
+                       "<td>%12s</td><td nowrap>%48s</td><td>%d/%d/%d</td>"
 
4053
                        "<td>%3d%%</td></tr>\n",
 
4054
-                       CHILD_INFO_TABLE[x].id, 
 
4055
-                       CHILD_INFO_TABLE[x].pid, 
 
4056
-                       child_status_string(CHILD_INFO_TABLE[x].status), 
 
4057
+                       child->id, child->pid,
 
4058
+                       child_status_string(child->status),
 
4059
                        scoreboard_status_string(SCOREBOARD_STATUS(x)),
 
4060
-                       child_type_string(CHILD_INFO_TABLE[x].type), 
 
4061
-                       senv == NULL ? NULL : ( senv->name == NULL ? "" : senv->name ), 
 
4062
+                       child_type_string(child->type),
 
4063
+                       senv == NULL ? NULL : (senv->name == NULL ? "" :
 
4064
+                                              senv->name),
 
4065
                        active_processors(x),
 
4066
                        idle_processors(x),
 
4067
-                       senv == NULL ? 0 : CHILD_INFO_TABLE[x].senv->max_processors,
 
4068
-                       senv == NULL ? 0 : CHILD_INFO_TABLE[x].senv->availability
 
4069
-                       );
 
4070
-       }
 
4071
-    ap_rputs("</table>\n", r);
 
4072
-
 
4073
-    ap_rputs("<hr/><table>"
 
4074
-                       "<tr><th>STATUS</th><td>Processor status</td></tr>"
 
4075
-                       "<tr><th>Pss</th><td>Number of processors active/idle/max</td></tr>"
 
4076
-                       "</table><hr/>",r);
 
4077
-       }
 
4078
-               
 
4079
-    if (grace_children > 0) {
 
4080
-       ap_rputs("<h2>peruser graceful children status</h2>\n", r);
 
4081
-       ap_rprintf(r, "%d of total %d still living<br />\n", grace_children_alive, grace_children);
 
4082
-        ap_rputs("<table border=\"0\">\n", r);
 
4083
-        ap_rputs("<tr><td>ID</td><td>PID</td><td>STATUS</td><td>TYPE</td></tr>\n", r);
 
4084
-        for (x = 0; x < grace_children; x++) {
 
4085
-            ap_rprintf(r, "<tr><td>%3d</td><td>%5d</td><td>%8s</td><td>%12s</td></tr>\n", 
 
4086
-                           child_grace_info_table[x].id, 
 
4087
-                           child_grace_info_table[x].pid, 
 
4088
-                           child_status_string(child_grace_info_table[x].status), 
 
4089
-                           child_type_string(child_grace_info_table[x].type)
 
4090
-                           );
 
4091
+                       senv == NULL ? 0 : senv->max_processors,
 
4092
+                       senv == NULL ? 0 : senv->availability);
 
4093
         }
 
4094
         ap_rputs("</table>\n", r);
 
4095
+
 
4096
+        ap_rputs("<hr/><table>"
 
4097
+            "<tr><th>STATUS</th><td>Processor status</td></tr>"
 
4098
+            "<tr><th>Pss</th><td>Number of processors active/idle/max</td></tr>"
 
4099
+            "</table><hr/>", r);
 
4100
     }
 
4101
+
 
4102
     return OK;
 
4103
 }
 
4104
 
 
4105
@@ -3346,7 +3416,7 @@
 
4106
      * will be redirected to a file, and the messages won't print to the
 
4107
      * console.
 
4108
      */
 
4109
-    static const char *const aszSucc[] = {"core.c", NULL};
 
4110
+    static const char * const aszSucc[] = { "core.c", NULL };
 
4111
 
 
4112
 #ifdef AUX3
 
4113
     (void) set42sig();
 
4114
@@ -3368,17 +3438,24 @@
 
4115
     ap_hook_process_connection(peruser_process_connection, NULL, NULL,
 
4116
                                APR_HOOK_REALLY_FIRST);
 
4117
 
 
4118
-    APR_OPTIONAL_HOOK(ap, status_hook, peruser_status_hook, NULL, NULL, APR_HOOK_MIDDLE);
 
4119
+    APR_OPTIONAL_HOOK(ap, status_hook, peruser_status_hook, NULL, NULL,
 
4120
+                      APR_HOOK_MIDDLE);
 
4121
 }
 
4122
 
 
4123
-void senv_init(server_env_t * senv) {
 
4124
-    senv->nice_lvl             = 0;
 
4125
-    senv->chroot               = NULL;
 
4126
-    senv->cgroup               = NULL;
 
4127
-    senv->min_processors       = ap_min_processors;
 
4128
-    senv->min_free_processors  = ap_min_free_processors;
 
4129
-    senv->max_free_processors   = ap_max_free_processors;
 
4130
-    senv->max_processors       = ap_max_processors;
 
4131
+void senv_init(server_env_t * senv)
 
4132
+{
 
4133
+    senv->nice_lvl = 0;
 
4134
+    senv->chroot = NULL;
 
4135
+    senv->cgroup = NULL;
 
4136
+    senv->min_processors = ap_min_processors;
 
4137
+    senv->min_free_processors = ap_min_free_processors;
 
4138
+    senv->max_free_processors = ap_max_free_processors;
 
4139
+    senv->max_processors = ap_max_processors;
 
4140
+    senv->error_cgroup = 0;
 
4141
+    senv->error_pass = 0;
 
4142
+    senv->stats_connections = 0;
 
4143
+    senv->stats_requests = 0;
 
4144
+    senv->stats_dropped = 0;
 
4145
 }
 
4146
 
 
4147
 static const char *cf_Processor(cmd_parms *cmd, void *dummy, const char *arg)
 
4148
@@ -3390,15 +3467,17 @@
 
4149
     const char *endp = ap_strrchr_c(arg, '>');
 
4150
 
 
4151
     if (endp == NULL) {
 
4152
-       return apr_psprintf(cmd->temp_pool,
 
4153
-                           "Error: Directive %s> missing closing '>'", cmd->cmd->name);
 
4154
+        return apr_psprintf(cmd->temp_pool,
 
4155
+                            "Error: Directive %s> missing closing '>'",
 
4156
+                            cmd->cmd->name);
 
4157
     }
 
4158
 
 
4159
     arg = apr_pstrndup(cmd->pool, arg, endp - arg);
 
4160
 
 
4161
     if (!arg) {
 
4162
-       return apr_psprintf(cmd->temp_pool,
 
4163
-                            "Error: %s> must specify a processor name", cmd->cmd->name);
 
4164
+        return apr_psprintf(cmd->temp_pool,
 
4165
+                            "Error: %s> must specify a processor name",
 
4166
+                            cmd->cmd->name);
 
4167
     }
 
4168
 
 
4169
     senv.name = ap_getword_conf(cmd->pool, &arg);
 
4170
@@ -3406,7 +3485,8 @@
 
4171
 
 
4172
     if (strlen(senv.name) == 0) {
 
4173
         return apr_psprintf(cmd->temp_pool,
 
4174
-                            "Error: Directive %s> takes one argument", cmd->cmd->name);
 
4175
+                            "Error: Directive %s> takes one argument",
 
4176
+                            cmd->cmd->name);
 
4177
     }
 
4178
 
 
4179
     server_env_t *old_senv = find_senv_by_name(senv.name);
 
4180
@@ -3421,27 +3501,28 @@
 
4181
     current = cmd->directive->first_child;
 
4182
 
 
4183
     int proc_temp = 0;
 
4184
-    for(; current != NULL; current = current->next) {
 
4185
+    for (; current != NULL; current = current->next) {
 
4186
         directive = current->directive;
 
4187
-        
 
4188
+
 
4189
         if (!strcasecmp(directive, "user")) {
 
4190
             user_name = current->args;
 
4191
         }
 
4192
         else if (!strcasecmp(directive, "group")) {
 
4193
-           group_name = current->args;
 
4194
+            group_name = current->args;
 
4195
         }
 
4196
         else if (!strcasecmp(directive, "chroot")) {
 
4197
             senv.chroot = ap_getword_conf(cmd->pool, &current->args);
 
4198
         }
 
4199
         else if (!strcasecmp(directive, "nicelevel")) {
 
4200
-           senv.nice_lvl = atoi(current->args);
 
4201
+            senv.nice_lvl = atoi(current->args);
 
4202
         }
 
4203
         else if (!strcasecmp(directive, "maxprocessors")) {
 
4204
             proc_temp = atoi(current->args);
 
4205
 
 
4206
             if (proc_temp < 1) {
 
4207
                 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4208
-                             "WARNING: Require MaxProcessors > 0, setting to 1");
 
4209
+                             "WARNING: Require MaxProcessors > 0,"
 
4210
+                             "setting to 1");
 
4211
                 proc_temp = 1;
 
4212
             }
 
4213
 
 
4214
@@ -3452,7 +3533,8 @@
 
4215
 
 
4216
             if (proc_temp < 0) {
 
4217
                 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4218
-                             "WARNING: Require MinProcessors >= 0, setting to 0");
 
4219
+                             "WARNING: Require MinProcessors >= 0,"
 
4220
+                             "setting to 0");
 
4221
                 proc_temp = 0;
 
4222
             }
 
4223
 
 
4224
@@ -3463,7 +3545,8 @@
 
4225
 
 
4226
             if (proc_temp < 0) {
 
4227
                 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4228
-                             "WARNING: Require MinSpareProcessors >= 0, setting to 0");
 
4229
+                             "WARNING: Require MinSpareProcessors >= 0,"
 
4230
+                             "setting to 0");
 
4231
                 proc_temp = 0;
 
4232
             }
 
4233
 
 
4234
@@ -3471,10 +3554,11 @@
 
4235
         }
 
4236
         else if (!strcasecmp(directive, "maxspareprocessors")) {
 
4237
             proc_temp = atoi(current->args);
 
4238
-            
 
4239
+
 
4240
             if (proc_temp < 0) {
 
4241
                 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4242
-                             "WARNING: Require MaxSpareProcessors >= 0, setting to 0");
 
4243
+                             "WARNING: Require MaxSpareProcessors >= 0,"
 
4244
+                             "setting to 0");
 
4245
                 proc_temp = 0;
 
4246
             }
 
4247
 
 
4248
@@ -3485,53 +3569,64 @@
 
4249
         }
 
4250
         else {
 
4251
             ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4252
-                         "Unknown directive %s in %s>", directive, cmd->cmd->name);
 
4253
+                         "Unknown directive %s in %s>", directive,
 
4254
+                         cmd->cmd->name);
 
4255
         }
 
4256
     }
 
4257
 
 
4258
     if (user_name == NULL || group_name == NULL) {
 
4259
         return apr_psprintf(cmd->temp_pool,
 
4260
-                            "Error: User or Group must be set in %s>", cmd->cmd->name);
 
4261
+                            "Error: User or Group must be set in %s>",
 
4262
+                            cmd->cmd->name);
 
4263
     }
 
4264
 
 
4265
     senv.uid = ap_uname2id(user_name);
 
4266
     senv.gid = ap_gname2id(group_name);
 
4267
 
 
4268
     _DBG("name=%s user=%s:%d group=%s:%d chroot=%s nice_lvl=%d",
 
4269
-         senv.name, user_name, senv.uid, group_name, senv.gid, senv.chroot, senv.nice_lvl);
 
4270
+         senv.name, user_name, senv.uid, group_name, senv.gid, senv.chroot,
 
4271
+         senv.nice_lvl);
 
4272
 
 
4273
-    _DBG("min_processors=%d min_free_processors=%d max_spare_processors=%d max_processors=%d",
 
4274
-         senv.min_processors, senv.min_free_processors, senv.max_free_processors, senv.max_processors);
 
4275
+    _DBG("min_processors=%d min_free_processors=%d max_spare_processors=%d "
 
4276
+         "max_processors=%d", senv.min_processors, senv.min_free_processors,
 
4277
+         senv.max_free_processors, senv.max_processors);
 
4278
 
 
4279
-    return child_add(CHILD_TYPE_PROCESSOR, CHILD_STATUS_STANDBY,
 
4280
-                     cmd->pool, &senv);
 
4281
+    return child_add(CHILD_TYPE_PROCESSOR, CHILD_STATUS_STANDBY, cmd->pool,
 
4282
+                     &senv);
 
4283
 }
 
4284
 
 
4285
 static const char *cf_Processor_depr(cmd_parms *cmd, void *dummy,
 
4286
-    const char *user_name, const char *group_name, const char *chroot)
 
4287
+                                     const char *user_name,
 
4288
+                                     const char *group_name, const char *chroot)
 
4289
 {
 
4290
     return NULL;
 
4291
 }
 
4292
 
 
4293
 /* we define an Multiplexer child w/ specific uid/gid */
 
4294
 static const char *cf_Multiplexer(cmd_parms *cmd, void *dummy,
 
4295
-    const char *user_name, const char *group_name, const char *chroot)
 
4296
+                                  const char *user_name, const char *group_name,
 
4297
+                                  const char *chroot)
 
4298
 {
 
4299
     static short depr_warned = 0;
 
4300
-    
 
4301
+
 
4302
     if (depr_warned == 0) {
 
4303
         ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4304
-                     "WARNING: Multiplexer directive is deprecated. Multiplexer user and group is set by User and Group directives.");    
 
4305
-        
 
4306
+                     "WARNING: Multiplexer directive is deprecated."
 
4307
+                     "Multiplexer user and group is set by User and Group"
 
4308
+                     "directives.");
 
4309
+
 
4310
         ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4311
-                     "To set multiplexer chroot, please use MultiplexerChroot.");
 
4312
+                     "To set multiplexer chroot, "
 
4313
+                     "please use MultiplexerChroot.");
 
4314
 
 
4315
         depr_warned = 1;
 
4316
     }
 
4317
 
 
4318
     if (chroot) {
 
4319
-        if (!ap_is_directory(cmd->pool, chroot))
 
4320
-            return apr_psprintf(cmd->pool, "Error: multiplexer chroot directory [%s] does not exist", chroot);
 
4321
+        if (!ap_is_directory(cmd->pool, chroot)) {
 
4322
+            return apr_psprintf(cmd->pool, "Error:multiplexer chroot directory"
 
4323
+                                "[%s] does not exist", chroot);
 
4324
+        }
 
4325
 
 
4326
         multiplexer_chroot = chroot;
 
4327
         _DBG("Setting multiplexer chroot to %s", chroot);
 
4328
@@ -3541,12 +3636,13 @@
 
4329
 }
 
4330
 
 
4331
 static const char* cf_MultiplexerChroot(cmd_parms *cmd, void *dummy,
 
4332
-                                         const char *path)
 
4333
+                                        const char *path)
 
4334
 {
 
4335
     multiplexer_chroot = path;
 
4336
 
 
4337
     if (path && !ap_is_directory(cmd->pool, path))
 
4338
-        return apr_psprintf(cmd->pool, "Error: multiplexer chroot directory [%s] does not exist", path);
 
4339
+        return apr_psprintf(cmd->pool, "Error: multiplexer chroot directory"
 
4340
+                            "[%s] does not exist", path);
 
4341
 
 
4342
     _DBG("setting multiplexer chroot to %s", path);
 
4343
 
 
4344
@@ -3554,108 +3650,117 @@
 
4345
 }
 
4346
 
 
4347
 static const char* cf_ServerEnvironment(cmd_parms *cmd, void *dummy,
 
4348
-    const char *name, const char * group_name, const char * chroot)
 
4349
+        const char *name, const char * group_name, const char * chroot)
 
4350
 {
 
4351
     peruser_server_conf *sconf = PERUSER_SERVER_CONF(cmd->server->module_config);
 
4352
     server_env_t senv;
 
4353
     char * processor_name, *tmp;
 
4354
-       
 
4355
+
 
4356
     _DBG("function entered", 0);
 
4357
-       
 
4358
+
 
4359
     /* name of processor env */
 
4360
     processor_name = name;
 
4361
-    
 
4362
-    if(group_name != NULL || chroot != NULL) {
 
4363
+
 
4364
+    if (group_name != NULL || chroot != NULL) {
 
4365
         /* deprecated ServerEnvironment user group chroot syntax
 
4366
          * we create simple server env based on user/group/chroot only
 
4367
          */
 
4368
-        processor_name = apr_pstrcat(cmd->pool, name, "_",group_name, "_", chroot, NULL);
 
4369
-       
 
4370
+        processor_name = apr_pstrcat(cmd->pool, name, "_", group_name, "_",
 
4371
+                                     chroot, NULL);
 
4372
+
 
4373
         /* search for previous default server env */
 
4374
         sconf->senv = find_senv_by_name(processor_name);
 
4375
-       
 
4376
-        if(!sconf->senv) {
 
4377
+
 
4378
+        if (!sconf->senv) {
 
4379
             senv_init(&senv);
 
4380
             senv.uid = ap_uname2id(name);
 
4381
             senv.gid = ap_gname2id(group_name);
 
4382
             senv.chroot = chroot;
 
4383
             senv.name = processor_name;
 
4384
-            
 
4385
-            tmp = child_add(CHILD_TYPE_PROCESSOR, CHILD_STATUS_STANDBY, cmd->pool, &senv);
 
4386
+
 
4387
+            tmp = child_add(CHILD_TYPE_PROCESSOR, CHILD_STATUS_STANDBY,
 
4388
+                            cmd->pool, &senv);
 
4389
             /* error handling in case this child can't be created */
 
4390
-            if(tmp)
 
4391
+            if (tmp) {
 
4392
                 return tmp;
 
4393
+            }
 
4394
         }
 
4395
     }
 
4396
-    
 
4397
+
 
4398
     /* use predefined processor environment or default named "user_group_chroot" */
 
4399
-    if(sconf->senv == NULL)
 
4400
+    if (sconf->senv == NULL) {
 
4401
         sconf->senv = find_senv_by_name(processor_name);
 
4402
-    
 
4403
+    }
 
4404
+
 
4405
     if (sconf->senv == NULL) {
 
4406
-        return apr_psprintf(cmd->pool,
 
4407
-                            "Error: Processor %s not defined", name);
 
4408
+        return apr_psprintf(cmd->pool, "Error: Processor %s not defined", name);
 
4409
     }
 
4410
 
 
4411
     _DBG("user=%d group=%d chroot=%s numchilds=%d",
 
4412
-        sconf->senv->uid, sconf->senv->gid, sconf->senv->chroot, NUM_CHILDS);
 
4413
+         sconf->senv->uid, sconf->senv->gid, sconf->senv->chroot, NUM_CHILDS);
 
4414
 
 
4415
     return NULL;
 
4416
 }
 
4417
 
 
4418
-static const char *set_min_free_servers(cmd_parms *cmd, void *dummy, const char *arg)
 
4419
+static const char *set_min_free_servers(cmd_parms *cmd, void *dummy,
 
4420
+                                        const char *arg)
 
4421
 {
 
4422
     const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
 
4423
+
 
4424
     if (err != NULL) {
 
4425
         return err;
 
4426
     }
 
4427
 
 
4428
     ap_min_free_processors = atoi(arg);
 
4429
     if (ap_min_free_processors <= 0) {
 
4430
-       ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 
 
4431
-                    "WARNING: detected MinSpareServers set to non-positive.");
 
4432
-       ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 
 
4433
-                    "Resetting to 1 to avoid almost certain Apache failure.");
 
4434
-       ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 
 
4435
-                    "Please read the documentation.");
 
4436
-       ap_min_free_processors = 1;
 
4437
+        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4438
+                     "WARNING: detected MinSpareServers set to non-positive.");
 
4439
+        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4440
+                     "Resetting to 1 to avoid almost certain Apache failure.");
 
4441
+        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4442
+                     "Please read the documentation.");
 
4443
+        ap_min_free_processors = 1;
 
4444
     }
 
4445
-       
 
4446
+
 
4447
     return NULL;
 
4448
 }
 
4449
 
 
4450
-static const char *set_max_clients (cmd_parms *cmd, void *dummy, const char *arg) 
 
4451
+static const char *set_max_clients(cmd_parms *cmd, void *dummy, const char *arg)
 
4452
 {
 
4453
     const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
 
4454
+
 
4455
     if (err != NULL) {
 
4456
         return err;
 
4457
     }
 
4458
 
 
4459
     ap_daemons_limit = atoi(arg);
 
4460
+
 
4461
     if (ap_daemons_limit > server_limit) {
 
4462
-       ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 
 
4463
-                    "WARNING: MaxClients of %d exceeds ServerLimit value "
 
4464
-                    "of %d servers,", ap_daemons_limit, server_limit);
 
4465
-       ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 
 
4466
-                    " lowering MaxClients to %d.  To increase, please "
 
4467
-                    "see the ServerLimit", server_limit);
 
4468
-       ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4469
-                    " directive.");
 
4470
-       ap_daemons_limit = server_limit;
 
4471
-    } 
 
4472
+        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4473
+                     "WARNING: MaxClients of %d exceeds ServerLimit value "
 
4474
+                     "of %d servers,", ap_daemons_limit, server_limit);
 
4475
+        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4476
+                     " lowering MaxClients to %d.  To increase, please "
 
4477
+                     "see the ServerLimit", server_limit);
 
4478
+        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " directive.");
 
4479
+        ap_daemons_limit = server_limit;
 
4480
+    }
 
4481
     else if (ap_daemons_limit < 1) {
 
4482
-       ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 
 
4483
+        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4484
                      "WARNING: Require MaxClients > 0, setting to 1");
 
4485
-       ap_daemons_limit = 1;
 
4486
+        ap_daemons_limit = 1;
 
4487
     }
 
4488
+
 
4489
     return NULL;
 
4490
 }
 
4491
 
 
4492
-static const char *set_min_processors (cmd_parms *cmd, void *dummy, const char *arg)
 
4493
+static const char *set_min_processors(cmd_parms *cmd, void *dummy,
 
4494
+        const char *arg)
 
4495
 {
 
4496
     peruser_server_conf *sconf;
 
4497
     int min_procs;
 
4498
-    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
 
4499
+    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE
 
4500
+                                           | NOT_IN_LIMIT);
 
4501
 
 
4502
     if (err != NULL) {
 
4503
         return err;
 
4504
@@ -3671,24 +3776,28 @@
 
4505
 
 
4506
     if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) {
 
4507
         sconf = PERUSER_SERVER_CONF(cmd->server->module_config);
 
4508
-        if(sconf->senv != NULL)
 
4509
-                       sconf->senv->min_processors = min_procs;
 
4510
-               else
 
4511
-                       ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4512
-                            "WARNING: MinProcessors must be set after ServerEnvironment to take effect");
 
4513
-    }
 
4514
-    else {
 
4515
+
 
4516
+        if (sconf->senv != NULL) {
 
4517
+            sconf->senv->min_processors = min_procs;
 
4518
+        } else {
 
4519
+            ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4520
+                         "WARNING: MinProcessors must be set"
 
4521
+                         "after ServerEnvironment to take effect");
 
4522
+        }
 
4523
+    } else {
 
4524
         ap_min_processors = min_procs;
 
4525
     }
 
4526
 
 
4527
     return NULL;
 
4528
 }
 
4529
 
 
4530
-static const char *set_min_free_processors (cmd_parms *cmd, void *dummy, const char *arg)
 
4531
+static const char *set_min_free_processors(cmd_parms *cmd, void *dummy,
 
4532
+                                           const char *arg)
 
4533
 {
 
4534
     peruser_server_conf *sconf;
 
4535
     int min_free_procs;
 
4536
-    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
 
4537
+    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE
 
4538
+                                           | NOT_IN_LIMIT);
 
4539
 
 
4540
     if (err != NULL) {
 
4541
         return err;
 
4542
@@ -3704,57 +3813,64 @@
 
4543
 
 
4544
     if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) {
 
4545
         sconf = PERUSER_SERVER_CONF(cmd->server->module_config);
 
4546
-        if(sconf->senv != NULL)
 
4547
-                       sconf->senv->min_free_processors = min_free_procs;
 
4548
-               else
 
4549
-                       ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4550
-                            "WARNING: MinSpareProcessors must be set after ServerEnvironment to take effect");
 
4551
-    }
 
4552
-    else {
 
4553
+        if (sconf->senv != NULL) {
 
4554
+            sconf->senv->min_free_processors = min_free_procs;
 
4555
+        } else {
 
4556
+            ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4557
+                         "WARNING: MinSpareProcessors must be set"
 
4558
+                         "after ServerEnvironment to take effect");
 
4559
+        }
 
4560
+    } else {
 
4561
         ap_min_free_processors = min_free_procs;
 
4562
     }
 
4563
 
 
4564
     return NULL;
 
4565
 }
 
4566
 
 
4567
-static const char *set_max_free_processors (cmd_parms *cmd, void *dummy, const char *arg)
 
4568
+static const char *set_max_free_processors(cmd_parms *cmd, void *dummy,
 
4569
+        const char *arg)
 
4570
 {
 
4571
-     peruser_server_conf *sconf;
 
4572
-     int max_free_procs;
 
4573
-     const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
 
4574
-
 
4575
-     if (err != NULL) {
 
4576
-         return err;
 
4577
-     }
 
4578
-
 
4579
-     max_free_procs = atoi(arg);
 
4580
-
 
4581
-     if (max_free_procs < 0) {
 
4582
-         ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4583
-                      "WARNING: Require MaxSpareProcessors >= 0, setting to 0");
 
4584
-         max_free_procs = 0;
 
4585
-     }
 
4586
-
 
4587
-     if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) {
 
4588
-         sconf = PERUSER_SERVER_CONF(cmd->server->module_config);
 
4589
-                if(sconf!=NULL)
 
4590
-                       sconf->senv->max_free_processors = max_free_procs;
 
4591
-                else
 
4592
-                       ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4593
-                            "WARNING: MaxSpareProcessors must be set after ServerEnvironment to take effect");
 
4594
-     }
 
4595
-     else {
 
4596
-         ap_max_free_processors = max_free_procs;
 
4597
-     }
 
4598
+    peruser_server_conf *sconf;
 
4599
+    int max_free_procs;
 
4600
+    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE
 
4601
+                                           | NOT_IN_LIMIT);
 
4602
+
 
4603
+    if (err != NULL) {
 
4604
+        return err;
 
4605
+    }
 
4606
+
 
4607
+    max_free_procs = atoi(arg);
 
4608
+
 
4609
+    if (max_free_procs < 0) {
 
4610
+        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4611
+                     "WARNING: Require MaxSpareProcessors >= 0, setting to 0");
 
4612
+        max_free_procs = 0;
 
4613
+    }
 
4614
+
 
4615
+    if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) {
 
4616
+        sconf = PERUSER_SERVER_CONF(cmd->server->module_config);
 
4617
+
 
4618
+        if (sconf != NULL) {
 
4619
+            sconf->senv->max_free_processors = max_free_procs;
 
4620
+        } else {
 
4621
+            ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4622
+                         "WARNING: MaxSpareProcessors must be set"
 
4623
+                         "after ServerEnvironment to take effect");
 
4624
+        }
 
4625
+    } else {
 
4626
+        ap_max_free_processors = max_free_procs;
 
4627
+    }
 
4628
 
 
4629
-     return NULL;
 
4630
+    return NULL;
 
4631
 }
 
4632
 
 
4633
-static const char *set_max_processors (cmd_parms *cmd, void *dummy, const char *arg)
 
4634
+static const char *set_max_processors(cmd_parms *cmd, void *dummy,
 
4635
+                                      const char *arg)
 
4636
 {
 
4637
     peruser_server_conf *sconf;
 
4638
     int max_procs;
 
4639
-    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
 
4640
+    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE
 
4641
+                                           | NOT_IN_LIMIT);
 
4642
 
 
4643
     if (err != NULL) {
 
4644
         return err;
 
4645
@@ -3770,23 +3886,26 @@
 
4646
 
 
4647
     if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) {
 
4648
         sconf = PERUSER_SERVER_CONF(cmd->server->module_config);
 
4649
-               if(sconf->senv != NULL)
 
4650
-               sconf->senv->max_processors = max_procs;
 
4651
-               else
 
4652
-                       ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4653
-                            "WARNING: MaxProcessors must be set after ServerEnvironment to take effect");
 
4654
-    }
 
4655
-    else {
 
4656
+        if (sconf->senv != NULL) {
 
4657
+            sconf->senv->max_processors = max_procs;
 
4658
+        } else {
 
4659
+            ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4660
+                                     "WARNING: MaxProcessors must be set"
 
4661
+                                     "after ServerEnvironment to take effect");
 
4662
+        }
 
4663
+    } else {
 
4664
         ap_max_processors = max_procs;
 
4665
     }
 
4666
 
 
4667
     return NULL;
 
4668
 }
 
4669
 
 
4670
-static const char *set_min_multiplexers (cmd_parms *cmd, void *dummy, const char *arg)
 
4671
+static const char *set_min_multiplexers(cmd_parms *cmd, void *dummy,
 
4672
+        const char *arg)
 
4673
 {
 
4674
     int min_multiplexers;
 
4675
-    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
 
4676
+    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE
 
4677
+                                           | NOT_IN_LIMIT);
 
4678
 
 
4679
     if (err != NULL) {
 
4680
         return err;
 
4681
@@ -3805,10 +3924,12 @@
 
4682
     return NULL;
 
4683
 }
 
4684
 
 
4685
-static const char *set_max_multiplexers (cmd_parms *cmd, void *dummy, const char *arg)
 
4686
+static const char *set_max_multiplexers(cmd_parms *cmd, void *dummy,
 
4687
+        const char *arg)
 
4688
 {
 
4689
     int max_multiplexers;
 
4690
-    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
 
4691
+    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE
 
4692
+                                           | NOT_IN_LIMIT);
 
4693
 
 
4694
     if (err != NULL) {
 
4695
         return err;
 
4696
@@ -3827,21 +3948,22 @@
 
4697
     return NULL;
 
4698
 }
 
4699
 
 
4700
-static const char *set_server_limit (cmd_parms *cmd, void *dummy, const char *arg) 
 
4701
+static const char *set_server_limit(cmd_parms *cmd, void *dummy,
 
4702
+        const char *arg)
 
4703
 {
 
4704
     int tmp_server_limit;
 
4705
-    
 
4706
+
 
4707
     const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
 
4708
     if (err != NULL) {
 
4709
         return err;
 
4710
     }
 
4711
 
 
4712
     tmp_server_limit = atoi(arg);
 
4713
+
 
4714
     /* you cannot change ServerLimit across a restart; ignore
 
4715
      * any such attempts
 
4716
      */
 
4717
-    if (first_server_limit &&
 
4718
-        tmp_server_limit != server_limit) {
 
4719
+    if (first_server_limit && tmp_server_limit != server_limit) {
 
4720
         /* how do we log a message?  the error log is a bit bucket at this
 
4721
          * point; we'll just have to set a flag so that ap_mpm_run()
 
4722
          * logs a warning later
 
4723
@@ -3849,25 +3971,28 @@
 
4724
         changed_limit_at_restart = 1;
 
4725
         return NULL;
 
4726
     }
 
4727
+
 
4728
     server_limit = tmp_server_limit;
 
4729
-    
 
4730
+
 
4731
     if (server_limit > MAX_SERVER_LIMIT) {
 
4732
-       ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 
 
4733
-                    "WARNING: ServerLimit of %d exceeds compile time limit "
 
4734
-                    "of %d servers,", server_limit, MAX_SERVER_LIMIT);
 
4735
-       ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 
 
4736
-                    " lowering ServerLimit to %d.", MAX_SERVER_LIMIT);
 
4737
-       server_limit = MAX_SERVER_LIMIT;
 
4738
-    } 
 
4739
-    else if (server_limit < 1) {
 
4740
-       ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 
 
4741
+        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4742
+                     "WARNING: ServerLimit of %d exceeds compile time limit "
 
4743
+                         "of %d servers,", server_limit, MAX_SERVER_LIMIT);
 
4744
+        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4745
+                     " lowering ServerLimit to %d.", MAX_SERVER_LIMIT);
 
4746
+        server_limit = MAX_SERVER_LIMIT;
 
4747
+    } else if (server_limit < 1) {
 
4748
+        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4749
                      "WARNING: Require ServerLimit > 0, setting to 1");
 
4750
-       server_limit = 1;
 
4751
+        server_limit = 1;
 
4752
     }
 
4753
+
 
4754
     return NULL;
 
4755
 }
 
4756
 
 
4757
-static const char *set_expire_timeout (cmd_parms *cmd, void *dummy, const char *arg) {
 
4758
+static const char *set_expire_timeout(cmd_parms *cmd, void *dummy,
 
4759
+                                      const char *arg)
 
4760
+{
 
4761
     const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
 
4762
     if (err != NULL) {
 
4763
         return err;
 
4764
@@ -3878,7 +4003,9 @@
 
4765
     return NULL;
 
4766
 }
 
4767
 
 
4768
-static const char *set_idle_timeout (cmd_parms *cmd, void *dummy, const char *arg) {
 
4769
+static const char *set_idle_timeout(cmd_parms *cmd, void *dummy,
 
4770
+                                    const char *arg)
 
4771
+{
 
4772
     const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
 
4773
     if (err != NULL) {
 
4774
         return err;
 
4775
@@ -3889,7 +4016,9 @@
 
4776
     return NULL;
 
4777
 }
 
4778
 
 
4779
-static const char *set_multiplexer_idle_timeout (cmd_parms *cmd, void *dummy, const char *arg) {
 
4780
+static const char *set_multiplexer_idle_timeout(cmd_parms *cmd, void *dummy,
 
4781
+        const char *arg)
 
4782
+{
 
4783
     const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
 
4784
 
 
4785
     if (err != NULL) {
 
4786
@@ -3901,9 +4030,12 @@
 
4787
     return NULL;
 
4788
 }
 
4789
 
 
4790
-static const char *set_processor_wait_timeout (cmd_parms *cmd, void *dummy, const char *timeout, const char *steps) {
 
4791
+static const char *set_processor_wait_timeout(cmd_parms *cmd, void *dummy,
 
4792
+                                              const char *timeout,
 
4793
+                                              const char *steps)
 
4794
+{
 
4795
     const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
 
4796
-    
 
4797
+
 
4798
     if (err != NULL) {
 
4799
         return err;
 
4800
     }
 
4801
@@ -3915,7 +4047,8 @@
 
4802
 
 
4803
         if (steps_tmp < 1) {
 
4804
             ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
 
4805
-                         "WARNING: Require ProcessorWaitTimeout steps > 0, setting to 1");
 
4806
+                         "WARNING: Require ProcessorWaitTimeout steps > 0,"
 
4807
+                         "setting to 1");
 
4808
             steps_tmp = 1;
 
4809
         }
 
4810
 
 
4811
@@ -3925,8 +4058,7 @@
 
4812
     return NULL;
 
4813
 }
 
4814
 
 
4815
-static const command_rec peruser_cmds[] = {
 
4816
-UNIX_DAEMON_COMMANDS,
 
4817
+static const command_rec peruser_cmds[] = { UNIX_DAEMON_COMMANDS,
 
4818
 LISTEN_COMMANDS,
 
4819
 AP_INIT_TAKE1("MinSpareProcessors", set_min_free_processors, NULL, RSRC_CONF,
 
4820
               "Minimum number of idle children, to handle request spikes"),
 
4821
@@ -3940,8 +4072,9 @@
 
4822
               "Minimum number of processors per vhost"),
 
4823
 AP_INIT_TAKE1("MaxProcessors", set_max_processors, NULL, RSRC_CONF,
 
4824
               "Maximum number of processors per vhost"),
 
4825
+
 
4826
 AP_INIT_TAKE1("MinMultiplexers", set_min_multiplexers, NULL, RSRC_CONF,
 
4827
-              "Minimum number of multiplexers the server can have"),
 
4828
+              "Minimum number of multiplexers the server can have")        ,
 
4829
 AP_INIT_TAKE1("MaxMultiplexers", set_max_multiplexers, NULL, RSRC_CONF,
 
4830
               "Maximum number of multiplexers the server can have"),
 
4831
 AP_INIT_TAKE1("ServerLimit", set_server_limit, NULL, RSRC_CONF,
 
4832
@@ -3949,11 +4082,14 @@
 
4833
 AP_INIT_TAKE1("ExpireTimeout", set_expire_timeout, NULL, RSRC_CONF,
 
4834
               "Maximum time a child can live, 0 to disable"),
 
4835
 AP_INIT_TAKE1("IdleTimeout", set_idle_timeout, NULL, RSRC_CONF,
 
4836
-              "Maximum time before a child is killed after being idle, 0 to disable"),
 
4837
-AP_INIT_TAKE1("MultiplexerIdleTimeout", set_multiplexer_idle_timeout, NULL, RSRC_CONF,
 
4838
-              "Maximum time before a multiplexer is killed after being idle, 0 to disable"),
 
4839
-AP_INIT_TAKE12("ProcessorWaitTimeout", set_processor_wait_timeout, NULL, RSRC_CONF,
 
4840
-              "Maximum time a multiplexer waits for the processor if it is busy"),
 
4841
+              "Maximum time before a child is killed after being idle,"
 
4842
+              "0 to disable"),
 
4843
+AP_INIT_TAKE1("MultiplexerIdleTimeout", set_multiplexer_idle_timeout, NULL,
 
4844
+              RSRC_CONF, "Maximum time before a multiplexer is killed after"
 
4845
+              " being idle, 0 to disable"),
 
4846
+AP_INIT_TAKE12("ProcessorWaitTimeout", set_processor_wait_timeout, NULL,
 
4847
+               RSRC_CONF, "Maximum time a multiplexer waits for the processor"
 
4848
+               " if it is busy"),
 
4849
 AP_INIT_TAKE23("Multiplexer", cf_Multiplexer, NULL, RSRC_CONF,
 
4850
               "Specify an Multiplexer Child configuration."),
 
4851
 AP_INIT_RAW_ARGS("<Processor", cf_Processor, NULL, RSRC_CONF,
 
4852
@@ -3969,11 +4105,11 @@
 
4853
 
 
4854
 module AP_MODULE_DECLARE_DATA mpm_peruser_module = {
 
4855
     MPM20_MODULE_STUFF,
 
4856
-    ap_mpm_rewrite_args,        /* hook to run before apache parses args */
 
4857
-    NULL,                      /* create per-directory config structure */
 
4858
-    NULL,                      /* merge per-directory config structures */
 
4859
-    peruser_create_config,     /* create per-server config structure */
 
4860
-    NULL,                      /* merge per-server config structures */
 
4861
-    peruser_cmds,              /* command apr_table_t */
 
4862
-    peruser_hooks,             /* register hooks */
 
4863
+    ap_mpm_rewrite_args,    /* hook to run before apache parses args */
 
4864
+    NULL,                   /* create per-directory config structure */
 
4865
+    NULL,                   /* merge per-directory config structures */
 
4866
+    peruser_create_config,  /* create per-server config structure */
 
4867
+    NULL,                   /* merge per-server config structures */
 
4868
+    peruser_cmds,           /* command apr_table_t */
 
4869
+    peruser_hooks,          /* register hooks */
 
4870
 };