Gentoo Archives: gentoo-commits

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