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/patches/
Date: Sat, 09 Nov 2013 15:33:23
Message-Id: 1283320143.68a2fd7aef2840ae86779dbb2ce55c0384e1c8ea.polynomial-c@gentoo
1 commit: 68a2fd7aef2840ae86779dbb2ce55c0384e1c8ea
2 Author: Benedikt Boehm <hollow <AT> gentoo <DOT> org>
3 AuthorDate: Wed Sep 1 05:49:03 2010 +0000
4 Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
5 CommitDate: Wed Sep 1 05:49:03 2010 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/apache.git;a=commit;h=68a2fd7a
7
8 dump peruser to 0.4.0-rc1 wrt #294098
9
10 ---
11 ....4.0b1.patch => 20_all_peruser_0.4.0-rc1.patch} | 540 ++++++++++++++-------
12 1 file changed, 367 insertions(+), 173 deletions(-)
13
14 diff --git a/2.2/patches/20_all_peruser_0.4.0b1.patch b/2.2/patches/20_all_peruser_0.4.0-rc1.patch
15 similarity index 92%
16 rename from 2.2/patches/20_all_peruser_0.4.0b1.patch
17 rename to 2.2/patches/20_all_peruser_0.4.0-rc1.patch
18 index 8e30e64..782bab5 100644
19 --- a/2.2/patches/20_all_peruser_0.4.0b1.patch
20 +++ b/2.2/patches/20_all_peruser_0.4.0-rc1.patch
21 @@ -1,6 +1,102 @@
22 -diff -Nur httpd-2.2.13/modules/ssl/mod_ssl.h httpd-2.2.13-peruser/modules/ssl/mod_ssl.h
23 ---- httpd-2.2.13/modules/ssl/mod_ssl.h 2006-07-12 06:38:44.000000000 +0300
24 -+++ httpd-2.2.13-peruser/modules/ssl/mod_ssl.h 2009-09-01 16:19:22.000000000 +0300
25 +diff -ruN httpd-2.2.14/docs/conf/extra/httpd-mpm.conf.in peruser-0.4rc1/docs/conf/extra/httpd-mpm.conf.in
26 +--- httpd-2.2.14/docs/conf/extra/httpd-mpm.conf.in 2007-12-29 04:08:28.000000000 +0100
27 ++++ peruser-0.4rc1/docs/conf/extra/httpd-mpm.conf.in 2009-11-21 21:38:45.000000000 +0100
28 +@@ -27,6 +27,24 @@
29 + # active mpm.
30 + #
31 +
32 ++# peruser MPM
33 ++# IdleTimeout: maximum time before a child is killed after being idle, 0 to disable
34 ++# ExpireTimeout: maximum time a child can live, 0 to disable
35 ++# MinSpareProcessors: minimum number of idle children, to handle request spikes
36 ++# MaxProcessors: Maximum number of processors per vhost
37 ++# ServerLimit: maximum value of MaxClients for this run of Apache
38 ++# MaxClients: maximum number of children alive at the same time
39 ++# MaxMultiplexers: maximum number of multiplexers the server can have
40 ++<IfModule mpm_peruser_module>
41 ++ IdleTimeout 900
42 ++ ExpireTimeout 1800
43 ++ MinSpareProcessors 2
44 ++ MaxProcessors 10
45 ++ ServerLimit 256
46 ++ MaxClients 256
47 ++ MaxMultiplexers 20
48 ++</IfModule>
49 ++
50 + # prefork MPM
51 + # StartServers: number of server processes to start
52 + # MinSpareServers: minimum number of server processes which are kept spare
53 +diff -ruN httpd-2.2.14/modules/generators/mod_status.c peruser-0.4rc1/modules/generators/mod_status.c
54 +--- httpd-2.2.14/modules/generators/mod_status.c 2008-01-02 10:43:52.000000000 +0100
55 ++++ peruser-0.4rc1/modules/generators/mod_status.c 2009-11-21 21:07:28.000000000 +0100
56 +@@ -205,6 +205,7 @@
57 + #define STAT_OPT_REFRESH 0
58 + #define STAT_OPT_NOTABLE 1
59 + #define STAT_OPT_AUTO 2
60 ++#define STAT_OPT_STATS 3
61 +
62 + struct stat_opt {
63 + int id;
64 +@@ -217,6 +218,7 @@
65 + {STAT_OPT_REFRESH, "refresh", "Refresh"},
66 + {STAT_OPT_NOTABLE, "notable", NULL},
67 + {STAT_OPT_AUTO, "auto", NULL},
68 ++ {STAT_OPT_STATS, "stats", NULL},
69 + {STAT_OPT_END, NULL, NULL}
70 + };
71 +
72 +@@ -241,6 +243,7 @@
73 + #endif
74 + int short_report;
75 + int no_table_report;
76 ++ int stats_report;
77 + worker_score *ws_record;
78 + process_score *ps_record;
79 + char *stat_buffer;
80 +@@ -268,7 +271,8 @@
81 + kbcount = 0;
82 + short_report = 0;
83 + no_table_report = 0;
84 +-
85 ++ stats_report=0;
86 ++
87 + pid_buffer = apr_palloc(r->pool, server_limit * sizeof(pid_t));
88 + stat_buffer = apr_palloc(r->pool, server_limit * thread_limit * sizeof(char));
89 +
90 +@@ -312,6 +316,9 @@
91 + case STAT_OPT_NOTABLE:
92 + no_table_report = 1;
93 + break;
94 ++ case STAT_OPT_STATS:
95 ++ stats_report = 1;
96 ++ break;
97 + case STAT_OPT_AUTO:
98 + ap_set_content_type(r, "text/plain; charset=ISO-8859-1");
99 + short_report = 1;
100 +@@ -819,7 +826,8 @@
101 + int flags =
102 + (short_report ? AP_STATUS_SHORT : 0) |
103 + (no_table_report ? AP_STATUS_NOTABLE : 0) |
104 +- (ap_extended_status ? AP_STATUS_EXTENDED : 0);
105 ++ (ap_extended_status ? AP_STATUS_EXTENDED : 0) |
106 ++ (stats_report ? AP_STATUS_STATS : 0);
107 +
108 + ap_run_status_hook(r, flags);
109 + }
110 +diff -ruN httpd-2.2.14/modules/generators/mod_status.h peruser-0.4rc1/modules/generators/mod_status.h
111 +--- httpd-2.2.14/modules/generators/mod_status.h 2006-07-12 05:38:44.000000000 +0200
112 ++++ peruser-0.4rc1/modules/generators/mod_status.h 2009-11-21 21:07:28.000000000 +0100
113 +@@ -32,6 +32,7 @@
114 + #define AP_STATUS_SHORT (0x1) /* short, non-HTML report requested */
115 + #define AP_STATUS_NOTABLE (0x2) /* HTML report without tables */
116 + #define AP_STATUS_EXTENDED (0x4) /* detailed report */
117 ++#define AP_STATUS_STATS (0x8) /* extended user statistics report */
118 +
119 + #if !defined(WIN32)
120 + #define STATUS_DECLARE(type) type
121 +diff -ruN httpd-2.2.14/modules/ssl/mod_ssl.h peruser-0.4rc1/modules/ssl/mod_ssl.h
122 +--- httpd-2.2.14/modules/ssl/mod_ssl.h 2006-07-12 05:38:44.000000000 +0200
123 ++++ peruser-0.4rc1/modules/ssl/mod_ssl.h 2009-11-21 14:29:17.000000000 +0100
124 @@ -50,6 +50,10 @@
125 * is using SSL/TLS. */
126 APR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *));
127 @@ -12,9 +108,9 @@ diff -Nur httpd-2.2.13/modules/ssl/mod_ssl.h httpd-2.2.13-peruser/modules/ssl/mo
128 /** The ssl_proxy_enable() and ssl_engine_disable() optional functions
129 * are used by mod_proxy to enable use of SSL for outgoing
130 * connections. */
131 -diff -Nur httpd-2.2.13/modules/ssl/ssl_engine_vars.c httpd-2.2.13-peruser/modules/ssl/ssl_engine_vars.c
132 ---- httpd-2.2.13/modules/ssl/ssl_engine_vars.c 2009-08-06 10:28:47.000000000 +0300
133 -+++ httpd-2.2.13-peruser/modules/ssl/ssl_engine_vars.c 2009-09-01 16:19:22.000000000 +0300
134 +diff -ruN httpd-2.2.14/modules/ssl/ssl_engine_vars.c peruser-0.4rc1/modules/ssl/ssl_engine_vars.c
135 +--- httpd-2.2.14/modules/ssl/ssl_engine_vars.c 2009-09-06 13:19:05.000000000 +0200
136 ++++ peruser-0.4rc1/modules/ssl/ssl_engine_vars.c 2009-11-21 14:33:56.000000000 +0100
137 @@ -58,6 +58,12 @@
138 return sslconn && sslconn->ssl;
139 }
140 @@ -36,9 +132,9 @@ diff -Nur httpd-2.2.13/modules/ssl/ssl_engine_vars.c httpd-2.2.13-peruser/module
141 APR_REGISTER_OPTIONAL_FN(ssl_var_lookup);
142 APR_REGISTER_OPTIONAL_FN(ssl_ext_lookup);
143
144 -diff -Nur httpd-2.2.13/server/mpm/config.m4 httpd-2.2.13-peruser/server/mpm/config.m4
145 ---- httpd-2.2.13/server/mpm/config.m4 2005-10-30 19:05:26.000000000 +0200
146 -+++ httpd-2.2.13-peruser/server/mpm/config.m4 2009-09-01 16:19:22.000000000 +0300
147 +diff -ruN httpd-2.2.14/server/mpm/config.m4 peruser-0.4rc1/server/mpm/config.m4
148 +--- httpd-2.2.14/server/mpm/config.m4 2005-10-30 18:05:26.000000000 +0100
149 ++++ peruser-0.4rc1/server/mpm/config.m4 2009-11-21 14:29:17.000000000 +0100
150 @@ -1,7 +1,7 @@
151 AC_MSG_CHECKING(which MPM to use)
152 AC_ARG_WITH(mpm,
153 @@ -57,9 +153,9 @@ diff -Nur httpd-2.2.13/server/mpm/config.m4 httpd-2.2.13-peruser/server/mpm/conf
154 return 0
155 else
156 return 1
157 -diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/AUTHORS httpd-2.2.13-peruser/server/mpm/experimental/peruser/AUTHORS
158 ---- httpd-2.2.13/server/mpm/experimental/peruser/AUTHORS 1970-01-01 03:00:00.000000000 +0300
159 -+++ httpd-2.2.13-peruser/server/mpm/experimental/peruser/AUTHORS 2009-09-01 16:19:22.000000000 +0300
160 +diff -ruN httpd-2.2.14/server/mpm/experimental/peruser/AUTHORS peruser-0.4rc1/server/mpm/experimental/peruser/AUTHORS
161 +--- httpd-2.2.14/server/mpm/experimental/peruser/AUTHORS 1970-01-01 01:00:00.000000000 +0100
162 ++++ peruser-0.4rc1/server/mpm/experimental/peruser/AUTHORS 2009-11-21 14:29:17.000000000 +0100
163 @@ -0,0 +1,11 @@
164 +Enrico Weigelt <weigelt [at] metux.de> (MetuxMPM maintainer)
165 +Sean Gabriel Heacock <gabriel [at] telana.com> (Peruser maintainer)
166 @@ -72,25 +168,136 @@ diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/AUTHORS httpd-2.2.13-peru
167 +Steve Amerige <mpm [at] fatbear.com>
168 +Stefan Klingner <stefan.klingner [at] mephisto23.com> (Peruser maintainer)
169 +Michal Grzedzicki <lazy404 [at] gmail.com>
170 -diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/config.m4 httpd-2.2.13-peruser/server/mpm/experimental/peruser/config.m4
171 ---- httpd-2.2.13/server/mpm/experimental/peruser/config.m4 1970-01-01 03:00:00.000000000 +0300
172 -+++ httpd-2.2.13-peruser/server/mpm/experimental/peruser/config.m4 2009-09-01 16:19:22.000000000 +0300
173 -@@ -0,0 +1,3 @@
174 -+if test "$MPM_NAME" = "peruser" ; then
175 -+ APACHE_FAST_OUTPUT(server/mpm/experimental/$MPM_NAME/Makefile)
176 -+fi
177 -diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/Makefile.in httpd-2.2.13-peruser/server/mpm/experimental/peruser/Makefile.in
178 ---- httpd-2.2.13/server/mpm/experimental/peruser/Makefile.in 1970-01-01 03:00:00.000000000 +0300
179 -+++ httpd-2.2.13-peruser/server/mpm/experimental/peruser/Makefile.in 2009-09-01 16:19:22.000000000 +0300
180 +diff -ruN httpd-2.2.14/server/mpm/experimental/peruser/Makefile.in peruser-0.4rc1/server/mpm/experimental/peruser/Makefile.in
181 +--- httpd-2.2.14/server/mpm/experimental/peruser/Makefile.in 1970-01-01 01:00:00.000000000 +0100
182 ++++ peruser-0.4rc1/server/mpm/experimental/peruser/Makefile.in 2009-11-21 14:29:17.000000000 +0100
183 @@ -0,0 +1,5 @@
184 +
185 +LTLIBRARY_NAME = libperuser.la
186 +LTLIBRARY_SOURCES = peruser.c
187 +
188 +include $(top_srcdir)/build/ltlib.mk
189 -diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/mpm_default.h httpd-2.2.13-peruser/server/mpm/experimental/peruser/mpm_default.h
190 ---- httpd-2.2.13/server/mpm/experimental/peruser/mpm_default.h 1970-01-01 03:00:00.000000000 +0300
191 -+++ httpd-2.2.13-peruser/server/mpm/experimental/peruser/mpm_default.h 2009-09-01 16:19:22.000000000 +0300
192 +diff -ruN httpd-2.2.14/server/mpm/experimental/peruser/config.m4 peruser-0.4rc1/server/mpm/experimental/peruser/config.m4
193 +--- httpd-2.2.14/server/mpm/experimental/peruser/config.m4 1970-01-01 01:00:00.000000000 +0100
194 ++++ peruser-0.4rc1/server/mpm/experimental/peruser/config.m4 2009-11-21 14:29:17.000000000 +0100
195 +@@ -0,0 +1,3 @@
196 ++if test "$MPM_NAME" = "peruser" ; then
197 ++ APACHE_FAST_OUTPUT(server/mpm/experimental/$MPM_NAME/Makefile)
198 ++fi
199 +diff -ruN httpd-2.2.14/server/mpm/experimental/peruser/mpm.h peruser-0.4rc1/server/mpm/experimental/peruser/mpm.h
200 +--- httpd-2.2.14/server/mpm/experimental/peruser/mpm.h 1970-01-01 01:00:00.000000000 +0100
201 ++++ peruser-0.4rc1/server/mpm/experimental/peruser/mpm.h 2009-11-21 21:10:39.000000000 +0100
202 +@@ -0,0 +1,107 @@
203 ++/* ====================================================================
204 ++ * The Apache Software License, Version 1.1
205 ++ *
206 ++ * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
207 ++ * reserved.
208 ++ *
209 ++ * Redistribution and use in source and binary forms, with or without
210 ++ * modification, are permitted provided that the following conditions
211 ++ * are met:
212 ++ *
213 ++ * 1. Redistributions of source code must retain the above copyright
214 ++ * notice, this list of conditions and the following disclaimer.
215 ++ *
216 ++ * 2. Redistributions in binary form must reproduce the above copyright
217 ++ * notice, this list of conditions and the following disclaimer in
218 ++ * the documentation and/or other materials provided with the
219 ++ * distribution.
220 ++ *
221 ++ * 3. The end-user documentation included with the redistribution,
222 ++ * if any, must include the following acknowledgment:
223 ++ * "This product includes software developed by the
224 ++ * Apache Software Foundation (http://www.apache.org/)."
225 ++ * Alternately, this acknowledgment may appear in the software itself,
226 ++ * if and wherever such third-party acknowledgments normally appear.
227 ++ *
228 ++ * 4. The names "Apache" and "Apache Software Foundation" must
229 ++ * not be used to endorse or promote products derived from this
230 ++ * software without prior written permission. For written
231 ++ * permission, please contact apache@××××××.org.
232 ++ *
233 ++ * 5. Products derived from this software may not be called "Apache",
234 ++ * nor may "Apache" appear in their name, without prior written
235 ++ * permission of the Apache Software Foundation.
236 ++ *
237 ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
238 ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
239 ++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
240 ++ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
241 ++ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
242 ++ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
243 ++ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
244 ++ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
245 ++ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
246 ++ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
247 ++ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
248 ++ * SUCH DAMAGE.
249 ++ * ====================================================================
250 ++ *
251 ++ * This software consists of voluntary contributions made by many
252 ++ * individuals on behalf of the Apache Software Foundation. For more
253 ++ * information on the Apache Software Foundation, please see
254 ++ * <http://www.apache.org/>.
255 ++ *
256 ++ * Portions of this software are based upon public domain software
257 ++ * originally written at the National Center for Supercomputing Applications,
258 ++ * University of Illinois, Urbana-Champaign.
259 ++ */
260 ++
261 ++#include "httpd.h"
262 ++#include "mpm_default.h"
263 ++#include "scoreboard.h"
264 ++#include "unixd.h"
265 ++
266 ++#ifndef APACHE_MPM_PERUSER_H
267 ++#define APACHE_MPM_PERUSER_H
268 ++
269 ++#define PERUSER_MPM
270 ++
271 ++#define MPM_NAME "Peruser"
272 ++
273 ++#define AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
274 ++#define AP_MPM_WANT_WAIT_OR_TIMEOUT
275 ++#define AP_MPM_WANT_PROCESS_CHILD_STATUS
276 ++#define AP_MPM_WANT_SET_PIDFILE
277 ++#define AP_MPM_WANT_SET_SCOREBOARD
278 ++#define AP_MPM_WANT_SET_LOCKFILE
279 ++#define AP_MPM_WANT_SET_MAX_REQUESTS
280 ++#define AP_MPM_WANT_SET_COREDUMPDIR
281 ++#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
282 ++#define AP_MPM_WANT_SIGNAL_SERVER
283 ++#define AP_MPM_WANT_SET_MAX_MEM_FREE
284 ++#define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
285 ++
286 ++#define AP_MPM_USES_POD 1
287 ++#define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
288 ++#define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0)
289 ++#define MPM_VALID_PID(p) (getpgid(p) == getpgrp())
290 ++#define MPM_ACCEPT_FUNC unixd_accept
291 ++
292 ++extern int ap_threads_per_child;
293 ++extern int ap_max_daemons_limit;
294 ++extern server_rec *ap_server_conf;
295 ++
296 ++/* Table of child status */
297 ++#define SERVER_DEAD 0
298 ++#define SERVER_DYING 1
299 ++#define SERVER_ALIVE 2
300 ++
301 ++typedef struct ap_ctable {
302 ++ pid_t pid;
303 ++ unsigned char status;
304 ++} ap_ctable;
305 ++
306 ++static const char* child_clone();
307 ++
308 ++
309 ++#endif /* APACHE_MPM_PERUSER_H */
310 +diff -ruN httpd-2.2.14/server/mpm/experimental/peruser/mpm_default.h peruser-0.4rc1/server/mpm/experimental/peruser/mpm_default.h
311 +--- httpd-2.2.14/server/mpm/experimental/peruser/mpm_default.h 1970-01-01 01:00:00.000000000 +0100
312 ++++ peruser-0.4rc1/server/mpm/experimental/peruser/mpm_default.h 2009-11-21 14:29:17.000000000 +0100
313 @@ -0,0 +1,162 @@
314 +/* ====================================================================
315 + * The Apache Software License, Version 1.1
316 @@ -254,118 +461,10 @@ diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/mpm_default.h httpd-2.2.1
317 +#endif
318 +
319 +#endif /* AP_MPM_DEFAULT_H */
320 -diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/mpm.h httpd-2.2.13-peruser/server/mpm/experimental/peruser/mpm.h
321 ---- httpd-2.2.13/server/mpm/experimental/peruser/mpm.h 1970-01-01 03:00:00.000000000 +0300
322 -+++ httpd-2.2.13-peruser/server/mpm/experimental/peruser/mpm.h 2009-09-01 16:19:22.000000000 +0300
323 -@@ -0,0 +1,104 @@
324 -+/* ====================================================================
325 -+ * The Apache Software License, Version 1.1
326 -+ *
327 -+ * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
328 -+ * reserved.
329 -+ *
330 -+ * Redistribution and use in source and binary forms, with or without
331 -+ * modification, are permitted provided that the following conditions
332 -+ * are met:
333 -+ *
334 -+ * 1. Redistributions of source code must retain the above copyright
335 -+ * notice, this list of conditions and the following disclaimer.
336 -+ *
337 -+ * 2. Redistributions in binary form must reproduce the above copyright
338 -+ * notice, this list of conditions and the following disclaimer in
339 -+ * the documentation and/or other materials provided with the
340 -+ * distribution.
341 -+ *
342 -+ * 3. The end-user documentation included with the redistribution,
343 -+ * if any, must include the following acknowledgment:
344 -+ * "This product includes software developed by the
345 -+ * Apache Software Foundation (http://www.apache.org/)."
346 -+ * Alternately, this acknowledgment may appear in the software itself,
347 -+ * if and wherever such third-party acknowledgments normally appear.
348 -+ *
349 -+ * 4. The names "Apache" and "Apache Software Foundation" must
350 -+ * not be used to endorse or promote products derived from this
351 -+ * software without prior written permission. For written
352 -+ * permission, please contact apache@××××××.org.
353 -+ *
354 -+ * 5. Products derived from this software may not be called "Apache",
355 -+ * nor may "Apache" appear in their name, without prior written
356 -+ * permission of the Apache Software Foundation.
357 -+ *
358 -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
359 -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
360 -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
361 -+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
362 -+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
363 -+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
364 -+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
365 -+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
366 -+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
367 -+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
368 -+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
369 -+ * SUCH DAMAGE.
370 -+ * ====================================================================
371 -+ *
372 -+ * This software consists of voluntary contributions made by many
373 -+ * individuals on behalf of the Apache Software Foundation. For more
374 -+ * information on the Apache Software Foundation, please see
375 -+ * <http://www.apache.org/>.
376 -+ *
377 -+ * Portions of this software are based upon public domain software
378 -+ * originally written at the National Center for Supercomputing Applications,
379 -+ * University of Illinois, Urbana-Champaign.
380 -+ */
381 -+
382 -+#include "httpd.h"
383 -+#include "mpm_default.h"
384 -+#include "scoreboard.h"
385 -+#include "unixd.h"
386 -+
387 -+#ifndef APACHE_MPM_PERUSER_H
388 -+#define APACHE_MPM_PERUSER_H
389 -+
390 -+#define PERUSER_MPM
391 -+
392 -+#define MPM_NAME "Peruser"
393 -+
394 -+#define AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
395 -+#define AP_MPM_WANT_WAIT_OR_TIMEOUT
396 -+#define AP_MPM_WANT_PROCESS_CHILD_STATUS
397 -+#define AP_MPM_WANT_SET_PIDFILE
398 -+#define AP_MPM_WANT_SET_SCOREBOARD
399 -+#define AP_MPM_WANT_SET_LOCKFILE
400 -+#define AP_MPM_WANT_SET_MAX_REQUESTS
401 -+#define AP_MPM_WANT_SET_COREDUMPDIR
402 -+#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
403 -+#define AP_MPM_WANT_SIGNAL_SERVER
404 -+#define AP_MPM_WANT_SET_MAX_MEM_FREE
405 -+#define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
406 -+
407 -+#define AP_MPM_USES_POD 1
408 -+#define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
409 -+#define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0)
410 -+#define MPM_VALID_PID(p) (getpgid(p) == getpgrp())
411 -+#define MPM_ACCEPT_FUNC unixd_accept
412 -+
413 -+extern int ap_threads_per_child;
414 -+extern int ap_max_daemons_limit;
415 -+extern server_rec *ap_server_conf;
416 -+
417 -+/* Table of child status */
418 -+#define SERVER_DEAD 0
419 -+#define SERVER_DYING 1
420 -+#define SERVER_ALIVE 2
421 -+
422 -+typedef struct ap_ctable {
423 -+ pid_t pid;
424 -+ unsigned char status;
425 -+} ap_ctable;
426 -+
427 -+#endif /* APACHE_MPM_PERUSER_H */
428 -diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/peruser.c httpd-2.2.13-peruser/server/mpm/experimental/peruser/peruser.c
429 ---- httpd-2.2.13/server/mpm/experimental/peruser/peruser.c 1970-01-01 03:00:00.000000000 +0300
430 -+++ httpd-2.2.13-peruser/server/mpm/experimental/peruser/peruser.c 2009-09-10 11:52:39.000000000 +0300
431 -@@ -0,0 +1,3884 @@
432 +diff -ruN httpd-2.2.14/server/mpm/experimental/peruser/peruser.c peruser-0.4rc1/server/mpm/experimental/peruser/peruser.c
433 +--- httpd-2.2.14/server/mpm/experimental/peruser/peruser.c 1970-01-01 01:00:00.000000000 +0100
434 ++++ peruser-0.4rc1/server/mpm/experimental/peruser/peruser.c 2009-11-21 22:02:27.000000000 +0100
435 +@@ -0,0 +1,3979 @@
436 +
437 +/* ====================================================================
438 + * The Apache Software License, Version 1.1
439 @@ -1278,6 +1377,35 @@ diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/peruser.c httpd-2.2.13-pe
440 + return total;
441 +}
442 +
443 ++static int active_processors(int child_num)
444 ++{
445 ++ int i, total;
446 ++
447 ++ for(i = 0, total = 0; i < NUM_CHILDS; ++i)
448 ++ {
449 ++ if( (CHILD_INFO_TABLE[i].senv == CHILD_INFO_TABLE[child_num].senv) && (CHILD_INFO_TABLE[i].pid > 0 ) )
450 ++ total++;
451 ++ }
452 ++
453 ++ return total;
454 ++}
455 ++
456 ++static int active_env_processors(int env_num)
457 ++{
458 ++ int i, total;
459 ++
460 ++ if(env_num >= NUM_SENV)
461 ++ return -1;
462 ++
463 ++ for(i = 0, total = 0; i < NUM_CHILDS; ++i)
464 ++ {
465 ++ if((CHILD_INFO_TABLE[i].senv == &SENV[env_num]) && (CHILD_INFO_TABLE[i].pid > 0))
466 ++ total++;
467 ++ }
468 ++
469 ++ return total;
470 ++}
471 ++
472 +static int idle_processors(int child_num)
473 +{
474 + int i, total;
475 @@ -1294,6 +1422,20 @@ diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/peruser.c httpd-2.2.13-pe
476 + return total;
477 +}
478 +
479 ++static int idle_env_processors(int env_num)
480 ++{
481 ++ int i, total;
482 ++
483 ++ for(i = 0, total = 0; i < NUM_CHILDS; ++i)
484 ++ {
485 ++ if(CHILD_INFO_TABLE[i].senv == &SENV[env_num] && (CHILD_INFO_TABLE[i].status == CHILD_STATUS_READY) )
486 ++ total++;
487 ++ }
488 ++
489 ++ return total;
490 ++}
491 ++
492 ++
493 +static int wait_for_workers(child_info_t *processor) {
494 + int i, wait_step_size, wait_time;
495 +
496 @@ -1469,7 +1611,7 @@ diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/peruser.c httpd-2.2.13-pe
497 + child_info_t *processor;
498 + apr_pool_t *ptrans;
499 + peruser_server_conf *sconf;
500 -+ int ssl_on;
501 ++ int ssl_on = 0;
502 +
503 + _DBG("Creating dummy connection to use the vhost lookup api", 0);
504 +
505 @@ -1481,12 +1623,11 @@ diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/peruser.c httpd-2.2.13-pe
506 + ap_update_vhost_given_ip(current_conn);
507 + _DBG("Base server is %s, name based vhosts %s", current_conn->base_server->server_hostname,
508 + current_conn->vhost_lookup_data ? "on" : "off");
509 ++
510 ++ // check for ssl configuration for this server (ssl_server_is_https is NULL if we have no mod_ssl)
511 ++ if(ssl_server_is_https) ssl_on = ssl_server_is_https(current_conn->base_server);
512 + }
513 +
514 -+ // check for ssl configuration for this server (ssl_server_is_https is NULL if we have no mod_ssl)
515 -+ if(ssl_server_is_https) ssl_on = ssl_server_is_https(current_conn->base_server);
516 -+ else ssl_on = 0;
517 -+
518 + if (current_conn && (!current_conn->vhost_lookup_data || ssl_on) && CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER) {
519 + _DBG("We are not using name based vhosts (or SSL is enabled), we'll directly pass the socket.");
520 +
521 @@ -2128,8 +2269,6 @@ diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/peruser.c httpd-2.2.13-pe
522 + return APR_SUCCESS;
523 +}
524 +
525 -+static const char* child_clone();
526 -+
527 +static void child_main(int child_num_arg)
528 +{
529 + apr_pool_t *ptrans;
530 @@ -2997,6 +3136,7 @@ diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/peruser.c httpd-2.2.13-pe
531 + }
532 +
533 + perform_idle_server_maintenance(pconf);
534 ++
535 +#ifdef TPF
536 + shutdown_pending = os_check_server(tpf_server_name);
537 + ap_check_signals();
538 @@ -3407,7 +3547,7 @@ diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/peruser.c httpd-2.2.13-pe
539 + senv.chroot = multiplexer_chroot;
540 + senv.cgroup = NULL;
541 + senv.nice_lvl = 0;
542 -+ senv.name = NULL;
543 ++ senv.name = "Multiplexer";
544 +
545 + senv.min_processors = ap_min_multiplexers;
546 + senv.min_free_processors = ap_min_free_processors;
547 @@ -3565,6 +3705,12 @@ diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/peruser.c httpd-2.2.13-pe
548 + return OK;
549 +}
550 +
551 ++
552 ++int senv_active_cmp(const void *a, const void *b) {
553 ++ _DBG("CMP %d %d", *(int *) a,*(int *) b);
554 ++ return active_env_processors(*(int *)a)<active_env_processors(*(int *)b);
555 ++}
556 ++
557 +static int peruser_status_hook(request_rec *r, int flags)
558 +{
559 + int x;
560 @@ -3572,45 +3718,77 @@ diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/peruser.c httpd-2.2.13-pe
561 +
562 + if (flags & AP_STATUS_SHORT)
563 + return OK;
564 -+
565 ++
566 ++
567 ++ if (flags & AP_STATUS_STATS) {
568 ++
569 ++ int *sorted_senv;
570 ++ int i;
571 ++ sorted_senv=(int *) apr_palloc(r->pool, NUM_SENV*sizeof(int));
572 ++
573 ++ if(!sorted_senv) {
574 ++ ap_rputs("peruser_status_hook(): Out of memory",r);
575 ++ return OK;
576 ++ }
577 ++ /* Initial senv table */
578 ++ for(i=0; i < NUM_SENV; i++)
579 ++ sorted_senv[i]=i;
580 ++
581 ++ /* sort env by number of processors */
582 ++ qsort(sorted_senv, NUM_SENV, sizeof(int), senv_active_cmp);
583 ++
584 ++ ap_rputs("<h3>Processors statistics:</h3><table border=\"0\"><tr><th>Environment</th><th>Pss</th><th>Avail</th></tr>", r);
585 ++ /* 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 */
586 ++ for (x = 0; x < NUM_SENV; x++)
587 ++ {
588 ++ senv = &SENV[sorted_senv[x]];
589 ++ if(senv==NULL)
590 ++ continue;
591 ++ ap_rprintf(r, "<tr><td nowrap>%s</td><td nowrap>%d/%d/%d</td>"
592 ++ "<td>%d%%</td></tr>",
593 ++ senv == NULL ? NULL : ( senv->name == NULL ? "" : senv->name ),
594 ++ active_env_processors(sorted_senv[x]), idle_env_processors(sorted_senv[x]), senv == NULL ? 0 : senv->max_processors,
595 ++ senv == NULL ? 0 : senv->availability );
596 ++ }
597 ++ ap_rputs("</table><tr/>", r);
598 ++
599 ++ ap_rputs("<hr/><table>"
600 ++ "<tr><th>Pss</th><td>Number of processors active/idle/max</td></tr>"
601 ++ "</table><hr/>",r);
602 ++ }else {
603 + ap_rputs("<hr>\n", r);
604 -+ ap_rputs("<h2>peruser status</h2>\n", r);
605 ++ ap_rputs("<h3>peruser status</h3>\n", r);
606 + ap_rputs("<table border=\"0\">\n", r);
607 -+ ap_rputs("<tr><td>ID</td><td>PID</td><td>STATUS</td><td>SB STATUS</td><td>TYPE</td><td>UID</td>"
608 -+ "<td>GID</td><td>CHROOT</td><td>NICE</td><td>INPUT</td>"
609 -+ "<td>OUTPUT</td><td>SOCK_FD</td>"
610 -+ "<td>TOTAL PROCESSORS</td><td>MAX PROCESSORS</td>"
611 -+ "<td>IDLE PROCESSORS</td><td>MIN FREE PROCESSORS</td>"
612 -+ "<td>AVAIL</td>"
613 ++ ap_rputs("<tr><th>ID</th><th>PID</th><th>STATUS</th><th>SB STATUS</th><th>Type</th><th>Processor</th>"
614 ++ "<th>Pss</th>"
615 ++ "<th>AVAIL</th>"
616 + "</tr>\n", r);
617 + for (x = 0; x < NUM_CHILDS; x++)
618 + {
619 + senv = CHILD_INFO_TABLE[x].senv;
620 -+ ap_rprintf(r, "<tr><td>%3d</td><td>%5d</td><td>%8s</td><td>%8s</td><td>%12s</td>"
621 -+ "<td>%4d</td><td>%4d</td><td>%25s</td><td>%3d</td><td>%5d</td>"
622 -+ "<td>%6d</td><td>%7d</td><td>%d</td><td>%d</td>"
623 -+ "<td>%d</td><td>%d</td><td>%3d</td></tr>\n",
624 ++ ap_rprintf(r, "<tr><td>%3d</td><td>%5d</td><td>%8s</td><td>%8s</td><td>%12s</td><td nowrap>%48s</td>"
625 ++ "<td>%d/%d/%d</td>"
626 ++ "<td>%3d%%</td></tr>\n",
627 + CHILD_INFO_TABLE[x].id,
628 + CHILD_INFO_TABLE[x].pid,
629 + child_status_string(CHILD_INFO_TABLE[x].status),
630 + scoreboard_status_string(SCOREBOARD_STATUS(x)),
631 + child_type_string(CHILD_INFO_TABLE[x].type),
632 -+ senv == NULL ? -1 : senv->uid,
633 -+ senv == NULL ? -1 : senv->gid,
634 -+ senv == NULL ? NULL : senv->chroot,
635 -+ senv == NULL ? 0 : senv->nice_lvl,
636 -+ senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->input,
637 -+ senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->output,
638 -+ CHILD_INFO_TABLE[x].sock_fd,
639 -+ total_processors(x),
640 -+ senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->max_processors,
641 ++ senv == NULL ? NULL : ( senv->name == NULL ? "" : senv->name ),
642 ++ active_processors(x),
643 + idle_processors(x),
644 -+ senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->min_free_processors,
645 -+ senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->availability
646 ++ senv == NULL ? 0 : CHILD_INFO_TABLE[x].senv->max_processors,
647 ++ senv == NULL ? 0 : CHILD_INFO_TABLE[x].senv->availability
648 + );
649 + }
650 + ap_rputs("</table>\n", r);
651 -+
652 ++
653 ++ ap_rputs("<hr/><table>"
654 ++ "<tr><th>STATUS</th><td>Processor status</td></tr>"
655 ++ "<tr><th>Pss</th><td>Number of processors active/idle/max</td></tr>"
656 ++ "</table><hr/>",r);
657 ++ }
658 ++
659 + if (grace_children > 0) {
660 + ap_rputs("<h2>peruser graceful children status</h2>\n", r);
661 + ap_rprintf(r, "%d of total %d still living<br />\n", grace_children_alive, grace_children);
662 @@ -3960,7 +4138,11 @@ diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/peruser.c httpd-2.2.13-pe
663 +
664 + if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) {
665 + sconf = PERUSER_SERVER_CONF(cmd->server->module_config);
666 -+ sconf->senv->min_processors = min_procs;
667 ++ if(sconf->senv != NULL)
668 ++ sconf->senv->min_processors = min_procs;
669 ++ else
670 ++ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
671 ++ "WARNING: MinProcessors must be set after ServerEnvironment to take effect");
672 + }
673 + else {
674 + ap_min_processors = min_procs;
675 @@ -3989,7 +4171,11 @@ diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/peruser.c httpd-2.2.13-pe
676 +
677 + if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) {
678 + sconf = PERUSER_SERVER_CONF(cmd->server->module_config);
679 -+ sconf->senv->min_free_processors = min_free_procs;
680 ++ if(sconf->senv != NULL)
681 ++ sconf->senv->min_free_processors = min_free_procs;
682 ++ else
683 ++ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
684 ++ "WARNING: MinSpareProcessors must be set after ServerEnvironment to take effect");
685 + }
686 + else {
687 + ap_min_free_processors = min_free_procs;
688 @@ -4018,7 +4204,11 @@ diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/peruser.c httpd-2.2.13-pe
689 +
690 + if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) {
691 + sconf = PERUSER_SERVER_CONF(cmd->server->module_config);
692 -+ sconf->senv->max_free_processors = max_free_procs;
693 ++ if(sconf!=NULL)
694 ++ sconf->senv->max_free_processors = max_free_procs;
695 ++ else
696 ++ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
697 ++ "WARNING: MaxSpareProcessors must be set after ServerEnvironment to take effect");
698 + }
699 + else {
700 + ap_max_free_processors = max_free_procs;
701 @@ -4047,7 +4237,11 @@ diff -Nur httpd-2.2.13/server/mpm/experimental/peruser/peruser.c httpd-2.2.13-pe
702 +
703 + if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) {
704 + sconf = PERUSER_SERVER_CONF(cmd->server->module_config);
705 -+ sconf->senv->max_processors = max_procs;
706 ++ if(sconf->senv != NULL)
707 ++ sconf->senv->max_processors = max_procs;
708 ++ else
709 ++ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
710 ++ "WARNING: MaxProcessors must be set after ServerEnvironment to take effect");
711 + }
712 + else {
713 + ap_max_processors = max_procs;