diff options
author | rene <rene@FreeBSD.org> | 2017-07-01 21:58:04 +0000 |
---|---|---|
committer | rene <rene@FreeBSD.org> | 2017-07-01 21:58:04 +0000 |
commit | 094ca1c6b1c65a677d478fd6c8befbee75677d48 (patch) | |
tree | 32ab83feca1ff00f3ffc6ca981a488aff0386969 | |
parent | d1df8d5559638e8cbd2b0d8fff7db32ef6153862 (diff) | |
download | FreeBSD-ports-094ca1c6b1c65a677d478fd6c8befbee75677d48.zip FreeBSD-ports-094ca1c6b1c65a677d478fd6c8befbee75677d48.tar.gz |
Remove expired ports:
2017-06-30 misc/p5-Geo-Coder-Many: deprecated and no longer maintained by upstream
2017-07-01 graphics/gimp-elsamuko-script: Broken for more than 2 years
2017-07-01 devel/anjuta-extras: Last release in 2013 and doesn't build with recent GTK+
2017-07-01 www/apache22-worker-mpm: Upstream propose EoL of apache 2.2.x during the next 12 months
2017-07-01 www/apache22-itk-mpm: Upstream propose EoL of apache 2.2.x during the next 12 months
2017-07-01 www/apache22-peruser-mpm: Upstream propose EoL of apache 2.2.x during the next 12 months
2017-07-01 www/apache22-event-mpm: Upstream propose EoL of apache 2.2.x during the next 12 months
34 files changed, 7 insertions, 7788 deletions
@@ -9447,3 +9447,10 @@ net/sixxs-aiccu||2017-06-25|Has expired: SixXS shutdown on 2017-06-06, https://w databases/pgpoolAdmin||2017-06-25|Removed, depended on expired databases/pgpool-II and only supported PostgreSQL 9.2 which is will EOL in September 2017 sysutils/syslog-ng-devel|sysutils/syslog-ng310|2017-06-28|Balabit's syslog-ng team has switched to a rolling release model now print/axpoint|print/p5-XML-Handler-AxPoint|2017-06-30|Rename to match CPAN naming +misc/p5-Geo-Coder-Many||2017-07-01|Has expired: deprecated and no longer maintained by upstream +graphics/gimp-elsamuko-script||2017-07-01|Has expired: Broken for more than 2 years +devel/anjuta-extras||2017-07-01|Has expired: Last release in 2013 and doesn't build with recent GTK+ +www/apache22-worker-mpm||2017-07-01|Has expired: Upstream propose EoL of apache 2.2.x during the next 12 months +www/apache22-itk-mpm||2017-07-01|Has expired: Upstream propose EoL of apache 2.2.x during the next 12 months +www/apache22-peruser-mpm||2017-07-01|Has expired: Upstream propose EoL of apache 2.2.x during the next 12 months +www/apache22-event-mpm||2017-07-01|Has expired: Upstream propose EoL of apache 2.2.x during the next 12 months diff --git a/devel/Makefile b/devel/Makefile index e3de2af..7452841 100644 --- a/devel/Makefile +++ b/devel/Makefile @@ -91,7 +91,6 @@ SUBDIR += android-tools-fastboot-devel SUBDIR += android-tools-simpleperf SUBDIR += anjuta - SUBDIR += anjuta-extras SUBDIR += antlr SUBDIR += antlr3 SUBDIR += antlr4 diff --git a/devel/anjuta-extras/Makefile b/devel/anjuta-extras/Makefile deleted file mode 100644 index e29706b..0000000 --- a/devel/anjuta-extras/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -# Created by: Koop Mast <kwm@FreeBSD.org> -# $FreeBSD$ - -PORTNAME= anjuta-extras -PORTVERSION= 3.10.0 -CATEGORIES= devel -MASTER_SITES= GNOME - -MAINTAINER= gnome@FreeBSD.org -COMMENT= Extra anjuta 3 plugins - -BUILD_DEPENDS= itstool:textproc/itstool -LIB_DEPENDS= libanjuta-3.so:devel/anjuta - -BROKEN= Does not build with GTK+ 3.22 -DEPRECATED= Last release in 2013 and doesn't build with recent GTK+ -EXPIRATION_DATE=2017-07-01 - -USES= gettext gmake libtool pkgconfig tar:xz -USE_LDCONFIG= yes -GNU_CONFIGURE= yes -USE_GNOME= gtk30 intltool libxml2 -CPPFLAGS+= -I${LOCALBASE}/include -LDFLAGS+= -L${LOCALBASE}/lib -INSTALL_TARGET= install-strip - -GLIB_SCHEMAS= org.gnome.anjuta.plugins.scintilla.gschema.xml \ - org.gnome.anjuta.plugins.scratchbox.gschema.xml - -post-patch: - @${REINPLACE_CMD} -e 's|return style_data|return|g' \ - ${WRKSRC}/plugins/scintilla/style-editor.c - -.include <bsd.port.mk> diff --git a/devel/anjuta-extras/distinfo b/devel/anjuta-extras/distinfo deleted file mode 100644 index a6670d2..0000000 --- a/devel/anjuta-extras/distinfo +++ /dev/null @@ -1,2 +0,0 @@ -SHA256 (anjuta-extras-3.10.0.tar.xz) = 92f92e3c530f5649edfe4d8645e8cfd3161383cbc486c636ebb24cf2d2642213 -SIZE (anjuta-extras-3.10.0.tar.xz) = 1905256 diff --git a/devel/anjuta-extras/files/patch-plugins_scintilla_aneditor.cxx b/devel/anjuta-extras/files/patch-plugins_scintilla_aneditor.cxx deleted file mode 100644 index 8461959..0000000 --- a/devel/anjuta-extras/files/patch-plugins_scintilla_aneditor.cxx +++ /dev/null @@ -1,22 +0,0 @@ -From 959807c25e3547b019448b0877bae54dd6c04a9d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=A9bastien=20Granjoux?= <seb.sfo@free.fr> -Date: Mon, 11 Nov 2013 10:51:05 +0100 -Subject: bgo #711771 - The edge-column variable is not taken into account by - anjuta for scintilla editor - - -diff --git a/plugins/scintilla/aneditor.cxx b/plugins/scintilla/aneditor.cxx -index 0fa9acc..d61e4e1 100644 ---- plugins/scintilla/aneditor.cxx -+++ plugins/scintilla/aneditor.cxx -@@ -2656,7 +2656,6 @@ void AnEditor::ReadProperties(const char *fileForExt, char **typedef_hl) { - int visibleLines = props->GetInt("visible.policy.lines"); - SendEditor(SCI_SETVISIBLEPOLICY, visibleStrict | visibleSlop, visibleLines); - -- SendEditor(SCI_SETEDGECOLUMN, props->GetInt("edge.column", 0)); - SendEditor(SCI_SETEDGEMODE, props->GetInt("edge.mode", EDGE_NONE)); - SendEditor(SCI_SETEDGECOLOUR, - ColourOfProperty(props, "edge.colour", ColourDesired(0xff, 0xda, 0xda))); --- -cgit v0.10.1 - diff --git a/devel/anjuta-extras/files/patch-plugins_scintilla_properties_styles.properties b/devel/anjuta-extras/files/patch-plugins_scintilla_properties_styles.properties deleted file mode 100644 index 6820dbf..0000000 --- a/devel/anjuta-extras/files/patch-plugins_scintilla_properties_styles.properties +++ /dev/null @@ -1,25 +0,0 @@ -From 088d3da478e876836efb386bfafd0b23c0de8d82 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=A9bastien=20Granjoux?= <seb.sfo@free.fr> -Date: Sat, 9 Nov 2013 22:34:18 +0100 -Subject: cintilla: bgo #690373 - The syntax-highlighting for Gtk types does - not work from version 3.x - - -diff --git a/plugins/scintilla/properties/styles.properties b/plugins/scintilla/properties/styles.properties -index 6d6e455..3e5331f 100644 ---- plugins/scintilla/properties/styles.properties -+++ plugins/scintilla/properties/styles.properties -@@ -8222,8 +8222,8 @@ keywords.$(file.patterns.yaml)=true false yes no - style.cpp.17=$(style.anjuta.comment) - # Comment keyword error - style.cpp.18=$(style.anjuta.comment) --# Libraries symbols --#style.cpp.19=$(style.anjuta.syskeyword) -+# Libraries symbols (needed to highlight library functions by example GTK+) -+ style.cpp.19=$(style.anjuta.syskeyword) - # Raw strings for C++0x - style.cpp.20=$(style.anjuta.string) - # Triple-quoted strings for Vala --- -cgit v0.10.1 - diff --git a/devel/anjuta-extras/files/patch-plugins_scintilla_scintilla_src_SplitVector.h b/devel/anjuta-extras/files/patch-plugins_scintilla_scintilla_src_SplitVector.h deleted file mode 100644 index 227c71e..0000000 --- a/devel/anjuta-extras/files/patch-plugins_scintilla_scintilla_src_SplitVector.h +++ /dev/null @@ -1,11 +0,0 @@ ---- plugins/scintilla/scintilla/src/SplitVector.h.orig 2015-06-10 20:14:00.051095000 -0400 -+++ plugins/scintilla/scintilla/src/SplitVector.h 2015-06-10 20:20:33.371490000 -0400 -@@ -9,6 +9,8 @@ - #ifndef SPLITVECTOR_H - #define SPLITVECTOR_H - -+#include <algorithm> -+ - template <typename T> - class SplitVector { - protected: diff --git a/devel/anjuta-extras/pkg-descr b/devel/anjuta-extras/pkg-descr deleted file mode 100644 index 5c0d446..0000000 --- a/devel/anjuta-extras/pkg-descr +++ /dev/null @@ -1,3 +0,0 @@ -Extra plugins for the Anjuta IDE. - -WWW: http://anjuta.org/ diff --git a/devel/anjuta-extras/pkg-plist b/devel/anjuta-extras/pkg-plist deleted file mode 100644 index 9c10f69..0000000 --- a/devel/anjuta-extras/pkg-plist +++ /dev/null @@ -1,87 +0,0 @@ -lib/anjuta/anjuta-editor.plugin -lib/anjuta/anjuta-sample.plugin -lib/anjuta/anjuta-scratchbox.plugin -lib/anjuta/libanjuta-editor.a -lib/anjuta/libanjuta-editor.so -lib/anjuta/libanjuta-sample.a -lib/anjuta/libanjuta-sample.so -lib/anjuta/libanjuta-scratchbox.a -lib/anjuta/libanjuta-scratchbox.so -share/anjuta/glade/anjuta-editor-scintilla.ui -share/anjuta/glade/anjuta-scratchbox-panel.png -share/anjuta/glade/anjuta-scratchbox.ui -share/anjuta/properties/anjuta.properties -share/anjuta/properties/styles.properties -share/anjuta/properties/user.properties -share/anjuta/ui/anjuta-sample.ui -share/anjuta/ui/anjuta-scintilla.xml -share/help/C/anjuta-manual/scintilla-plugin.page -share/help/de/anjuta-manual/scintilla-plugin.page -share/locale/ar/LC_MESSAGES/anjuta-extras.mo -share/locale/az/LC_MESSAGES/anjuta-extras.mo -share/locale/be@latin/LC_MESSAGES/anjuta-extras.mo -share/locale/bg/LC_MESSAGES/anjuta-extras.mo -share/locale/ca/LC_MESSAGES/anjuta-extras.mo -share/locale/ca@valencia/LC_MESSAGES/anjuta-extras.mo -share/locale/cs/LC_MESSAGES/anjuta-extras.mo -share/locale/da/LC_MESSAGES/anjuta-extras.mo -share/locale/de/LC_MESSAGES/anjuta-extras.mo -share/locale/dz/LC_MESSAGES/anjuta-extras.mo -share/locale/el/LC_MESSAGES/anjuta-extras.mo -share/locale/en_CA/LC_MESSAGES/anjuta-extras.mo -share/locale/en_GB/LC_MESSAGES/anjuta-extras.mo -share/locale/eo/LC_MESSAGES/anjuta-extras.mo -share/locale/es/LC_MESSAGES/anjuta-extras.mo -share/locale/eu/LC_MESSAGES/anjuta-extras.mo -share/locale/fi/LC_MESSAGES/anjuta-extras.mo -share/locale/fr/LC_MESSAGES/anjuta-extras.mo -share/locale/ga/LC_MESSAGES/anjuta-extras.mo -share/locale/gl/LC_MESSAGES/anjuta-extras.mo -share/locale/gu/LC_MESSAGES/anjuta-extras.mo -share/locale/he/LC_MESSAGES/anjuta-extras.mo -share/locale/hi/LC_MESSAGES/anjuta-extras.mo -share/locale/hr/LC_MESSAGES/anjuta-extras.mo -share/locale/hu/LC_MESSAGES/anjuta-extras.mo -share/locale/id/LC_MESSAGES/anjuta-extras.mo -share/locale/it/LC_MESSAGES/anjuta-extras.mo -share/locale/ja/LC_MESSAGES/anjuta-extras.mo -share/locale/kn/LC_MESSAGES/anjuta-extras.mo -share/locale/ko/LC_MESSAGES/anjuta-extras.mo -share/locale/lt/LC_MESSAGES/anjuta-extras.mo -share/locale/lv/LC_MESSAGES/anjuta-extras.mo -share/locale/mk/LC_MESSAGES/anjuta-extras.mo -share/locale/ml/LC_MESSAGES/anjuta-extras.mo -share/locale/mr/LC_MESSAGES/anjuta-extras.mo -share/locale/ms/LC_MESSAGES/anjuta-extras.mo -share/locale/nb/LC_MESSAGES/anjuta-extras.mo -share/locale/ne/LC_MESSAGES/anjuta-extras.mo -share/locale/nl/LC_MESSAGES/anjuta-extras.mo -share/locale/oc/LC_MESSAGES/anjuta-extras.mo -share/locale/or/LC_MESSAGES/anjuta-extras.mo -share/locale/pa/LC_MESSAGES/anjuta-extras.mo -share/locale/pl/LC_MESSAGES/anjuta-extras.mo -share/locale/pt/LC_MESSAGES/anjuta-extras.mo -share/locale/pt_BR/LC_MESSAGES/anjuta-extras.mo -share/locale/ro/LC_MESSAGES/anjuta-extras.mo -share/locale/ru/LC_MESSAGES/anjuta-extras.mo -share/locale/rw/LC_MESSAGES/anjuta-extras.mo -share/locale/si/LC_MESSAGES/anjuta-extras.mo -share/locale/sk/LC_MESSAGES/anjuta-extras.mo -share/locale/sl/LC_MESSAGES/anjuta-extras.mo -share/locale/sq/LC_MESSAGES/anjuta-extras.mo -share/locale/sr/LC_MESSAGES/anjuta-extras.mo -share/locale/sr@latin/LC_MESSAGES/anjuta-extras.mo -share/locale/sv/LC_MESSAGES/anjuta-extras.mo -share/locale/te/LC_MESSAGES/anjuta-extras.mo -share/locale/th/LC_MESSAGES/anjuta-extras.mo -share/locale/tr/LC_MESSAGES/anjuta-extras.mo -share/locale/uk/LC_MESSAGES/anjuta-extras.mo -share/locale/vi/LC_MESSAGES/anjuta-extras.mo -share/locale/zh_CN/LC_MESSAGES/anjuta-extras.mo -share/locale/zh_HK/LC_MESSAGES/anjuta-extras.mo -share/locale/zh_TW/LC_MESSAGES/anjuta-extras.mo -share/pixmaps/anjuta/anjuta-editor-scintilla-plugin-48.png -share/pixmaps/anjuta/anjuta-editor-scintilla-plugin.svg -share/pixmaps/anjuta/anjuta-sample-plugin-48.png -share/pixmaps/anjuta/anjuta-sample-plugin.svg -share/pixmaps/anjuta/anjuta-scratchbox-48.png diff --git a/graphics/Makefile b/graphics/Makefile index cbb4fc6..bc81c58 100644 --- a/graphics/Makefile +++ b/graphics/Makefile @@ -249,7 +249,6 @@ SUBDIR += gimp-app SUBDIR += gimp-beautify-plugin SUBDIR += gimp-data-extras - SUBDIR += gimp-elsamuko-script SUBDIR += gimp-ez-perspective-plugin SUBDIR += gimp-focusblur-plugin SUBDIR += gimp-gmic-plugin diff --git a/graphics/gimp-elsamuko-script/Makefile b/graphics/gimp-elsamuko-script/Makefile deleted file mode 100644 index 0912b85..0000000 --- a/graphics/gimp-elsamuko-script/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# Created by: Mario Sergio Fujikawa Ferreira <lioux@FreeBSD.org> -# $FreeBSD$ - -PORTNAME= elsamuko -DISTVERSION= 0.24 -PORTREVISION= 2 -CATEGORIES= graphics -MASTER_SITES= https://github.com/site/${PORTNAME}/gimp-${PORTNAME}/archive/ -PKGNAMEPREFIX= gimp- -PKGNAMESUFFIX= -script -DISTNAME= ${PORTNAME} - -MAINTAINER= ports@FreeBSD.org -COMMENT= Gimp scripts by elsamuko - -LICENSE= GPLv3 - -BROKEN= Unfetchable -DEPRECATED= Broken for more than 2 years -EXPIRATION_DATE= 2017-07-01 - -RUN_DEPENDS= ${LOCALBASE}/bin/gimp:graphics/gimp-app - -OPTIONS_DEFINE= DOCS - -USES= zip -NO_BUILD= yes -NO_ARCH= yes - -GIMP_SCRIPTS_DIR?= share/gimp/scripts - -# installation dir -PLIST_SUB= GIMP_SCRIPTS_DIR=${GIMP_SCRIPTS_DIR} - -# installed docs -PORTDOCS= * - -do-install: - (cd ${WRKSRC} && ${COPYTREE_SHARE} \*.scm \ - ${STAGEDIR}${PREFIX}/${GIMP_SCRIPTS_DIR}) - -# install docs -do-install-DOCS-on: - ${MKDIR} ${STAGEDIR}${DOCSDIR} - ${INSTALL_DATA} ${WRKSRC}/z_README ${STAGEDIR}${DOCSDIR} - -.include <bsd.port.mk> diff --git a/graphics/gimp-elsamuko-script/distinfo b/graphics/gimp-elsamuko-script/distinfo deleted file mode 100644 index 7f65dd1..0000000 --- a/graphics/gimp-elsamuko-script/distinfo +++ /dev/null @@ -1,2 +0,0 @@ -SHA256 (elsamuko.zip) = b71a7241044ce12dd0c85b64fd50067220943579c3dbaf3967be303fc017da9b -SIZE (elsamuko.zip) = 75893 diff --git a/graphics/gimp-elsamuko-script/pkg-descr b/graphics/gimp-elsamuko-script/pkg-descr deleted file mode 100644 index 7bed3d7..0000000 --- a/graphics/gimp-elsamuko-script/pkg-descr +++ /dev/null @@ -1,24 +0,0 @@ -GIMP scripts by elsamuko. - -Effects: - -- Lomo -- Sprocket Hole -- Technicolor 2 Color -- Technicolor 3 Color -- Antique Photo Border -- First Photo Border -- National Geographic -- Split Tone With Edge Detection -- Film Grain -- Obama "Hope" -- Che Guevara -- Vintage Look -- White Balance Puzzle -- Gimp Octave -- Photochrom -- Movie 300 - -Read about these and other effects at the following location. - -WWW: https://sites.google.com/site/elsamuko/gimp diff --git a/graphics/gimp-elsamuko-script/pkg-plist b/graphics/gimp-elsamuko-script/pkg-plist deleted file mode 100644 index 3afa35c..0000000 --- a/graphics/gimp-elsamuko-script/pkg-plist +++ /dev/null @@ -1,28 +0,0 @@ -%%GIMP_SCRIPTS_DIR%%/elsamuko-antique-border.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-che-guevara.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-color-tint.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-cyanotype.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-difference-layers.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-erosion-sharpen.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-error-level-analysis.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-escape-lines.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-glass-displacement.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-grain.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-lomo-batch.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-lomo.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-movie-300.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-national-geographic-batch.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-national-geographic.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-obama-hope.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-photo-border.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-photochrom-batch.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-photochrom.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-rainy-landscape.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-slide-with-sprockets.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-sunny-landscape.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-technicolor-2-color-batch.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-technicolor-2-color.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-technicolor-3-color.scm -%%GIMP_SCRIPTS_DIR%%/elsamuko-wb-puzzle.scm -%%GIMP_SCRIPTS_DIR%%/mm1-vintage-look.scm -%%GIMP_SCRIPTS_DIR%%/tuxcomputers-split-tone.scm diff --git a/misc/Makefile b/misc/Makefile index 267a74b..e368139 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -316,7 +316,6 @@ SUBDIR += p5-Geo-Coder-Bing SUBDIR += p5-Geo-Coder-Google SUBDIR += p5-Geo-Coder-Googlev3 - SUBDIR += p5-Geo-Coder-Many SUBDIR += p5-Geo-Coder-Mapquest SUBDIR += p5-Geo-Coder-Multimap SUBDIR += p5-Geo-Coder-Multiple diff --git a/misc/p5-Geo-Coder-Many/Makefile b/misc/p5-Geo-Coder-Many/Makefile deleted file mode 100644 index e65fb0a..0000000 --- a/misc/p5-Geo-Coder-Many/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# Created by: Sunpoet Po-Chuan Hsieh <sunpoet@FreeBSD.org> -# $FreeBSD$ - -PORTNAME= Geo-Coder-Many -PORTVERSION= 0.47 -CATEGORIES= misc geography perl5 -MASTER_SITES= CPAN -PKGNAMEPREFIX= p5- - -MAINTAINER= sunpoet@FreeBSD.org -COMMENT= Module to tie together multiple Geo::Coder::* modules - -LICENSE= ART10 GPLv1 -LICENSE_COMB= dual - -BUILD_DEPENDS= p5-Geo-Coder-Bing>=0.10:misc/p5-Geo-Coder-Bing \ - p5-Geo-Coder-Googlev3>=0.07:misc/p5-Geo-Coder-Googlev3 \ - p5-Geo-Coder-Mapquest>=0.05:misc/p5-Geo-Coder-Mapquest \ - p5-Geo-Coder-Multimap>=0.01:misc/p5-Geo-Coder-Multimap \ - p5-Geo-Coder-OSM>=0.01:misc/p5-Geo-Coder-OSM \ - p5-Geo-Coder-OpenCage>=0.02:misc/p5-Geo-Coder-OpenCage \ - p5-Geo-Distance-XS>=0.08:math/p5-Geo-Distance-XS \ - p5-HTTP-Message>=5.827:www/p5-HTTP-Message \ - p5-List-MoreUtils>=0.22:lang/p5-List-MoreUtils \ - p5-List-Util-WeightedRoundRobin>=0.4:misc/p5-List-Util-WeightedRoundRobin \ - p5-Sort-Versions>=1.5:devel/p5-Sort-Versions -RUN_DEPENDS:= ${BUILD_DEPENDS} -TEST_DEPENDS= p5-Test-Exception>=0:devel/p5-Test-Exception \ - p5-Test-MockObject>=0:devel/p5-Test-MockObject \ - p5-Test-Pod-Coverage>=0:devel/p5-Test-Pod-Coverage - -DEPRECATED= deprecated and no longer maintained by upstream -EXPIRATION_DATE=2017-06-30 - -NO_ARCH= yes -USE_PERL5= configure -USES= perl5 - -.include <bsd.port.mk> diff --git a/misc/p5-Geo-Coder-Many/distinfo b/misc/p5-Geo-Coder-Many/distinfo deleted file mode 100644 index f63d8e9..0000000 --- a/misc/p5-Geo-Coder-Many/distinfo +++ /dev/null @@ -1,3 +0,0 @@ -TIMESTAMP = 1485872737 -SHA256 (Geo-Coder-Many-0.47.tar.gz) = ce3cefe506fe606181437f46b33808c087b7f0661a5d99017d10f4cfa3474282 -SIZE (Geo-Coder-Many-0.47.tar.gz) = 32110 diff --git a/misc/p5-Geo-Coder-Many/pkg-descr b/misc/p5-Geo-Coder-Many/pkg-descr deleted file mode 100644 index 4e1ad1c..0000000 --- a/misc/p5-Geo-Coder-Many/pkg-descr +++ /dev/null @@ -1,9 +0,0 @@ -Geo::Coder::Many provides a single interface to different remote (ie HTTP based) -geocoding modules - -Amongst other things, Geo::Coder::Many adds geocoder precision information, -alternative scheduling methods (weighted random, and ordered list), timeouts for -geocoders which are failing, and optional callbacks for result filtering and -picking. - -WWW: http://search.cpan.org/dist/Geo-Coder-Many/ diff --git a/misc/p5-Geo-Coder-Many/pkg-plist b/misc/p5-Geo-Coder-Many/pkg-plist deleted file mode 100644 index 58254b4..0000000 --- a/misc/p5-Geo-Coder-Many/pkg-plist +++ /dev/null @@ -1,30 +0,0 @@ -%%SITE_PERL%%/Geo/Coder/Many.pm -%%SITE_PERL%%/Geo/Coder/Many/Bing.pm -%%SITE_PERL%%/Geo/Coder/Many/Generic.pm -%%SITE_PERL%%/Geo/Coder/Many/Googlev3.pm -%%SITE_PERL%%/Geo/Coder/Many/Mapquest.pm -%%SITE_PERL%%/Geo/Coder/Many/OSM.pm -%%SITE_PERL%%/Geo/Coder/Many/OpenCage.pm -%%SITE_PERL%%/Geo/Coder/Many/Response.pm -%%SITE_PERL%%/Geo/Coder/Many/Scheduler.pm -%%SITE_PERL%%/Geo/Coder/Many/Scheduler/OrderedList.pm -%%SITE_PERL%%/Geo/Coder/Many/Scheduler/Selective.pm -%%SITE_PERL%%/Geo/Coder/Many/Scheduler/UniquenessScheduler.pm -%%SITE_PERL%%/Geo/Coder/Many/Scheduler/UniquenessScheduler/WRR.pm -%%SITE_PERL%%/Geo/Coder/Many/Scheduler/UniquenessScheduler/WeightedRandom.pm -%%SITE_PERL%%/Geo/Coder/Many/Util.pm -%%PERL5_MAN3%%/Geo::Coder::Many.3.gz -%%PERL5_MAN3%%/Geo::Coder::Many::Bing.3.gz -%%PERL5_MAN3%%/Geo::Coder::Many::Generic.3.gz -%%PERL5_MAN3%%/Geo::Coder::Many::Googlev3.3.gz -%%PERL5_MAN3%%/Geo::Coder::Many::Mapquest.3.gz -%%PERL5_MAN3%%/Geo::Coder::Many::OSM.3.gz -%%PERL5_MAN3%%/Geo::Coder::Many::OpenCage.3.gz -%%PERL5_MAN3%%/Geo::Coder::Many::Response.3.gz -%%PERL5_MAN3%%/Geo::Coder::Many::Scheduler.3.gz -%%PERL5_MAN3%%/Geo::Coder::Many::Scheduler::OrderedList.3.gz -%%PERL5_MAN3%%/Geo::Coder::Many::Scheduler::Selective.3.gz -%%PERL5_MAN3%%/Geo::Coder::Many::Scheduler::UniquenessScheduler.3.gz -%%PERL5_MAN3%%/Geo::Coder::Many::Scheduler::UniquenessScheduler::WRR.3.gz -%%PERL5_MAN3%%/Geo::Coder::Many::Scheduler::UniquenessScheduler::WeightedRandom.3.gz -%%PERL5_MAN3%%/Geo::Coder::Many::Util.3.gz diff --git a/www/Makefile b/www/Makefile index d564337..f7dfbbd 100644 --- a/www/Makefile +++ b/www/Makefile @@ -23,10 +23,6 @@ SUBDIR += apache-forrest SUBDIR += apache-mode.el SUBDIR += apache22 - SUBDIR += apache22-event-mpm - SUBDIR += apache22-itk-mpm - SUBDIR += apache22-peruser-mpm - SUBDIR += apache22-worker-mpm SUBDIR += apache24 SUBDIR += apercu SUBDIR += aria2 diff --git a/www/apache22-event-mpm/Makefile b/www/apache22-event-mpm/Makefile deleted file mode 100644 index f2d5f7d..0000000 --- a/www/apache22-event-mpm/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD$ - -MASTERDIR= ${.CURDIR}/../apache22 - -MAINTAINER= apache@FreeBSD.org - -WITH_MPM= event - -DESCR= ${.CURDIR}/pkg-descr - -PORT_OPTIONS+= CGID -OPTIONS_EXCLUDE= CGI - -.include "${MASTERDIR}/Makefile" diff --git a/www/apache22-event-mpm/pkg-descr b/www/apache22-event-mpm/pkg-descr deleted file mode 100644 index 5365f35..0000000 --- a/www/apache22-event-mpm/pkg-descr +++ /dev/null @@ -1,3 +0,0 @@ -Apache 2.2 with the event MPM enabled. - -WWW: http://httpd.apache.org/ diff --git a/www/apache22-itk-mpm/Makefile b/www/apache22-itk-mpm/Makefile deleted file mode 100644 index baf8403..0000000 --- a/www/apache22-itk-mpm/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# $FreeBSD$ - -# To build this port with the additional mpm-itk-perdir-regex -# patch use -DWITH_ITK_PERDIR_REGEX -# -# To build this port with the additional mpm-itk-limits -# patch use -DWITH_ITK_LIMITS -# -# Note: -# It's not possible to use both patches together -# -# For a quick description take a look into the mpm-itk* patches -# in the files directory - -MASTERDIR= ${.CURDIR}/../apache22 - -MAINTAINER= apache@FreeBSD.org - -WITH_MPM= itk - -DESCR= ${.CURDIR}/pkg-descr - -MPM_ITK_VERSION?= 20110321-01 - -EXTRA_PATCHES+= ${.CURDIR}/files/mpm-itk-${MPM_ITK_VERSION} - -.if defined (WITH_ITK_PERDIR_REGEX) && defined (WITH_ITK_LIMITS) -IGNORE= use only one patch option not both (WITH_ITK_PERDIR_REGEX or WITH_ITK_LIMITS) -.endif - -.if defined (WITH_ITK_PERDIR_REGEX) -EXTRA_PATCHES+= ${.CURDIR}/files/mpm-itk-perdir-regex -.endif - -.if defined (WITH_ITK_LIMITS) -EXTRA_PATCHES+= ${.CURDIR}/files/mpm-itk-limits -.endif - -.include "${MASTERDIR}/Makefile" diff --git a/www/apache22-itk-mpm/files/mpm-itk-20110321-01 b/www/apache22-itk-mpm/files/mpm-itk-20110321-01 deleted file mode 100644 index 45f79a4..0000000 --- a/www/apache22-itk-mpm/files/mpm-itk-20110321-01 +++ /dev/null @@ -1,2112 +0,0 @@ -vim: syntax=diff - -Monolithic mpm-itk patch version 2.2.17-01 updated 2011-03-21 - -The Apache 2 ITK MPM - -apache2-mpm-itk (just mpm-itk for short) is an MPM (Multi-Processing Module) -for the Apache web server. mpm-itk allows you to run each of your vhost -under a separate uid and gid . in short, the scripts and configuration files -for one vhost no longer have to be readable for all the other vhosts. - -mpm-itk is based on the traditional prefork MPM, which means it's -non-threaded; in short, this means you can run non-thread-aware code (like -many PHP extensions) without problems. On the other hand, you lose out to -any performance benefit you'd get with threads, of course; you'd have to -decide for yourself if that's worth it or not. You will also take an -additional performance hit over prefork, since there's an extra fork per -request. - -Licensing: - mpm-itk is licensed under the Apache License, version 2.0, - like the rest of Apache. - -For more Informations and Instructions please visit the official webpage. - -WWW: http://mpm-itk.sesse.net/ - -=========================================================================== -unchanged: ---- server/mpm/experimental/itk/Makefile.in -+++ server/mpm/experimental/itk/Makefile.in -@@ -0,0 +1,5 @@ -+ -+LTLIBRARY_NAME = libitk.la -+LTLIBRARY_SOURCES = itk.c -+ -+include $(top_srcdir)/build/ltlib.mk -unchanged: ---- server/mpm/experimental/itk/config.m4 -+++ server/mpm/experimental/itk/config.m4 -@@ -0,0 +1,3 @@ -+if test "$MPM_NAME" = "itk" ; then -+ APACHE_FAST_OUTPUT(server/mpm/$MPM_SUBDIR_NAME/Makefile) -+fi -unchanged: ---- server/mpm/experimental/itk/itk.c -+++ server/mpm/experimental/itk/itk.c -@@ -0,0 +1,1757 @@ -+/* Licensed to the Apache Software Foundation (ASF) under one or more -+ * contributor license agreements. See the NOTICE file distributed with -+ * this work for additional information regarding copyright ownership. -+ * The ASF licenses this file to You under the Apache License, Version 2.0 -+ * (the "License"); you may not use this file except in compliance with -+ * the License. You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ * -+ * Portions copyright 2005-2009 Steinar H. Gunderson <sgunderson@bigfoot.com>. -+ * Licensed under the same terms as the rest of Apache. -+ * -+ * Portions copyright 2008 Knut Auvor Grythe <knut@auvor.no>. -+ * Licensed under the same terms as the rest of Apache. -+ */ -+ -+#include "apr.h" -+#include "apr_portable.h" -+#include "apr_strings.h" -+#include "apr_thread_proc.h" -+#include "apr_signal.h" -+ -+# define _DBG(text,par...) \ -+ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, \ -+ "(itkmpm: pid=%d uid=%d, gid=%d) %s(): " text, \ -+ getpid(), getuid(), getgid(), __FUNCTION__, par) -+ -+#define APR_WANT_STDIO -+#define APR_WANT_STRFUNC -+#include "apr_want.h" -+ -+#if APR_HAVE_UNISTD_H -+#include <unistd.h> -+#endif -+#if APR_HAVE_SYS_TYPES_H -+#include <sys/types.h> -+#endif -+ -+#define CORE_PRIVATE -+ -+#include "ap_config.h" -+#include "httpd.h" -+#include "mpm_default.h" -+#include "http_main.h" -+#include "http_log.h" -+#include "http_config.h" -+#include "http_core.h" /* for get_remote_host */ -+#include "http_connection.h" -+#include "http_request.h" /* for ap_hook_post_perdir_config */ -+#include "scoreboard.h" -+#include "ap_mpm.h" -+#include "unixd.h" -+#include "mpm_common.h" -+#include "ap_listen.h" -+#include "ap_mmn.h" -+#include "apr_poll.h" -+ -+#ifdef HAVE_BSTRING_H -+#include <bstring.h> /* for IRIX, FD_SET calls bzero() */ -+#endif -+#ifdef HAVE_TIME_H -+#include <time.h> -+#endif -+#ifdef HAVE_SYS_PROCESSOR_H -+#include <sys/processor.h> /* for bindprocessor() */ -+#endif -+ -+#if HAVE_LIBCAP -+#include <sys/capability.h> -+#endif -+ -+#include <signal.h> -+#include <sys/times.h> -+ -+/* Limit on the total --- clients will be locked out if more servers than -+ * this are needed. It is intended solely to keep the server from crashing -+ * when things get out of hand. -+ * -+ * We keep a hard maximum number of servers, for two reasons --- first off, -+ * in case something goes seriously wrong, we want to stop the fork bomb -+ * short of actually crashing the machine we're running on by filling some -+ * kernel table. Secondly, it keeps the size of the scoreboard file small -+ * enough that we can read the whole thing without worrying too much about -+ * the overhead. -+ */ -+#ifndef DEFAULT_SERVER_LIMIT -+#define DEFAULT_SERVER_LIMIT 256 -+#endif -+ -+/* Admin can't tune ServerLimit beyond MAX_SERVER_LIMIT. We want -+ * some sort of compile-time limit to help catch typos. -+ */ -+#ifndef MAX_SERVER_LIMIT -+#define MAX_SERVER_LIMIT 200000 -+#endif -+ -+#ifndef HARD_THREAD_LIMIT -+#define HARD_THREAD_LIMIT 1 -+#endif -+ -+/* config globals */ -+ -+int ap_threads_per_child=0; /* Worker threads per child */ -+static apr_proc_mutex_t *accept_mutex; -+static int ap_daemons_to_start=0; -+static int ap_daemons_min_free=0; -+static int ap_daemons_max_free=0; -+static int ap_daemons_limit=0; /* MaxClients */ -+static int server_limit = DEFAULT_SERVER_LIMIT; -+static int first_server_limit = 0; -+static int changed_limit_at_restart; -+static int mpm_state = AP_MPMQ_STARTING; -+static ap_pod_t *pod; -+ -+/* -+ * The max child slot ever assigned, preserved across restarts. Necessary -+ * to deal with MaxClients changes across AP_SIG_GRACEFUL restarts. We -+ * use this value to optimize routines that have to scan the entire scoreboard. -+ */ -+int ap_max_daemons_limit = -1; -+server_rec *ap_server_conf; -+ -+/* one_process --- debugging mode variable; can be set from the command line -+ * with the -X flag. If set, this gets you the child_main loop running -+ * in the process which originally started up (no detach, no make_child), -+ * which is a pretty nice debugging environment. (You'll get a SIGHUP -+ * early in standalone_main; just continue through. This is the server -+ * trying to kill off any child processes which it might have lying -+ * around --- Apache doesn't keep track of their pids, it just sends -+ * SIGHUP to the process group, ignoring it in the root process. -+ * Continue through and you'll be fine.). -+ */ -+ -+static int one_process = 0; -+ -+static apr_pool_t *pconf; /* Pool for config stuff */ -+static apr_pool_t *pchild; /* Pool for httpd child stuff */ -+ -+static pid_t ap_my_pid; /* it seems silly to call getpid all the time */ -+static pid_t parent_pid; -+#ifndef MULTITHREAD -+static int my_child_num; -+#endif -+ap_generation_t volatile ap_my_generation=0; -+ -+#ifdef TPF -+int tpf_child = 0; -+char tpf_server_name[INETD_SERVNAME_LENGTH+1]; -+#endif /* TPF */ -+ -+static volatile int die_now = 0; -+ -+#define UNSET_NICE_VALUE 100 -+ -+typedef struct -+{ -+ uid_t uid; -+ gid_t gid; -+ char *username; -+ int nice_value; -+} itk_per_dir_conf; -+ -+typedef struct -+{ -+ int max_clients_vhost; -+} itk_server_conf; -+ -+module AP_MODULE_DECLARE_DATA mpm_itk_module; -+ -+#ifdef GPROF -+/* -+ * change directory for gprof to plop the gmon.out file -+ * configure in httpd.conf: -+ * GprofDir $RuntimeDir/ -> $ServerRoot/$RuntimeDir/gmon.out -+ * GprofDir $RuntimeDir/% -> $ServerRoot/$RuntimeDir/gprof.$pid/gmon.out -+ */ -+static void chdir_for_gprof(void) -+{ -+ core_server_config *sconf = -+ ap_get_module_config(ap_server_conf->module_config, &core_module); -+ char *dir = sconf->gprof_dir; -+ const char *use_dir; -+ -+ if(dir) { -+ apr_status_t res; -+ char *buf = NULL ; -+ int len = strlen(sconf->gprof_dir) - 1; -+ if(*(dir + len) == '%') { -+ dir[len] = '\0'; -+ buf = ap_append_pid(pconf, dir, "gprof."); -+ } -+ use_dir = ap_server_root_relative(pconf, buf ? buf : dir); -+ res = apr_dir_make(use_dir, -+ APR_UREAD | APR_UWRITE | APR_UEXECUTE | -+ APR_GREAD | APR_GEXECUTE | -+ APR_WREAD | APR_WEXECUTE, pconf); -+ if(res != APR_SUCCESS && !APR_STATUS_IS_EEXIST(res)) { -+ ap_log_error(APLOG_MARK, APLOG_ERR, res, ap_server_conf, -+ "gprof: error creating directory %s", dir); -+ } -+ } -+ else { -+ use_dir = ap_server_root_relative(pconf, DEFAULT_REL_RUNTIMEDIR); -+ } -+ -+ chdir(use_dir); -+} -+#else -+#define chdir_for_gprof() -+#endif -+ -+/* XXX - I don't know if TPF will ever use this module or not, so leave -+ * the ap_check_signals calls in but disable them - manoj */ -+#define ap_check_signals() -+ -+/* a clean exit from a child with proper cleanup */ -+static void clean_child_exit(int code) __attribute__ ((noreturn)); -+static void clean_child_exit(int code) -+{ -+ mpm_state = AP_MPMQ_STOPPING; -+ -+ if (pchild) { -+ apr_pool_destroy(pchild); -+ } -+ ap_mpm_pod_close(pod); -+ chdir_for_gprof(); -+ exit(code); -+} -+ -+static void accept_mutex_on(void) -+{ -+ apr_status_t rv = apr_proc_mutex_lock(accept_mutex); -+ if (rv != APR_SUCCESS) { -+ const char *msg = "couldn't grab the accept mutex"; -+ -+ if (ap_my_generation != -+ ap_scoreboard_image->global->running_generation) { -+ ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, NULL, "%s", msg); -+ clean_child_exit(0); -+ } -+ else { -+ ap_log_error(APLOG_MARK, APLOG_EMERG, rv, NULL, "%s", msg); -+ exit(APEXIT_CHILDFATAL); -+ } -+ } -+} -+ -+static void accept_mutex_off(void) -+{ -+ apr_status_t rv = apr_proc_mutex_unlock(accept_mutex); -+ if (rv != APR_SUCCESS) { -+ const char *msg = "couldn't release the accept mutex"; -+ -+ if (ap_my_generation != -+ ap_scoreboard_image->global->running_generation) { -+ ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, NULL, "%s", msg); -+ /* don't exit here... we have a connection to -+ * process, after which point we'll see that the -+ * generation changed and we'll exit cleanly -+ */ -+ } -+ else { -+ ap_log_error(APLOG_MARK, APLOG_EMERG, rv, NULL, "%s", msg); -+ exit(APEXIT_CHILDFATAL); -+ } -+ } -+} -+ -+/* On some architectures it's safe to do unserialized accept()s in the single -+ * Listen case. But it's never safe to do it in the case where there's -+ * multiple Listen statements. Define SINGLE_LISTEN_UNSERIALIZED_ACCEPT -+ * when it's safe in the single Listen case. -+ */ -+#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT -+#define SAFE_ACCEPT(stmt) do {if (ap_listeners->next) {stmt;}} while(0) -+#else -+#define SAFE_ACCEPT(stmt) do {stmt;} while(0) -+#endif -+ -+AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result) -+{ -+ switch(query_code){ -+ case AP_MPMQ_MAX_DAEMON_USED: -+ *result = ap_daemons_limit; -+ return APR_SUCCESS; -+ case AP_MPMQ_IS_THREADED: -+ *result = AP_MPMQ_NOT_SUPPORTED; -+ return APR_SUCCESS; -+ case AP_MPMQ_IS_FORKED: -+ *result = AP_MPMQ_DYNAMIC; -+ return APR_SUCCESS; -+ case AP_MPMQ_HARD_LIMIT_DAEMONS: -+ *result = server_limit; -+ return APR_SUCCESS; -+ case AP_MPMQ_HARD_LIMIT_THREADS: -+ *result = HARD_THREAD_LIMIT; -+ return APR_SUCCESS; -+ case AP_MPMQ_MAX_THREADS: -+ *result = 0; -+ return APR_SUCCESS; -+ case AP_MPMQ_MIN_SPARE_DAEMONS: -+ *result = ap_daemons_min_free; -+ return APR_SUCCESS; -+ case AP_MPMQ_MIN_SPARE_THREADS: -+ *result = 0; -+ return APR_SUCCESS; -+ case AP_MPMQ_MAX_SPARE_DAEMONS: -+ *result = ap_daemons_max_free; -+ return APR_SUCCESS; -+ case AP_MPMQ_MAX_SPARE_THREADS: -+ *result = 0; -+ return APR_SUCCESS; -+ case AP_MPMQ_MAX_REQUESTS_DAEMON: -+ *result = ap_max_requests_per_child; -+ return APR_SUCCESS; -+ case AP_MPMQ_MAX_DAEMONS: -+ *result = server_limit; -+ return APR_SUCCESS; -+ case AP_MPMQ_MPM_STATE: -+ *result = mpm_state; -+ return APR_SUCCESS; -+ } -+ return APR_ENOTIMPL; -+} -+ -+#if defined(NEED_WAITPID) -+/* -+ Systems without a real waitpid sometimes lose a child's exit while waiting -+ for another. Search through the scoreboard for missing children. -+ */ -+int reap_children(int *exitcode, apr_exit_why_e *status) -+{ -+ int n, pid; -+ -+ for (n = 0; n < ap_max_daemons_limit; ++n) { -+ if (ap_scoreboard_image->servers[n][0].status != SERVER_DEAD && -+ kill((pid = ap_scoreboard_image->parent[n].pid), 0) == -1) { -+ ap_update_child_status_from_indexes(n, 0, SERVER_DEAD, NULL); -+ /* just mark it as having a successful exit status */ -+ *status = APR_PROC_EXIT; -+ *exitcode = 0; -+ return(pid); -+ } -+ } -+ return 0; -+} -+#endif -+ -+/***************************************************************** -+ * Connection structures and accounting... -+ */ -+ -+static void just_die(int sig) -+{ -+ clean_child_exit(0); -+} -+ -+static void stop_listening(int sig) -+{ -+ ap_close_listeners(); -+ -+ /* For a graceful stop, we want the child to exit when done */ -+ die_now = 1; -+} -+ -+/* volatile just in case */ -+static int volatile shutdown_pending; -+static int volatile restart_pending; -+static int volatile is_graceful; -+ -+static void sig_term(int sig) -+{ -+ if (shutdown_pending == 1) { -+ /* Um, is this _probably_ not an error, if the user has -+ * tried to do a shutdown twice quickly, so we won't -+ * worry about reporting it. -+ */ -+ return; -+ } -+ shutdown_pending = 1; -+ is_graceful = (sig == AP_SIG_GRACEFUL_STOP); -+} -+ -+/* restart() is the signal handler for SIGHUP and AP_SIG_GRACEFUL -+ * in the parent process, unless running in ONE_PROCESS mode -+ */ -+static void restart(int sig) -+{ -+ if (restart_pending == 1) { -+ /* Probably not an error - don't bother reporting it */ -+ return; -+ } -+ restart_pending = 1; -+ is_graceful = (sig == AP_SIG_GRACEFUL); -+} -+ -+static void set_signals(void) -+{ -+#ifndef NO_USE_SIGACTION -+ struct sigaction sa; -+#endif -+ -+ if (!one_process) { -+ ap_fatal_signal_setup(ap_server_conf, pconf); -+ } -+ -+#ifndef NO_USE_SIGACTION -+ sigemptyset(&sa.sa_mask); -+ sa.sa_flags = 0; -+ -+ sa.sa_handler = sig_term; -+ if (sigaction(SIGTERM, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGTERM)"); -+#ifdef AP_SIG_GRACEFUL_STOP -+ if (sigaction(AP_SIG_GRACEFUL_STOP, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, -+ "sigaction(" AP_SIG_GRACEFUL_STOP_STRING ")"); -+#endif -+#ifdef SIGINT -+ if (sigaction(SIGINT, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGINT)"); -+#endif -+#ifdef SIGXCPU -+ sa.sa_handler = SIG_DFL; -+ if (sigaction(SIGXCPU, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGXCPU)"); -+#endif -+#ifdef SIGXFSZ -+ sa.sa_handler = SIG_DFL; -+ if (sigaction(SIGXFSZ, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGXFSZ)"); -+#endif -+#ifdef SIGPIPE -+ sa.sa_handler = SIG_IGN; -+ if (sigaction(SIGPIPE, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGPIPE)"); -+#endif -+ -+ /* we want to ignore HUPs and AP_SIG_GRACEFUL while we're busy -+ * processing one -+ */ -+ sigaddset(&sa.sa_mask, SIGHUP); -+ sigaddset(&sa.sa_mask, AP_SIG_GRACEFUL); -+ sa.sa_handler = restart; -+ if (sigaction(SIGHUP, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGHUP)"); -+ if (sigaction(AP_SIG_GRACEFUL, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(" AP_SIG_GRACEFUL_STRING ")"); -+#else -+ if (!one_process) { -+#ifdef SIGXCPU -+ apr_signal(SIGXCPU, SIG_DFL); -+#endif /* SIGXCPU */ -+#ifdef SIGXFSZ -+ apr_signal(SIGXFSZ, SIG_DFL); -+#endif /* SIGXFSZ */ -+ } -+ -+ apr_signal(SIGTERM, sig_term); -+#ifdef SIGHUP -+ apr_signal(SIGHUP, restart); -+#endif /* SIGHUP */ -+#ifdef AP_SIG_GRACEFUL -+ apr_signal(AP_SIG_GRACEFUL, restart); -+#endif /* AP_SIG_GRACEFUL */ -+#ifdef AP_SIG_GRACEFUL_STOP -+ apr_signal(AP_SIG_GRACEFUL_STOP, sig_term); -+#endif /* AP_SIG_GRACEFUL */ -+#ifdef SIGPIPE -+ apr_signal(SIGPIPE, SIG_IGN); -+#endif /* SIGPIPE */ -+ -+#endif -+} -+ -+/***************************************************************** -+ * Child process main loop. -+ * The following vars are static to avoid getting clobbered by longjmp(); -+ * they are really private to child_main. -+ */ -+ -+static int requests_this_child; -+static int num_listensocks = 0; -+ -+ -+int ap_graceful_stop_signalled(void) -+{ -+ /* not ever called anymore... */ -+ return 0; -+} -+ -+ -+static void child_main(int child_num_arg) -+{ -+ apr_pool_t *ptrans; -+ apr_allocator_t *allocator; -+ apr_status_t status; -+ int i; -+ ap_listen_rec *lr; -+ apr_pollset_t *pollset; -+ ap_sb_handle_t *sbh; -+ apr_bucket_alloc_t *bucket_alloc; -+ int last_poll_idx = 0; -+ -+#if HAVE_LIBCAP -+ cap_t caps; -+ cap_value_t suidcaps[] = { -+ CAP_SETUID, -+ CAP_SETGID, -+ CAP_DAC_READ_SEARCH, -+ CAP_SYS_NICE, -+ }; -+#endif -+ -+ mpm_state = AP_MPMQ_STARTING; /* for benefit of any hooks that run as this -+ * child initializes -+ */ -+ -+ my_child_num = child_num_arg; -+ ap_my_pid = getpid(); -+ requests_this_child = 0; -+ -+ ap_fatal_signal_child_setup(ap_server_conf); -+ -+ /* Get a sub context for global allocations in this child, so that -+ * we can have cleanups occur when the child exits. -+ */ -+ apr_allocator_create(&allocator); -+ apr_allocator_max_free_set(allocator, ap_max_mem_free); -+ apr_pool_create_ex(&pchild, pconf, NULL, allocator); -+ apr_allocator_owner_set(allocator, pchild); -+ -+ apr_pool_create(&ptrans, pchild); -+ apr_pool_tag(ptrans, "transaction"); -+ -+ /* needs to be done before we switch UIDs so we have permissions */ -+ ap_reopen_scoreboard(pchild, NULL, 0); -+ status = apr_proc_mutex_child_init(&accept_mutex, ap_lock_fname, pchild); -+ if (status != APR_SUCCESS) { -+ ap_log_error(APLOG_MARK, APLOG_EMERG, status, ap_server_conf, -+ "Couldn't initialize cross-process lock in child " -+ "(%s) (%d)", ap_lock_fname, ap_accept_lock_mech); -+ clean_child_exit(APEXIT_CHILDFATAL); -+ } -+ -+ ap_run_child_init(pchild, ap_server_conf); -+ -+ ap_create_sb_handle(&sbh, pchild, my_child_num, 0); -+ -+ (void) ap_update_child_status(sbh, SERVER_READY, (request_rec *) NULL); -+ -+ /* Set up the pollfd array */ -+ status = apr_pollset_create(&pollset, num_listensocks, pchild, 0); -+ if (status != APR_SUCCESS) { -+ ap_log_error(APLOG_MARK, APLOG_EMERG, status, ap_server_conf, -+ "Couldn't create pollset in child; check system or user limits"); -+ clean_child_exit(APEXIT_CHILDSICK); /* assume temporary resource issue */ -+ } -+ -+ for (lr = ap_listeners, i = num_listensocks; i--; lr = lr->next) { -+ apr_pollfd_t pfd = { 0 }; -+ -+ pfd.desc_type = APR_POLL_SOCKET; -+ pfd.desc.s = lr->sd; -+ pfd.reqevents = APR_POLLIN; -+ pfd.client_data = lr; -+ -+ /* ### check the status */ -+ (void) apr_pollset_add(pollset, &pfd); -+ } -+ -+#if HAVE_LIBCAP -+ /* Drop as many privileges as we can. We'll still -+ * access files with uid=0, and we can setuid() to anything, but -+ * at least there's tons of other evilness (like loading kernel -+ * modules) we can't do directly. (The setuid() capability will -+ * go away automatically when we setuid() or exec() -- the former -+ * is likely to come first.) -+ */ -+ caps = cap_init(); -+ cap_clear(caps); -+ cap_set_flag(caps, CAP_PERMITTED, sizeof(suidcaps)/sizeof(cap_value_t), suidcaps, CAP_SET); -+ cap_set_flag(caps, CAP_EFFECTIVE, sizeof(suidcaps)/sizeof(cap_value_t), suidcaps, CAP_SET); -+ cap_set_proc(caps); -+ cap_free(caps); -+#endif -+ -+ mpm_state = AP_MPMQ_RUNNING; -+ -+ bucket_alloc = apr_bucket_alloc_create(pchild); -+ -+ /* die_now is set when AP_SIG_GRACEFUL is received in the child; -+ * shutdown_pending is set when SIGTERM is received when running -+ * in single process mode. */ -+ while (!die_now && !shutdown_pending) { -+ conn_rec *current_conn; -+ void *csd; -+ -+ /* -+ * (Re)initialize this child to a pre-connection state. -+ */ -+ -+ apr_pool_clear(ptrans); -+ -+ if ((ap_max_requests_per_child > 0 -+ && requests_this_child++ >= ap_max_requests_per_child)) { -+ clean_child_exit(0); -+ } -+ -+ (void) ap_update_child_status(sbh, SERVER_READY, (request_rec *) NULL); -+ -+ /* -+ * Wait for an acceptable connection to arrive. -+ */ -+ -+ /* Lock around "accept", if necessary */ -+ SAFE_ACCEPT(accept_mutex_on()); -+ -+ if (num_listensocks == 1) { -+ /* There is only one listener record, so refer to that one. */ -+ lr = ap_listeners; -+ } -+ else { -+ /* multiple listening sockets - need to poll */ -+ for (;;) { -+ apr_int32_t numdesc; -+ const apr_pollfd_t *pdesc; -+ -+ /* check for termination first so we don't sleep for a while in -+ * poll if already signalled -+ */ -+ if (one_process && shutdown_pending) { -+ SAFE_ACCEPT(accept_mutex_off()); -+ return; -+ } -+ else if (die_now) { -+ /* In graceful stop/restart; drop the mutex -+ * and terminate the child. */ -+ SAFE_ACCEPT(accept_mutex_off()); -+ clean_child_exit(0); -+ } -+ /* timeout == 10 seconds to avoid a hang at graceful restart/stop -+ * caused by the closing of sockets by the signal handler -+ */ -+ status = apr_pollset_poll(pollset, apr_time_from_sec(10), -+ &numdesc, &pdesc); -+ if (status != APR_SUCCESS) { -+ if (APR_STATUS_IS_TIMEUP(status) || -+ APR_STATUS_IS_EINTR(status)) { -+ continue; -+ } -+ /* Single Unix documents select as returning errnos -+ * EBADF, EINTR, and EINVAL... and in none of those -+ * cases does it make sense to continue. In fact -+ * on Linux 2.0.x we seem to end up with EFAULT -+ * occasionally, and we'd loop forever due to it. -+ */ -+ ap_log_error(APLOG_MARK, APLOG_ERR, status, -+ ap_server_conf, "apr_pollset_poll: (listen)"); -+ SAFE_ACCEPT(accept_mutex_off()); -+ clean_child_exit(1); -+ } -+ -+ /* We can always use pdesc[0], but sockets at position N -+ * could end up completely starved of attention in a very -+ * busy server. Therefore, we round-robin across the -+ * returned set of descriptors. While it is possible that -+ * the returned set of descriptors might flip around and -+ * continue to starve some sockets, we happen to know the -+ * internal pollset implementation retains ordering -+ * stability of the sockets. Thus, the round-robin should -+ * ensure that a socket will eventually be serviced. -+ */ -+ if (last_poll_idx >= numdesc) -+ last_poll_idx = 0; -+ -+ /* Grab a listener record from the client_data of the poll -+ * descriptor, and advance our saved index to round-robin -+ * the next fetch. -+ * -+ * ### hmm... this descriptor might have POLLERR rather -+ * ### than POLLIN -+ */ -+ lr = pdesc[last_poll_idx++].client_data; -+ goto got_fd; -+ } -+ } -+ got_fd: -+ /* if we accept() something we don't want to die, so we have to -+ * defer the exit -+ */ -+ status = lr->accept_func(&csd, lr, ptrans); -+ -+ SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */ -+ -+ if (status == APR_EGENERAL) { -+ /* resource shortage or should-not-occur occurred */ -+ clean_child_exit(1); -+ } -+ else if (status != APR_SUCCESS) { -+ continue; -+ } -+ -+ /* -+ * We now have a connection, so set it up with the appropriate -+ * socket options, file descriptors, and read/write buffers. -+ */ -+ -+ { -+ pid_t pid = fork(), child_pid; -+ int status; -+ switch (pid) { -+ case -1: -+ ap_log_error(APLOG_MARK, APLOG_ERR, errno, NULL, "fork: Unable to fork new process"); -+ break; -+ case 0: /* child */ -+ apr_proc_mutex_child_init(&accept_mutex, ap_lock_fname, pchild); -+ current_conn = ap_run_create_connection(ptrans, ap_server_conf, csd, my_child_num, sbh, bucket_alloc); -+ if (current_conn) { -+ ap_process_connection(current_conn, csd); -+ ap_lingering_close(current_conn); -+ } -+ exit(0); -+ default: /* parent; just wait for child to be done */ -+ do { -+ child_pid = waitpid(pid, &status, 0); -+ } while (child_pid == -1 && errno == EINTR); -+ -+ if (child_pid != pid || !WIFEXITED(status)) { -+ if (WIFSIGNALED(status)) { -+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, "child died with signal %u", WTERMSIG(status)); -+ } else if (WEXITSTATUS(status) != 0) { -+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, "child exited with non-zero exit status %u", WEXITSTATUS(status)); -+ } else { -+ ap_log_error(APLOG_MARK, APLOG_ERR, errno, NULL, "waitpid() failed"); -+ } -+ clean_child_exit(1); -+ } -+ break; -+ } -+ } -+ -+ /* Check the pod and the generation number after processing a -+ * connection so that we'll go away if a graceful restart occurred -+ * while we were processing the connection or we are the lucky -+ * idle server process that gets to die. -+ */ -+ if (ap_mpm_pod_check(pod) == APR_SUCCESS) { /* selected as idle? */ -+ die_now = 1; -+ } -+ else if (ap_my_generation != -+ ap_scoreboard_image->global->running_generation) { /* restart? */ -+ /* yeah, this could be non-graceful restart, in which case the -+ * parent will kill us soon enough, but why bother checking? -+ */ -+ die_now = 1; -+ } -+ -+ /* if we have already setuid(), die (we can't be used anyhow) */ -+ if (getuid()) -+ die_now = 1; -+ } -+ /* This apr_pool_clear call is redundant, should be redundant, but compensates -+ * a flaw in the apr reslist code. This should be removed once that flaw has -+ * been addressed. -+ */ -+ apr_pool_clear(ptrans); -+ clean_child_exit(0); -+} -+ -+ -+static int make_child(server_rec *s, int slot) -+{ -+ int pid; -+ -+ if (slot + 1 > ap_max_daemons_limit) { -+ ap_max_daemons_limit = slot + 1; -+ } -+ -+ if (one_process) { -+ apr_signal(SIGHUP, sig_term); -+ /* Don't catch AP_SIG_GRACEFUL in ONE_PROCESS mode :) */ -+ apr_signal(SIGINT, sig_term); -+#ifdef SIGQUIT -+ apr_signal(SIGQUIT, SIG_DFL); -+#endif -+ apr_signal(SIGTERM, sig_term); -+ child_main(slot); -+ return 0; -+ } -+ -+ (void) ap_update_child_status_from_indexes(slot, 0, SERVER_STARTING, -+ (request_rec *) NULL); -+ -+ -+#ifdef _OSD_POSIX -+ /* BS2000 requires a "special" version of fork() before a setuid() call */ -+ if ((pid = os_fork(unixd_config.user_name)) == -1) { -+#elif defined(TPF) -+ if ((pid = os_fork(s, slot)) == -1) { -+#else -+ if ((pid = fork()) == -1) { -+#endif -+ ap_log_error(APLOG_MARK, APLOG_ERR, errno, s, "fork: Unable to fork new process"); -+ -+ /* fork didn't succeed. Fix the scoreboard or else -+ * it will say SERVER_STARTING forever and ever -+ */ -+ (void) ap_update_child_status_from_indexes(slot, 0, SERVER_DEAD, -+ (request_rec *) NULL); -+ -+ /* In case system resources are maxxed out, we don't want -+ * Apache running away with the CPU trying to fork over and -+ * over and over again. -+ */ -+ sleep(10); -+ -+ return -1; -+ } -+ -+ if (!pid) { -+#ifdef HAVE_BINDPROCESSOR -+ /* by default AIX binds to a single processor -+ * this bit unbinds children which will then bind to another cpu -+ */ -+ int status = bindprocessor(BINDPROCESS, (int)getpid(), -+ PROCESSOR_CLASS_ANY); -+ if (status != OK) { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, -+ ap_server_conf, "processor unbind failed %d", status); -+ } -+#endif -+ RAISE_SIGSTOP(MAKE_CHILD); -+ AP_MONCONTROL(1); -+ /* Disable the parent's signal handlers and set up proper handling in -+ * the child. -+ */ -+ apr_signal(SIGHUP, just_die); -+ apr_signal(SIGTERM, just_die); -+ /* The child process just closes listeners on AP_SIG_GRACEFUL. -+ * The pod is used for signalling the graceful restart. -+ */ -+ apr_signal(AP_SIG_GRACEFUL, stop_listening); -+ child_main(slot); -+ } -+ -+ ap_scoreboard_image->parent[slot].pid = pid; -+ -+ return 0; -+} -+ -+ -+/* start up a bunch of children */ -+static void startup_children(int number_to_start) -+{ -+ int i; -+ -+ for (i = 0; number_to_start && i < ap_daemons_limit; ++i) { -+ if (ap_scoreboard_image->servers[i][0].status != SERVER_DEAD) { -+ continue; -+ } -+ if (make_child(ap_server_conf, i) < 0) { -+ break; -+ } -+ --number_to_start; -+ } -+} -+ -+ -+/* -+ * idle_spawn_rate is the number of children that will be spawned on the -+ * next maintenance cycle if there aren't enough idle servers. It is -+ * doubled up to MAX_SPAWN_RATE, and reset only when a cycle goes by -+ * without the need to spawn. -+ */ -+static int idle_spawn_rate = 1; -+#ifndef MAX_SPAWN_RATE -+#define MAX_SPAWN_RATE (32) -+#endif -+static int hold_off_on_exponential_spawning; -+ -+static void perform_idle_server_maintenance(apr_pool_t *p) -+{ -+ int i; -+ int to_kill; -+ int idle_count; -+ worker_score *ws; -+ int free_length; -+ int free_slots[MAX_SPAWN_RATE]; -+ int last_non_dead; -+ int total_non_dead; -+ -+ /* initialize the free_list */ -+ free_length = 0; -+ -+ to_kill = -1; -+ idle_count = 0; -+ last_non_dead = -1; -+ total_non_dead = 0; -+ -+ for (i = 0; i < ap_daemons_limit; ++i) { -+ int status; -+ -+ if (i >= ap_max_daemons_limit && free_length == idle_spawn_rate) -+ break; -+ ws = &ap_scoreboard_image->servers[i][0]; -+ status = ws->status; -+ if (status == SERVER_DEAD) { -+ /* try to keep children numbers as low as possible */ -+ if (free_length < idle_spawn_rate) { -+ free_slots[free_length] = i; -+ ++free_length; -+ } -+ } -+ else { -+ /* We consider a starting server as idle because we started it -+ * at least a cycle ago, and if it still hasn't finished starting -+ * then we're just going to swamp things worse by forking more. -+ * So we hopefully won't need to fork more if we count it. -+ * This depends on the ordering of SERVER_READY and SERVER_STARTING. -+ */ -+ if (status <= SERVER_READY) { -+ ++ idle_count; -+ /* always kill the highest numbered child if we have to... -+ * no really well thought out reason ... other than observing -+ * the server behaviour under linux where lower numbered children -+ * tend to service more hits (and hence are more likely to have -+ * their data in cpu caches). -+ */ -+ to_kill = i; -+ } -+ -+ ++total_non_dead; -+ last_non_dead = i; -+ } -+ } -+ ap_max_daemons_limit = last_non_dead + 1; -+ if (idle_count > ap_daemons_max_free) { -+ /* kill off one child... we use the pod because that'll cause it to -+ * shut down gracefully, in case it happened to pick up a request -+ * while we were counting -+ */ -+ ap_mpm_pod_signal(pod); -+ idle_spawn_rate = 1; -+ } -+ else if (idle_count < ap_daemons_min_free) { -+ /* terminate the free list */ -+ if (free_length == 0) { -+ /* only report this condition once */ -+ static int reported = 0; -+ -+ if (!reported) { -+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, -+ "server reached MaxClients setting, consider" -+ " raising the MaxClients setting"); -+ reported = 1; -+ } -+ idle_spawn_rate = 1; -+ } -+ else { -+ if (idle_spawn_rate >= 8) { -+ ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf, -+ "server seems busy, (you may need " -+ "to increase StartServers, or Min/MaxSpareServers), " -+ "spawning %d children, there are %d idle, and " -+ "%d total children", idle_spawn_rate, -+ idle_count, total_non_dead); -+ } -+ for (i = 0; i < free_length; ++i) { -+#ifdef TPF -+ if (make_child(ap_server_conf, free_slots[i]) == -1) { -+ if(free_length == 1) { -+ shutdown_pending = 1; -+ ap_log_error(APLOG_MARK, APLOG_EMERG, 0, ap_server_conf, -+ "No active child processes: shutting down"); -+ } -+ } -+#else -+ make_child(ap_server_conf, free_slots[i]); -+#endif /* TPF */ -+ } -+ /* the next time around we want to spawn twice as many if this -+ * wasn't good enough, but not if we've just done a graceful -+ */ -+ if (hold_off_on_exponential_spawning) { -+ --hold_off_on_exponential_spawning; -+ } -+ else if (idle_spawn_rate < MAX_SPAWN_RATE) { -+ idle_spawn_rate *= 2; -+ } -+ } -+ } -+ else { -+ idle_spawn_rate = 1; -+ } -+} -+ -+/***************************************************************** -+ * Executive routines. -+ */ -+ -+int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) -+{ -+ int index; -+ int remaining_children_to_start; -+ apr_status_t rv; -+ -+ ap_log_pid(pconf, ap_pid_fname); -+ -+ first_server_limit = server_limit; -+ if (changed_limit_at_restart) { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, s, -+ "WARNING: Attempt to change ServerLimit " -+ "ignored during restart"); -+ changed_limit_at_restart = 0; -+ } -+ -+ /* Initialize cross-process accept lock */ -+ ap_lock_fname = apr_psprintf(_pconf, "%s.%" APR_PID_T_FMT, -+ ap_server_root_relative(_pconf, ap_lock_fname), -+ ap_my_pid); -+ -+ rv = apr_proc_mutex_create(&accept_mutex, ap_lock_fname, -+ ap_accept_lock_mech, _pconf); -+ if (rv != APR_SUCCESS) { -+ ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, -+ "Couldn't create accept lock (%s) (%d)", -+ ap_lock_fname, ap_accept_lock_mech); -+ mpm_state = AP_MPMQ_STOPPING; -+ return 1; -+ } -+ -+#if APR_USE_SYSVSEM_SERIALIZE -+ if (ap_accept_lock_mech == APR_LOCK_DEFAULT || -+ ap_accept_lock_mech == APR_LOCK_SYSVSEM) { -+#else -+ if (ap_accept_lock_mech == APR_LOCK_SYSVSEM) { -+#endif -+ rv = unixd_set_proc_mutex_perms(accept_mutex); -+ if (rv != APR_SUCCESS) { -+ ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, -+ "Couldn't set permissions on cross-process lock; " -+ "check User and Group directives"); -+ mpm_state = AP_MPMQ_STOPPING; -+ return 1; -+ } -+ } -+ -+ if (!is_graceful) { -+ if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) { -+ mpm_state = AP_MPMQ_STOPPING; -+ return 1; -+ } -+ /* fix the generation number in the global score; we just got a new, -+ * cleared scoreboard -+ */ -+ ap_scoreboard_image->global->running_generation = ap_my_generation; -+ } -+ -+ set_signals(); -+ -+ if (one_process) { -+ AP_MONCONTROL(1); -+ make_child(ap_server_conf, 0); -+ } -+ else { -+ if (ap_daemons_max_free < ap_daemons_min_free + 1) /* Don't thrash... */ -+ ap_daemons_max_free = ap_daemons_min_free + 1; -+ -+ /* If we're doing a graceful_restart then we're going to see a lot -+ * of children exiting immediately when we get into the main loop -+ * below (because we just sent them AP_SIG_GRACEFUL). This happens pretty -+ * rapidly... and for each one that exits we'll start a new one until -+ * we reach at least daemons_min_free. But we may be permitted to -+ * start more than that, so we'll just keep track of how many we're -+ * supposed to start up without the 1 second penalty between each fork. -+ */ -+ remaining_children_to_start = ap_daemons_to_start; -+ if (remaining_children_to_start > ap_daemons_limit) { -+ remaining_children_to_start = ap_daemons_limit; -+ } -+ if (!is_graceful) { -+ startup_children(remaining_children_to_start); -+ remaining_children_to_start = 0; -+ } -+ else { -+ /* give the system some time to recover before kicking into -+ * exponential mode -+ */ -+ hold_off_on_exponential_spawning = 10; -+ } -+ -+ ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, -+ "%s configured -- resuming normal operations", -+ ap_get_server_description()); -+ ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf, -+ "Server built: %s", ap_get_server_built()); -+#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH -+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, -+ "AcceptMutex: %s (default: %s)", -+ apr_proc_mutex_name(accept_mutex), -+ apr_proc_mutex_defname()); -+#endif -+ restart_pending = shutdown_pending = 0; -+ -+ mpm_state = AP_MPMQ_RUNNING; -+ -+ while (!restart_pending && !shutdown_pending) { -+ int child_slot; -+ apr_exit_why_e exitwhy; -+ int status, processed_status; -+ /* this is a memory leak, but I'll fix it later. */ -+ apr_proc_t pid; -+ -+ ap_wait_or_timeout(&exitwhy, &status, &pid, pconf); -+ -+ /* XXX: if it takes longer than 1 second for all our children -+ * to start up and get into IDLE state then we may spawn an -+ * extra child -+ */ -+ if (pid.pid != -1) { -+ processed_status = ap_process_child_status(&pid, exitwhy, status); -+ if (processed_status == APEXIT_CHILDFATAL) { -+ mpm_state = AP_MPMQ_STOPPING; -+ return 1; -+ } -+ -+ /* non-fatal death... note that it's gone in the scoreboard. */ -+ child_slot = find_child_by_pid(&pid); -+ if (child_slot >= 0) { -+ (void) ap_update_child_status_from_indexes(child_slot, 0, SERVER_DEAD, -+ (request_rec *) NULL); -+ if (processed_status == APEXIT_CHILDSICK) { -+ /* child detected a resource shortage (E[NM]FILE, ENOBUFS, etc) -+ * cut the fork rate to the minimum -+ */ -+ idle_spawn_rate = 1; -+ } -+ else if (remaining_children_to_start -+ && child_slot < ap_daemons_limit) { -+ /* we're still doing a 1-for-1 replacement of dead -+ * children with new children -+ */ -+ make_child(ap_server_conf, child_slot); -+ --remaining_children_to_start; -+ } -+#if APR_HAS_OTHER_CHILD -+ } -+ else if (apr_proc_other_child_alert(&pid, APR_OC_REASON_DEATH, status) == APR_SUCCESS) { -+ /* handled */ -+#endif -+ } -+ else if (is_graceful) { -+ /* Great, we've probably just lost a slot in the -+ * scoreboard. Somehow we don't know about this -+ * child. -+ */ -+ ap_log_error(APLOG_MARK, APLOG_WARNING, -+ 0, ap_server_conf, -+ "long lost child came home! (pid %ld)", (long)pid.pid); -+ } -+ /* Don't perform idle maintenance when a child dies, -+ * only do it when there's a timeout. Remember only a -+ * finite number of children can die, and it's pretty -+ * pathological for a lot to die suddenly. -+ */ -+ continue; -+ } -+ else if (remaining_children_to_start) { -+ /* we hit a 1 second timeout in which none of the previous -+ * generation of children needed to be reaped... so assume -+ * they're all done, and pick up the slack if any is left. -+ */ -+ startup_children(remaining_children_to_start); -+ remaining_children_to_start = 0; -+ /* In any event we really shouldn't do the code below because -+ * few of the servers we just started are in the IDLE state -+ * yet, so we'd mistakenly create an extra server. -+ */ -+ continue; -+ } -+ -+ perform_idle_server_maintenance(pconf); -+#ifdef TPF -+ shutdown_pending = os_check_server(tpf_server_name); -+ ap_check_signals(); -+ sleep(1); -+#endif /*TPF */ -+ } -+ } /* one_process */ -+ -+ mpm_state = AP_MPMQ_STOPPING; -+ -+ if (shutdown_pending && !is_graceful) { -+ /* Time to shut down: -+ * Kill child processes, tell them to call child_exit, etc... -+ */ -+ if (unixd_killpg(getpgrp(), SIGTERM) < 0) { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "killpg SIGTERM"); -+ } -+ ap_reclaim_child_processes(1); /* Start with SIGTERM */ -+ -+ /* cleanup pid file on normal shutdown */ -+ { -+ const char *pidfile = NULL; -+ pidfile = ap_server_root_relative (pconf, ap_pid_fname); -+ if ( pidfile != NULL && unlink(pidfile) == 0) -+ ap_log_error(APLOG_MARK, APLOG_INFO, -+ 0, ap_server_conf, -+ "removed PID file %s (pid=%ld)", -+ pidfile, (long)getpid()); -+ } -+ -+ ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, -+ "caught SIGTERM, shutting down"); -+ -+ return 1; -+ } else if (shutdown_pending) { -+ /* Time to perform a graceful shut down: -+ * Reap the inactive children, and ask the active ones -+ * to close their listeners, then wait until they are -+ * all done to exit. -+ */ -+ int active_children; -+ apr_time_t cutoff = 0; -+ -+ /* Stop listening */ -+ ap_close_listeners(); -+ -+ /* kill off the idle ones */ -+ ap_mpm_pod_killpg(pod, ap_max_daemons_limit); -+ -+ /* Send SIGUSR1 to the active children */ -+ active_children = 0; -+ for (index = 0; index < ap_daemons_limit; ++index) { -+ if (ap_scoreboard_image->servers[index][0].status != SERVER_DEAD) { -+ /* Ask each child to close its listeners. */ -+ ap_mpm_safe_kill(MPM_CHILD_PID(index), AP_SIG_GRACEFUL); -+ active_children++; -+ } -+ } -+ -+ /* Allow each child which actually finished to exit */ -+ ap_relieve_child_processes(); -+ -+ /* cleanup pid file */ -+ { -+ const char *pidfile = NULL; -+ pidfile = ap_server_root_relative (pconf, ap_pid_fname); -+ if ( pidfile != NULL && unlink(pidfile) == 0) -+ ap_log_error(APLOG_MARK, APLOG_INFO, -+ 0, ap_server_conf, -+ "removed PID file %s (pid=%ld)", -+ pidfile, (long)getpid()); -+ } -+ -+ ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, -+ "caught " AP_SIG_GRACEFUL_STOP_STRING ", shutting down gracefully"); -+ -+ if (ap_graceful_shutdown_timeout) { -+ cutoff = apr_time_now() + -+ apr_time_from_sec(ap_graceful_shutdown_timeout); -+ } -+ -+ /* Don't really exit until each child has finished */ -+ shutdown_pending = 0; -+ do { -+ /* Pause for a second */ -+ sleep(1); -+ -+ /* Relieve any children which have now exited */ -+ ap_relieve_child_processes(); -+ -+ active_children = 0; -+ for (index = 0; index < ap_daemons_limit; ++index) { -+ if (ap_mpm_safe_kill(MPM_CHILD_PID(index), 0) == APR_SUCCESS) { -+ active_children = 1; -+ /* Having just one child is enough to stay around */ -+ break; -+ } -+ } -+ } while (!shutdown_pending && active_children && -+ (!ap_graceful_shutdown_timeout || apr_time_now() < cutoff)); -+ -+ /* We might be here because we received SIGTERM, either -+ * way, try and make sure that all of our processes are -+ * really dead. -+ */ -+ unixd_killpg(getpgrp(), SIGTERM); -+ -+ return 1; -+ } -+ -+ /* we've been told to restart */ -+ apr_signal(SIGHUP, SIG_IGN); -+ apr_signal(AP_SIG_GRACEFUL, SIG_IGN); -+ if (one_process) { -+ /* not worth thinking about */ -+ return 1; -+ } -+ -+ /* advance to the next generation */ -+ /* XXX: we really need to make sure this new generation number isn't in -+ * use by any of the children. -+ */ -+ ++ap_my_generation; -+ ap_scoreboard_image->global->running_generation = ap_my_generation; -+ -+ if (is_graceful) { -+ ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, -+ "Graceful restart requested, doing restart"); -+ -+ /* kill off the idle ones */ -+ ap_mpm_pod_killpg(pod, ap_max_daemons_limit); -+ -+ /* This is mostly for debugging... so that we know what is still -+ * gracefully dealing with existing request. This will break -+ * in a very nasty way if we ever have the scoreboard totally -+ * file-based (no shared memory) -+ */ -+ for (index = 0; index < ap_daemons_limit; ++index) { -+ if (ap_scoreboard_image->servers[index][0].status != SERVER_DEAD) { -+ ap_scoreboard_image->servers[index][0].status = SERVER_GRACEFUL; -+ /* Ask each child to close its listeners. -+ * -+ * NOTE: we use the scoreboard, because if we send SIGUSR1 -+ * to every process in the group, this may include CGI's, -+ * piped loggers, etc. They almost certainly won't handle -+ * it gracefully. -+ */ -+ ap_mpm_safe_kill(ap_scoreboard_image->parent[index].pid, AP_SIG_GRACEFUL); -+ } -+ } -+ } -+ else { -+ /* Kill 'em off */ -+ if (unixd_killpg(getpgrp(), SIGHUP) < 0) { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "killpg SIGHUP"); -+ } -+ ap_reclaim_child_processes(0); /* Not when just starting up */ -+ ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, -+ "SIGHUP received. Attempting to restart"); -+ } -+ -+ return 0; -+} -+ -+/* This really should be a post_config hook, but the error log is already -+ * redirected by that point, so we need to do this in the open_logs phase. -+ */ -+static int itk_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) -+{ -+ apr_status_t rv; -+ -+ pconf = p; -+ ap_server_conf = s; -+ -+ if ((num_listensocks = ap_setup_listeners(ap_server_conf)) < 1) { -+ ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_STARTUP, 0, -+ NULL, "no listening sockets available, shutting down"); -+ return DONE; -+ } -+ -+ if ((rv = ap_mpm_pod_open(pconf, &pod))) { -+ ap_log_error(APLOG_MARK, APLOG_CRIT|APLOG_STARTUP, rv, NULL, -+ "Could not open pipe-of-death."); -+ return DONE; -+ } -+ return OK; -+} -+ -+static int itk_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) -+{ -+ static int restart_num = 0; -+ int no_detach, debug, foreground; -+ apr_status_t rv; -+ -+ mpm_state = AP_MPMQ_STARTING; -+ -+ debug = ap_exists_config_define("DEBUG"); -+ -+ if (debug) { -+ foreground = one_process = 1; -+ no_detach = 0; -+ } -+ else -+ { -+ no_detach = ap_exists_config_define("NO_DETACH"); -+ one_process = ap_exists_config_define("ONE_PROCESS"); -+ foreground = ap_exists_config_define("FOREGROUND"); -+ } -+ -+ /* sigh, want this only the second time around */ -+ if (restart_num++ == 1) { -+ is_graceful = 0; -+ -+ if (!one_process && !foreground) { -+ rv = apr_proc_detach(no_detach ? APR_PROC_DETACH_FOREGROUND -+ : APR_PROC_DETACH_DAEMONIZE); -+ if (rv != APR_SUCCESS) { -+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, -+ "apr_proc_detach failed"); -+ return HTTP_INTERNAL_SERVER_ERROR; -+ } -+ } -+ -+ parent_pid = ap_my_pid = getpid(); -+ } -+ -+ unixd_pre_config(ptemp); -+ ap_listen_pre_config(); -+ ap_daemons_to_start = DEFAULT_START_DAEMON; -+ ap_daemons_min_free = DEFAULT_MIN_FREE_DAEMON; -+ ap_daemons_max_free = DEFAULT_MAX_FREE_DAEMON; -+ ap_daemons_limit = server_limit; -+ ap_pid_fname = DEFAULT_PIDLOG; -+ ap_lock_fname = DEFAULT_LOCKFILE; -+ ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD; -+ ap_extended_status = 0; -+#ifdef AP_MPM_WANT_SET_MAX_MEM_FREE -+ ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED; -+#endif -+ -+ apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); -+ -+ return OK; -+} -+ -+static int itk_post_perdir_config(request_rec *r) -+{ -+ uid_t wanted_uid; -+ gid_t wanted_gid; -+ const char *wanted_username; -+ int err = 0; -+ -+ itk_server_conf *sconf = -+ (itk_server_conf *) ap_get_module_config(r->server->module_config, &mpm_itk_module); -+ -+ /* Enforce MaxClientsVhost. */ -+ if (sconf->max_clients_vhost > 0) { -+ int i, num_other_servers = 0; -+ for (i = 0; i < ap_daemons_limit; ++i) { -+ worker_score *ws = &ap_scoreboard_image->servers[i][0]; -+ if (ws->status >= SERVER_BUSY_READ && strncmp(ws->vhost, r->server->server_hostname, 31) == 0) -+ ++num_other_servers; -+ } -+ -+ if (num_other_servers > sconf->max_clients_vhost) { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, \ -+ "MaxClientsVhost reached for %s, refusing client.", -+ r->server->server_hostname); -+ return HTTP_SERVICE_UNAVAILABLE; -+ } -+ } -+ -+ itk_per_dir_conf *dconf = -+ (itk_per_dir_conf *) ap_get_module_config(r->per_dir_config, &mpm_itk_module); -+ -+ strncpy(ap_scoreboard_image->servers[my_child_num][0].vhost, r->server->server_hostname, 31); -+ ap_scoreboard_image->servers[my_child_num][0].vhost[31] = 0; -+ -+ if (dconf->nice_value != UNSET_NICE_VALUE && -+ setpriority(PRIO_PROCESS, 0, dconf->nice_value)) { -+ _DBG("setpriority(): %s", strerror(errno)); -+ err = 1; -+ } -+ -+ wanted_uid = dconf->uid; -+ wanted_gid = dconf->gid; -+ wanted_username = dconf->username; -+ -+ if (wanted_uid == -1 || wanted_gid == -1) { -+ wanted_uid = unixd_config.user_id; -+ wanted_gid = unixd_config.group_id; -+ wanted_username = unixd_config.user_name; -+ } -+ -+ if (!err && wanted_uid != -1 && wanted_gid != -1 && (getuid() != wanted_uid || getgid() != wanted_gid)) { -+ if (setgid(wanted_gid)) { -+ _DBG("setgid(%d): %s", wanted_gid, strerror(errno)); -+ err = 1; -+ } else if (initgroups(wanted_username, wanted_gid)) { -+ _DBG("initgroups(%s, %d): %s", wanted_username, wanted_gid, strerror(errno)); -+ err = 1; -+ } else if (setuid(wanted_uid)) { -+ _DBG("setuid(%d): %s", wanted_uid, strerror(errno)); -+ err = 1; -+ } -+ } -+ -+ /* -+ * Most likely a case of switching uid/gid within a persistent -+ * connection; the RFCs allow us to just close the connection -+ * at anytime, so we excercise our right. :-) -+ */ -+ if (err) { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, \ -+ "Couldn't set uid/gid/priority, closing connection."); -+ ap_lingering_close(r->connection); -+ exit(0); -+ } -+ return OK; -+} -+ -+static void itk_hooks(apr_pool_t *p) -+{ -+ /* The itk open_logs phase must run before the core's, or stderr -+ * will be redirected to a file, and the messages won't print to the -+ * console. -+ */ -+ static const char *const aszSucc[] = {"core.c", NULL}; -+ -+#ifdef AUX3 -+ (void) set42sig(); -+#endif -+ -+ ap_hook_open_logs(itk_open_logs, NULL, aszSucc, APR_HOOK_MIDDLE); -+ /* we need to set the MPM state before other pre-config hooks use MPM query -+ * to retrieve it, so register as REALLY_FIRST -+ */ -+ ap_hook_pre_config(itk_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST); -+ -+ /* set the uid as fast as possible, but not before merging per-dit config */ -+ ap_hook_header_parser(itk_post_perdir_config, NULL, NULL, APR_HOOK_REALLY_FIRST); -+} -+ -+static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, const char *arg) -+{ -+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); -+ if (err != NULL) { -+ return err; -+ } -+ -+ ap_daemons_to_start = atoi(arg); -+ return NULL; -+} -+ -+static const char *set_min_free_servers(cmd_parms *cmd, void *dummy, const char *arg) -+{ -+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); -+ if (err != NULL) { -+ return err; -+ } -+ -+ ap_daemons_min_free = atoi(arg); -+ if (ap_daemons_min_free <= 0) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: detected MinSpareServers set to non-positive."); -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "Resetting to 1 to avoid almost certain Apache failure."); -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "Please read the documentation."); -+ ap_daemons_min_free = 1; -+ } -+ -+ return NULL; -+} -+ -+static const char *set_max_free_servers(cmd_parms *cmd, void *dummy, const char *arg) -+{ -+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); -+ if (err != NULL) { -+ return err; -+ } -+ -+ ap_daemons_max_free = atoi(arg); -+ return NULL; -+} -+ -+static const char *set_max_clients (cmd_parms *cmd, void *dummy, const char *arg) -+{ -+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); -+ if (err != NULL) { -+ return err; -+ } -+ -+ ap_daemons_limit = atoi(arg); -+ if (ap_daemons_limit > server_limit) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: MaxClients of %d exceeds ServerLimit value " -+ "of %d servers,", ap_daemons_limit, server_limit); -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ " lowering MaxClients to %d. To increase, please " -+ "see the ServerLimit", server_limit); -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ " directive."); -+ ap_daemons_limit = server_limit; -+ } -+ else if (ap_daemons_limit < 1) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: Require MaxClients > 0, setting to 1"); -+ ap_daemons_limit = 1; -+ } -+ return NULL; -+} -+ -+static const char *set_server_limit (cmd_parms *cmd, void *dummy, const char *arg) -+{ -+ int tmp_server_limit; -+ -+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); -+ if (err != NULL) { -+ return err; -+ } -+ -+ tmp_server_limit = atoi(arg); -+ /* you cannot change ServerLimit across a restart; ignore -+ * any such attempts -+ */ -+ if (first_server_limit && -+ tmp_server_limit != server_limit) { -+ /* how do we log a message? the error log is a bit bucket at this -+ * point; we'll just have to set a flag so that ap_mpm_run() -+ * logs a warning later -+ */ -+ changed_limit_at_restart = 1; -+ return NULL; -+ } -+ server_limit = tmp_server_limit; -+ -+ if (server_limit > MAX_SERVER_LIMIT) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: ServerLimit of %d exceeds compile time limit " -+ "of %d servers,", server_limit, MAX_SERVER_LIMIT); -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ " lowering ServerLimit to %d.", MAX_SERVER_LIMIT); -+ server_limit = MAX_SERVER_LIMIT; -+ } -+ else if (server_limit < 1) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: Require ServerLimit > 0, setting to 1"); -+ server_limit = 1; -+ } -+ return NULL; -+} -+ -+static const char *assign_user_id (cmd_parms *cmd, void *ptr, const char *user_name, const char *group_name) -+{ -+ itk_per_dir_conf *dconf = (itk_per_dir_conf *) ptr; -+ dconf->username = apr_pstrdup(cmd->pool, user_name); -+ dconf->uid = ap_uname2id(user_name); -+ dconf->gid = ap_gname2id(group_name); -+ return NULL; -+} -+ -+static const char *set_max_clients_vhost (cmd_parms *cmd, void *dummy, const char *arg) -+{ -+ itk_server_conf *sconf = -+ (itk_server_conf *) ap_get_module_config(cmd->server->module_config, &mpm_itk_module); -+ sconf->max_clients_vhost = atoi(arg); -+ return NULL; -+} -+ -+static const char *set_nice_value (cmd_parms *cmd, void *ptr, const char *arg) -+{ -+ itk_per_dir_conf *dconf = (itk_per_dir_conf *) ptr; -+ int nice_value = atoi(arg); -+ -+ if (nice_value < -20) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: NiceValue of %d is below -20, increasing NiceValue to -20.", -+ nice_value); -+ nice_value = -20; -+ } -+ else if (nice_value > 19) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: NiceValue of %d is above 19, lowering NiceValue to 19.", -+ nice_value); -+ nice_value = 19; -+ } -+ dconf->nice_value = nice_value; -+ return NULL; -+} -+ -+static const command_rec itk_cmds[] = { -+UNIX_DAEMON_COMMANDS, -+LISTEN_COMMANDS, -+AP_INIT_TAKE1("StartServers", set_daemons_to_start, NULL, RSRC_CONF, -+ "Number of child processes launched at server startup"), -+AP_INIT_TAKE1("MinSpareServers", set_min_free_servers, NULL, RSRC_CONF, -+ "Minimum number of idle children, to handle request spikes"), -+AP_INIT_TAKE1("MaxSpareServers", set_max_free_servers, NULL, RSRC_CONF, -+ "Maximum number of idle children"), -+AP_INIT_TAKE1("MaxClients", set_max_clients, NULL, RSRC_CONF, -+ "Maximum number of children alive at the same time"), -+AP_INIT_TAKE1("ServerLimit", set_server_limit, NULL, RSRC_CONF, -+ "Maximum value of MaxClients for this run of Apache"), -+AP_INIT_TAKE2("AssignUserID", assign_user_id, NULL, RSRC_CONF|ACCESS_CONF, -+ "Tie a virtual host to a specific child process."), -+AP_INIT_TAKE1("MaxClientsVHost", set_max_clients_vhost, NULL, RSRC_CONF, -+ "Maximum number of children alive at the same time for this virtual host."), -+AP_INIT_TAKE1("NiceValue", set_nice_value, NULL, RSRC_CONF|ACCESS_CONF, -+ "Set nice value for the given vhost, from -20 (highest priority) to 19 (lowest priority)."), -+AP_GRACEFUL_SHUTDOWN_TIMEOUT_COMMAND, -+{ NULL } -+}; -+ -+/* == allocate a private per-dir config structure == */ -+static void *itk_create_dir_config(apr_pool_t *p, char *dummy) -+{ -+ itk_per_dir_conf *c = (itk_per_dir_conf *) -+ apr_pcalloc(p, sizeof(itk_per_dir_conf)); -+ c->uid = c->gid = -1; -+ c->nice_value = UNSET_NICE_VALUE; -+ return c; -+} -+ -+/* == merge the parent per-dir config structure into ours == */ -+static void *itk_merge_dir_config(apr_pool_t *p, void *parent_ptr, void *child_ptr) -+{ -+ itk_per_dir_conf *c = (itk_per_dir_conf *) -+ itk_create_dir_config(p, NULL); -+ itk_per_dir_conf *parent = (itk_per_dir_conf *) parent_ptr; -+ itk_per_dir_conf *child = (itk_per_dir_conf *) child_ptr; -+ -+ if (child->username != NULL) { -+ c->username = child->username; -+ c->uid = child->uid; -+ c->gid = child->gid; -+ } else { -+ c->username = parent->username; -+ c->uid = parent->uid; -+ c->gid = parent->gid; -+ } -+ if (child->nice_value != UNSET_NICE_VALUE) { -+ c->nice_value = child->nice_value; -+ } else { -+ c->nice_value = parent->nice_value; -+ } -+ return c; -+} -+ -+/* == allocate a private server config structure == */ -+static void *itk_create_server_config(apr_pool_t *p, server_rec *s) -+{ -+ itk_server_conf *c = (itk_server_conf *) -+ apr_pcalloc(p, sizeof(itk_server_conf)); -+ c->max_clients_vhost = -1; -+ return c; -+} -+ -+module AP_MODULE_DECLARE_DATA mpm_itk_module = { -+ MPM20_MODULE_STUFF, -+ ap_mpm_rewrite_args, /* hook to run before apache parses args */ -+ itk_create_dir_config, /* create per-directory config structure */ -+ itk_merge_dir_config, /* merge per-directory config structures */ -+ itk_create_server_config, /* create per-server config structure */ -+ NULL, /* merge per-server config structures */ -+ itk_cmds, /* command apr_table_t */ -+ itk_hooks, /* register hooks */ -+}; -unchanged: ---- server/mpm/experimental/itk/mpm.h -+++ server/mpm/experimental/itk/mpm.h -@@ -0,0 +1,68 @@ -+/* Licensed to the Apache Software Foundation (ASF) under one or more -+ * contributor license agreements. See the NOTICE file distributed with -+ * this work for additional information regarding copyright ownership. -+ * The ASF licenses this file to You under the Apache License, Version 2.0 -+ * (the "License"); you may not use this file except in compliance with -+ * the License. You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ * -+ * Portions copyright 2005-2009 Steinar H. Gunderson <sgunderson@bigfoot.com>. -+ * Licensed under the same terms as the rest of Apache. -+ * -+ * Portions copyright 2008 Knut Auvor Grythe <knut@auvor.no>. -+ * Licensed under the same terms as the rest of Apache. -+ */ -+ -+/** -+ * @file itk/mpm.h -+ * @brief ITK MPM (setuid per-vhost, no threads) -+ * -+ * @defgroup APACHE_MPM_ITK Apache ITK -+ * @ingroup APACHE_MPM APACHE_OS_UNIX -+ * @{ -+ */ -+ -+#include "httpd.h" -+#include "mpm_default.h" -+#include "scoreboard.h" -+#include "unixd.h" -+ -+#ifndef APACHE_MPM_ITK_H -+#define APACHE_MPM_ITK_H -+ -+#define ITK_MPM -+ -+#define MPM_NAME "ITK" -+ -+#define AP_MPM_WANT_RECLAIM_CHILD_PROCESSES -+#define AP_MPM_WANT_WAIT_OR_TIMEOUT -+#define AP_MPM_WANT_PROCESS_CHILD_STATUS -+#define AP_MPM_WANT_SET_PIDFILE -+#define AP_MPM_WANT_SET_SCOREBOARD -+#define AP_MPM_WANT_SET_LOCKFILE -+#define AP_MPM_WANT_SET_MAX_REQUESTS -+#define AP_MPM_WANT_SET_COREDUMPDIR -+#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH -+#define AP_MPM_WANT_SIGNAL_SERVER -+#define AP_MPM_WANT_SET_MAX_MEM_FREE -+#define AP_MPM_WANT_FATAL_SIGNAL_HANDLER -+#define AP_MPM_WANT_SET_GRACEFUL_SHUTDOWN -+#define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK -+ -+#define AP_MPM_USES_POD 1 -+#define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid) -+#define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0) -+#define MPM_ACCEPT_FUNC unixd_accept -+ -+extern int ap_threads_per_child; -+extern int ap_max_daemons_limit; -+extern server_rec *ap_server_conf; -+#endif /* APACHE_MPM_ITK_H */ -+/** @} */ -unchanged: ---- server/mpm/experimental/itk/mpm_default.h -+++ server/mpm/experimental/itk/mpm_default.h -@@ -0,0 +1,80 @@ -+/* Licensed to the Apache Software Foundation (ASF) under one or more -+ * contributor license agreements. See the NOTICE file distributed with -+ * this work for additional information regarding copyright ownership. -+ * The ASF licenses this file to You under the Apache License, Version 2.0 -+ * (the "License"); you may not use this file except in compliance with -+ * the License. You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ * -+ * Portions copyright 2005-2009 Steinar H. Gunderson <sgunderson@bigfoot.com>. -+ * Licensed under the same terms as the rest of Apache. -+ * -+ * Portions copyright 2008 Knut Auvor Grythe <knut@auvor.no>. -+ * Licensed under the same terms as the rest of Apache. -+ */ -+ -+/** -+ * @file itk/mpm_default.h -+ * @brief ITK MPM defaults -+ * -+ * @addtogroup APACHE_MPM_ITK -+ * @{ -+ */ -+ -+#ifndef APACHE_MPM_DEFAULT_H -+#define APACHE_MPM_DEFAULT_H -+ -+/* Number of servers to spawn off by default --- also, if fewer than -+ * this free when the caretaker checks, it will spawn more. -+ */ -+#ifndef DEFAULT_START_DAEMON -+#define DEFAULT_START_DAEMON 5 -+#endif -+ -+/* Maximum number of *free* server processes --- more than this, and -+ * they will die off. -+ */ -+ -+#ifndef DEFAULT_MAX_FREE_DAEMON -+#define DEFAULT_MAX_FREE_DAEMON 10 -+#endif -+ -+/* Minimum --- fewer than this, and more will be created */ -+ -+#ifndef DEFAULT_MIN_FREE_DAEMON -+#define DEFAULT_MIN_FREE_DAEMON 5 -+#endif -+ -+/* File used for accept locking, when we use a file */ -+#ifndef DEFAULT_LOCKFILE -+#define DEFAULT_LOCKFILE DEFAULT_REL_RUNTIMEDIR "/accept.lock" -+#endif -+ -+/* Where the main/parent process's pid is logged */ -+#ifndef DEFAULT_PIDLOG -+#define DEFAULT_PIDLOG DEFAULT_REL_RUNTIMEDIR "/httpd.pid" -+#endif -+ -+/* -+ * Interval, in microseconds, between scoreboard maintenance. -+ */ -+#ifndef SCOREBOARD_MAINTENANCE_INTERVAL -+#define SCOREBOARD_MAINTENANCE_INTERVAL 1000000 -+#endif -+ -+/* Number of requests to try to handle in a single process. If <= 0, -+ * the children don't die off. -+ */ -+#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD -+#define DEFAULT_MAX_REQUESTS_PER_CHILD 10000 -+#endif -+ -+#endif /* AP_MPM_DEFAULT_H */ -+/** @} */ -unchanged: ---- server/mpm/config.m4 -+++ server/mpm/config.m4 -@@ -1,7 +1,7 @@ - AC_MSG_CHECKING(which MPM to use) - AC_ARG_WITH(mpm, - APACHE_HELP_STRING(--with-mpm=MPM,Choose the process model for Apache to use. -- MPM={beos|event|worker|prefork|mpmt_os2|winnt}),[ -+ MPM={beos|event|worker|prefork|mpmt_os2|winnt|itk}),[ - APACHE_MPM=$withval - ],[ - if test "x$APACHE_MPM" = "x"; then -@@ -23,7 +23,7 @@ - - ap_mpm_is_experimental () - { -- if test "$apache_cv_mpm" = "event" ; then -+ if test "$apache_cv_mpm" = "event" -o "$apache_cv_mpm" = "itk" ; then - return 0 - else - return 1 -@@ -66,6 +66,11 @@ - else - MPM_SUBDIR_NAME=$MPM_NAME - fi -+ -+if test "$apache_cv_mpm" = "itk" ; then -+ AC_CHECK_LIB(cap, cap_init) -+fi -+ - MPM_DIR=server/mpm/$MPM_SUBDIR_NAME - MPM_LIB=$MPM_DIR/lib${MPM_NAME}.la - -unchanged: ---- include/http_request.h -+++ include/http_request.h -@@ -12,6 +12,12 @@ - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -+ * -+ * Portions copyright 2005-2009 Steinar H. Gunderson <sgunderson@bigfoot.com>. -+ * Licensed under the same terms as the rest of Apache. -+ * -+ * Portions copyright 2008 Knut Auvor Grythe <knut@auvor.no>. -+ * Licensed under the same terms as the rest of Apache. - */ - - /** -@@ -350,6 +356,15 @@ - */ - AP_DECLARE_HOOK(void,insert_filter,(request_rec *r)) - -+/** -+ * This hook allows modules to affect the request immediately after the -+ * per-directory configuration for the request has been generated. This allows -+ * modules to make decisions based upon the current directory configuration -+ * @param r The current request -+ * @return OK or DECLINED -+ */ -+AP_DECLARE_HOOK(int,post_perdir_config,(request_rec *r)) -+ - AP_DECLARE(int) ap_location_walk(request_rec *r); - AP_DECLARE(int) ap_directory_walk(request_rec *r); - AP_DECLARE(int) ap_file_walk(request_rec *r); -unchanged: ---- server/request.c -+++ server/request.c -@@ -12,6 +12,12 @@ - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -+ * -+ * Portions copyright 2005-2009 Steinar H. Gunderson <sgunderson@bigfoot.com>. -+ * Licensed under the same terms as the rest of Apache. -+ * -+ * Portions copyright 2008 Knut Auvor Grythe <knut@auvor.no>. -+ * Licensed under the same terms as the rest of Apache. - */ - - /* -@@ -61,6 +67,7 @@ - APR_HOOK_LINK(auth_checker) - APR_HOOK_LINK(insert_filter) - APR_HOOK_LINK(create_request) -+ APR_HOOK_LINK(post_perdir_config) - ) - - AP_IMPLEMENT_HOOK_RUN_FIRST(int,translate_name, -@@ -80,6 +87,8 @@ - AP_IMPLEMENT_HOOK_VOID(insert_filter, (request_rec *r), (r)) - AP_IMPLEMENT_HOOK_RUN_ALL(int, create_request, - (request_rec *r), (r), OK, DECLINED) -+AP_IMPLEMENT_HOOK_RUN_ALL(int,post_perdir_config, -+ (request_rec *r), (r), OK, DECLINED) - - - static int decl_die(int status, char *phase, request_rec *r) -@@ -158,6 +167,13 @@ - return access_status; - } - -+ /* First chance to handle the request after per-directory configuration is -+ * generated -+ */ -+ if ((access_status = ap_run_post_perdir_config(r))) { -+ return access_status; -+ } -+ - /* Only on the main request! */ - if (r->main == NULL) { - if ((access_status = ap_run_header_parser(r))) { -only in patch2: -unchanged: ---- server/config.c -+++ server/config.c -@@ -1840,6 +1840,34 @@ AP_CORE_DECLARE(int) ap_parse_htaccess(a - else { - if (!APR_STATUS_IS_ENOENT(status) - && !APR_STATUS_IS_ENOTDIR(status)) { -+#ifdef ITK_MPM -+ /* -+ * If we are in a persistent connection, we might end up in a state -+ * where we can no longer read .htaccess files because we have already -+ * setuid(). This can either be because the previous request was for -+ * another vhost (basically the same problem as when setuid() fails in -+ * itk.c), or it can be because a .htaccess file is readable only by -+ * root. -+ * -+ * In any case, we don't want to give out a 403, since the request has -+ * a very real chance of succeeding on a fresh connection (where -+ * presumably uid=0). Thus, we give up serving the request on this -+ * TCP connection, and do a hard close of the socket. As long as we're -+ * in a persistent connection (and there _should_ not be a way this -+ * would happen on the first request in a connection, save for subrequests, -+ * which we special-case), this is allowed, as it is what happens on -+ * a timeout. The browser will simply open a new connection and try -+ * again (there's of course a performance hit, though, both due to -+ * the new connection setup and the fork() of a new server child). -+ */ -+ if (r->main == NULL && getuid() != 0) { -+ ap_log_rerror(APLOG_MARK, APLOG_WARNING, status, r, -+ "Couldn't read %s, closing connection.", -+ filename); -+ ap_lingering_close(r->connection); -+ exit(0); -+ } -+#endif - ap_log_rerror(APLOG_MARK, APLOG_CRIT, status, r, - "%s pcfg_openfile: unable to check htaccess file, " - "ensure it is readable", diff --git a/www/apache22-itk-mpm/files/mpm-itk-limits b/www/apache22-itk-mpm/files/mpm-itk-limits deleted file mode 100644 index b8a8c5b..0000000 --- a/www/apache22-itk-mpm/files/mpm-itk-limits +++ /dev/null @@ -1,53 +0,0 @@ ---- server/mpm/experimental/itk/Makefile.in 2011-07-01 10:33:45.000000000 +0000 -+++ server/mpm/experimental/itk/Makefile.in 2011-07-01 10:33:57.000000000 +0000 -@@ -1,5 +1,6 @@ - - LTLIBRARY_NAME = libitk.la - LTLIBRARY_SOURCES = itk.c -+LTLIBRARY_LIBADD = -lutil - - include $(top_srcdir)/build/ltlib.mk ---- server/mpm/experimental/itk/itk.c 2011-07-01 10:04:40.000000000 +0000 -+++ server/mpm/experimental/itk/itk.c 2011-07-01 10:17:19.000000000 +0000 -@@ -41,6 +41,8 @@ - #if APR_HAVE_SYS_TYPES_H - #include <sys/types.h> - #endif -+#include <pwd.h> -+#include <login_cap.h> - - #define CORE_PRIVATE - -@@ -1438,6 +1440,8 @@ - gid_t wanted_gid; - const char *wanted_username; - int err = 0; -+ struct passwd *pw; -+ login_cap_t *lc; - - itk_server_conf *sconf = - (itk_server_conf *) ap_get_module_config(r->server->module_config, &mpm_itk_module); -@@ -1481,6 +1485,23 @@ - wanted_username = unixd_config.user_name; - } - -+ if ((pw = getpwuid(wanted_uid)) == NULL) { -+ _DBG("crit: invalid uid: (%ld)", wanted_uid, strerror(errno)); -+ err = 1; -+ } -+ -+ /* -+ * Apply user resource limits based on login class. -+ */ -+ if ((lc = login_getclassbyname(pw->pw_class, pw)) == NULL) { -+ _DBG("failed to login_getclassbyname()", strerror(errno)); -+ err = 1; -+ } -+ if ((setusercontext(lc, pw, wanted_uid, LOGIN_SETRESOURCES)) != 0) { -+ _DBG("failed to setusercontext()", strerror(errno)); -+ err = 1; -+ } -+ - if (!err && wanted_uid != -1 && wanted_gid != -1 && (getuid() != wanted_uid || getgid() != wanted_gid)) { - if (setgid(wanted_gid)) { - _DBG("setgid(%d): %s", wanted_gid, strerror(errno)); diff --git a/www/apache22-itk-mpm/files/mpm-itk-perdir-regex b/www/apache22-itk-mpm/files/mpm-itk-perdir-regex deleted file mode 100644 index cbe5d2c..0000000 --- a/www/apache22-itk-mpm/files/mpm-itk-perdir-regex +++ /dev/null @@ -1,160 +0,0 @@ -vim: syntax=diff - -This patch is a supplement for the MPM-ITK patchset, adding the per-directory -setting AssignUserFromPath <path-regex> <user-pattern> <group-pattern> - -Using a regex for setting the user and/or group name might seem scary, but -it has a number of uses in cases where a hard-coded list of <Directory> -clauses would be implactical: - - For personal home pages, either using mod_userdir or simply - subdirectories named like the user name - For vhosts using mod_vhost_alias - -This patch is against MPM-ITK version 2.2.11-02. You might have to kneed it -a little if you are using a later version of MPM-ITK. - -Please Note: This patch has only been briefly tested. Remember to test it -rigorously before applying it in a production environment! - -Examples - - <Directory /home> - AssignUserFromPath "^/home/([^/]+)" www-data $1-web - </Directory> - - WWW: http://www.pvv.ntnu.no/~knuta/mpm-itk/ - - To apply this additional diff to apache22-mpm-itk use - make -DWITH_ITK_PERDIR_REGEX - -=========================================================================== ---- server/mpm/experimental/itk/itk.c 2011-03-05 18:12:47.000000000 +0100 -+++ server/mpm/experimental/itk/itk.c 2011-03-06 23:28:49.000000000 +0100 -@@ -60,6 +60,7 @@ - #include "ap_listen.h" - #include "ap_mmn.h" - #include "apr_poll.h" -+#include "ap_regex.h" - - #ifdef HAVE_BSTRING_H - #include <bstring.h> /* for IRIX, FD_SET calls bzero() */ -@@ -164,6 +165,10 @@ - gid_t gid; - char *username; - int nice_value; -+ char *user_regex_string; -+ ap_regex_t *user_regex; -+ char *user_pattern; -+ char *group_pattern; - } itk_per_dir_conf; - - typedef struct -@@ -1421,6 +1426,7 @@ - gid_t wanted_gid; - const char *wanted_username; - int err = 0; -+ int retval = OK; - - itk_server_conf *sconf = - (itk_server_conf *) ap_get_module_config(r->server->module_config, &mpm_itk_module); -@@ -1458,6 +1464,35 @@ - wanted_gid = dconf->gid; - wanted_username = dconf->username; - -+ /* Determine uid and gid from regex, if available */ -+ if (dconf->user_regex != NULL) { -+ apr_size_t nmatch = 10; -+ ap_regmatch_t pmatch[10]; -+ char *user_string; -+ char *group_string; -+ struct passwd *user_struct; -+ struct group *group_struct; -+ -+ if (ap_regexec(dconf->user_regex, r->filename, nmatch, pmatch, 0) == 0) { -+ user_string = ap_pregsub(r->pool, dconf->user_pattern, r->filename, nmatch, pmatch); -+ group_string = ap_pregsub(r->pool, dconf->group_pattern, r->filename, nmatch, pmatch); -+ -+ if (!(user_struct = getpwnam(user_string))) { -+ _DBG("%s: No such user: '%s' (regex: '%s', pattern: '%s')", -+ r->filename, user_string, dconf->user_regex_string, dconf->user_pattern); -+ retval = HTTP_INTERNAL_SERVER_ERROR; -+ } else if (!(group_struct = getgrnam(group_string))) { -+ _DBG("%s: No such group: '%s' (regex: '%s', pattern: '%s')", -+ r->filename, group_string, dconf->user_regex_string, dconf->group_pattern); -+ retval = HTTP_INTERNAL_SERVER_ERROR; -+ } else { -+ wanted_username = user_string; -+ wanted_uid = user_struct->pw_uid; -+ wanted_gid = group_struct->gr_gid; -+ } -+ } -+ } -+ - if (wanted_uid == -1 || wanted_gid == -1) { - wanted_uid = unixd_config.user_id; - wanted_gid = unixd_config.group_id; -@@ -1488,7 +1523,7 @@ - ap_lingering_close(r->connection); - exit(0); - } -- return OK; -+ return retval; - } - - static void itk_hooks(apr_pool_t *p) -@@ -1632,6 +1667,24 @@ - return NULL; - } - -+static const char *assign_user_id_regex (cmd_parms *cmd, itk_per_dir_conf *dconf, const char *regex, const char *user_string, const char *group_string) -+{ -+ ap_regex_t *compiled_regexp; -+ -+ compiled_regexp = ap_pregcomp(cmd->pool, regex, AP_REG_EXTENDED); -+ if (!compiled_regexp) { -+ return apr_pstrcat(cmd->pool, -+ "AssignUserFromPath: cannot compile regular expression '", -+ regex, "'", NULL); -+ } -+ -+ dconf->user_regex_string = apr_pstrdup(cmd->pool, regex); -+ dconf->user_regex = compiled_regexp; -+ dconf->user_pattern = apr_pstrdup(cmd->pool, user_string); -+ dconf->group_pattern = apr_pstrdup(cmd->pool, group_string); -+ return NULL; -+} -+ - static const char *set_max_clients_vhost (cmd_parms *cmd, void *dummy, const char *arg) - { - itk_server_conf *sconf = -@@ -1676,6 +1729,8 @@ - "Maximum value of MaxClients for this run of Apache"), - AP_INIT_TAKE2("AssignUserID", assign_user_id, NULL, RSRC_CONF|ACCESS_CONF, - "Tie a virtual host to a specific child process."), -+AP_INIT_TAKE3("AssignUserFromPath", assign_user_id_regex, NULL, RSRC_CONF|ACCESS_CONF, -+ "Use a regex to determine the user ID from a path in the file system. Use with care!"), - AP_INIT_TAKE1("MaxClientsVHost", set_max_clients_vhost, NULL, RSRC_CONF, - "Maximum number of children alive at the same time for this virtual host."), - AP_INIT_TAKE1("NiceValue", set_nice_value, NULL, RSRC_CONF|ACCESS_CONF, -@@ -1716,6 +1771,20 @@ - } else { - c->nice_value = parent->nice_value; - } -+ // The test for username != NULL means that we clear the regex settings if an -+ // explicit username is specified in a subdirectory, which is what I believe -+ // most people would expect. -+ if (child->user_regex_string != NULL || child->username != NULL) { -+ c->user_regex_string = child->user_regex_string; -+ c->user_regex = child->user_regex; -+ c->user_pattern = child->user_pattern; -+ c->group_pattern = child->group_pattern; -+ } else { -+ c->user_regex_string = parent->user_regex_string; -+ c->user_regex = parent->user_regex; -+ c->user_pattern = parent->user_pattern; -+ c->group_pattern = parent->group_pattern; -+ } - return c; - } - diff --git a/www/apache22-itk-mpm/pkg-descr b/www/apache22-itk-mpm/pkg-descr deleted file mode 100644 index 127e177..0000000 --- a/www/apache22-itk-mpm/pkg-descr +++ /dev/null @@ -1,5 +0,0 @@ -Apache 2.2 with the itk MPM enabled. - -WWW: http://httpd.apache.org/ -WWW: http://mpm-itk.sesse.net/ -WWW: http://www.pvv.ntnu.no/~knuta/mpm-itk/ diff --git a/www/apache22-peruser-mpm/Makefile b/www/apache22-peruser-mpm/Makefile deleted file mode 100644 index 704fe5c..0000000 --- a/www/apache22-peruser-mpm/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# $FreeBSD$ - -# Apache 2.2.X with peruser mpm 0.3.0-dc3 -# Peruser main url: http://telana.com/peruser.php -# Peruser patches: http://source.kood.ee/ -# This port contains the main patch, including the dc3 patch - -MASTERDIR= ${.CURDIR}/../apache22 - -MAINTAINER= ports@FreeBSD.org - -WITH_MPM= peruser - -DESCR= ${.CURDIR}/pkg-descr - -EXTRA_PATCHES+= ${.CURDIR}/files/httpd-2.2.3-peruser-0.3.0.patch -EXTRA_PATCHES+= ${.CURDIR}/files/httpd-2.2.3-peruser-0.3.0-dc3.patch -EXTRA_PATCHES+= ${.CURDIR}/files/httpd-2.2.3-peruser-0.3.0-dc3-r57.patch - -.include "${MASTERDIR}/Makefile" diff --git a/www/apache22-peruser-mpm/files/httpd-2.2.3-peruser-0.3.0-dc3-r57.patch b/www/apache22-peruser-mpm/files/httpd-2.2.3-peruser-0.3.0-dc3-r57.patch deleted file mode 100644 index 824821c..0000000 --- a/www/apache22-peruser-mpm/files/httpd-2.2.3-peruser-0.3.0-dc3-r57.patch +++ /dev/null @@ -1,275 +0,0 @@ ---- server/mpm/experimental/peruser/peruser.c (revision 55) -+++ server/mpm/experimental/peruser/peruser.c (revision 57) -@@ -320,7 +320,7 @@ - * process. - */ - static apr_size_t child_info_size; --static child_info *child_info_image; -+static child_info *child_info_image = NULL; - static child_grace_info_t *child_grace_info_table; - struct ap_ctable *ap_child_table; - -@@ -936,7 +936,7 @@ - msg.msg_iovlen = 5; - - cmsg = apr_palloc(pool, sizeof(*cmsg) + sizeof(sock_fd)); -- cmsg->cmsg_len = sizeof(*cmsg) + sizeof(sock_fd); -+ cmsg->cmsg_len = CMSG_LEN(sizeof(sock_fd)); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - -@@ -1034,9 +1034,10 @@ - ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "apr_os_sock_get"); - } - -- _DBG("child_num=%d sock=%ld sock_fd=%d\n", my_child_num, sock, sock_fd); -+ _DBG("child_num=%d sock=%ld sock_fd=%d", my_child_num, sock, sock_fd); - _DBG("type=%s %d", child_type_string(CHILD_INFO_TABLE[my_child_num].type), my_child_num); - -+#ifdef _OSD_POSIX - if (sock_fd >= FD_SETSIZE) - { - ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, -@@ -1048,6 +1049,7 @@ - _DBG("child_num=%d: exiting with error", my_child_num); - return; - } -+#endif - - if (CHILD_INFO_TABLE[my_child_num].sock_fd < 0) - { -@@ -1300,7 +1302,7 @@ - msg.msg_iovlen = 5; - - cmsg = apr_palloc(r->pool, sizeof(*cmsg) + sizeof(sock_fd)); -- cmsg->cmsg_len = sizeof(*cmsg) + sizeof(sock_fd); -+ cmsg->cmsg_len = CMSG_LEN(sizeof(sock_fd)); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - -@@ -1309,7 +1311,6 @@ - msg.msg_control = cmsg; - msg.msg_controllen = cmsg->cmsg_len; - -- - if (processor->status == CHILD_STATUS_STANDBY) - { - _DBG("Activating child #%d", processor->id); -@@ -1374,7 +1375,7 @@ - iov[3].iov_len = HUGE_STRING_LEN; - - cmsg = apr_palloc(ptrans, sizeof(*cmsg) + sizeof(trans_sock_fd)); -- cmsg->cmsg_len = sizeof(*cmsg) + sizeof(trans_sock_fd); -+ cmsg->cmsg_len = CMSG_LEN(sizeof(trans_sock_fd)); - - msg.msg_name = NULL; - msg.msg_namelen = 0; -@@ -1424,32 +1425,32 @@ - apr_cpystrn(headers, buff, header_len + 1); - _DBG("header_len=%d headers=\"%s\"", header_len, headers); - --if (header_len) { -- _DBG("header_len > 0, we got a request", 0); -- /* -- store received data into an brigade and add -- it to the current transaction's pool -- */ -- bucket = apr_bucket_eos_create(alloc); -- APR_BRIGADE_INSERT_HEAD(bb, bucket); -- bucket = apr_bucket_socket_create(*trans_sock, alloc); -- APR_BRIGADE_INSERT_HEAD(bb, bucket); -- -- if (body_len) { -- body = (char*)&buff[header_len + 1]; -- _DBG("body_len=%d body=\"%s\"", body_len, body); -- -- bucket = apr_bucket_heap_create(body, body_len, NULL, alloc); -+ if (header_len) { -+ _DBG("header_len > 0, we got a request", 0); -+ /* -- store received data into an brigade and add -+ it to the current transaction's pool -- */ -+ bucket = apr_bucket_eos_create(alloc); - APR_BRIGADE_INSERT_HEAD(bb, bucket); -+ bucket = apr_bucket_socket_create(*trans_sock, alloc); -+ APR_BRIGADE_INSERT_HEAD(bb, bucket); -+ -+ if (body_len) { -+ body = (char*)&buff[header_len + 1]; -+ _DBG("body_len=%d body=\"%s\"", body_len, body); -+ -+ bucket = apr_bucket_heap_create(body, body_len, NULL, alloc); -+ APR_BRIGADE_INSERT_HEAD(bb, bucket); -+ } else { -+ _DBG("There is no body",0); -+ } -+ -+ bucket = apr_bucket_heap_create(headers, header_len, NULL, alloc); -+ -+ APR_BRIGADE_INSERT_HEAD(bb, bucket); -+ apr_pool_userdata_set(bb, "PERUSER_SOCKETS", NULL, ptrans); - } else { -- _DBG("There is no body",0); -+ _DBG("header_len == 0, we got a socket only", 0); - } -- -- bucket = apr_bucket_heap_create(headers, header_len, NULL, alloc); -- -- APR_BRIGADE_INSERT_HEAD(bb, bucket); -- apr_pool_userdata_set(bb, "PERUSER_SOCKETS", NULL, ptrans); --} else { -- _DBG("header_len == 0, we got a socket only", 0); --} - _DBG("returning 0", 0); - return 0; - } -@@ -2608,6 +2609,12 @@ - ++ap_my_generation; - ap_scoreboard_image->global->running_generation = ap_my_generation; - -+ /* cleanup sockets */ -+ for (i = 0; i < NUM_SENV; i++) { -+ close(SENV[i].input); -+ close(SENV[i].output); -+ } -+ - if (is_graceful) { - char char_of_death = AP_PERUSER_CHAR_OF_DEATH; - -@@ -2696,14 +2703,6 @@ - } - _DBG("Total children of %d leaving behind for graceful restart (%d living)", - grace_children, grace_children_alive); -- -- /* destroy server_env_image */ -- for (i = 0; i < NUM_SENV; i++) -- { -- close(SENV[i].input); -- close(SENV[i].output); -- } -- cleanup_server_environments(NULL); - } - else { - /* Kill 'em off */ -@@ -2861,40 +2860,41 @@ - return rv; - } - -+ if (!child_info_image) { -+ _DBG("Initializing child_info_table", 0); -+ child_info_size = tmp_server_limit * sizeof(child_info_t) + sizeof(apr_size_t); - -- _DBG("Initializing child_info_table", 0); -- child_info_size = tmp_server_limit * sizeof(child_info_t) + sizeof(apr_size_t); -+ rv = apr_shm_create(&child_info_shm, child_info_size, NULL, global_pool); - -- rv = apr_shm_create(&child_info_shm, child_info_size, NULL, global_pool); -+ /* if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) { */ -+ if (rv != APR_SUCCESS) { -+ _DBG("shared memory creation failed", 0); - --/* if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) { */ -- if (rv != APR_SUCCESS) { -- _DBG("shared memory creation failed", 0); -+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, -+ "Unable to create shared memory segment " -+ "(anonymous shared memory failure)"); -+ } -+ else if (rv == APR_ENOTIMPL) { -+ _DBG("anonymous shared memory not available", 0); -+ /* TODO: make up a filename and do name-based shmem */ -+ } - -- ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, -- "Unable to create shared memory segment " -- "(anonymous shared memory failure)"); -- } -- else if (rv == APR_ENOTIMPL) { -- _DBG("anonymous shared memory not available", 0); -- /* TODO: make up a filename and do name-based shmem */ -- } -+ if (rv || !(shmem = apr_shm_baseaddr_get(child_info_shm))) { -+ _DBG("apr_shm_baseaddr_get() failed", 0); -+ return HTTP_INTERNAL_SERVER_ERROR; -+ } - -- if (rv || !(shmem = apr_shm_baseaddr_get(child_info_shm))) { -- _DBG("apr_shm_baseaddr_get() failed", 0); -- return HTTP_INTERNAL_SERVER_ERROR; -+ memset(shmem, 0, child_info_size); -+ child_info_image = (child_info*)apr_palloc(global_pool, sizeof(child_info)); -+ child_info_image->control = (child_info_control*)shmem; -+ shmem += sizeof(child_info_control); -+ child_info_image->table = (child_info_t*)shmem; - } - -- memset(shmem, 0, sizeof(child_info_size)); -- child_info_image = (child_info*)calloc(1, sizeof(child_info_size)); -- child_info_image->control = (child_info_control*)shmem; -- shmem += sizeof(child_info_control*); -- child_info_image->table = (child_info_t*)shmem; -- -+ _DBG("Clearing child_info_table"); - child_info_image->control->num = 0; - -- for (i = 0; i < tmp_server_limit; i++) -- { -+ for (i = 0; i < tmp_server_limit; i++) { - CHILD_INFO_TABLE[i].pid = 0; - CHILD_INFO_TABLE[i].senv = (server_env_t*)NULL; - CHILD_INFO_TABLE[i].type = CHILD_TYPE_UNKNOWN; -@@ -2927,25 +2927,23 @@ - return HTTP_INTERNAL_SERVER_ERROR; - } - -- memset(shmem, 0, sizeof(server_env_size)); -- server_env_image = (server_env*)calloc(1, sizeof(server_env_size)); -+ memset(shmem, 0, server_env_size); -+ server_env_image = (server_env*)apr_palloc(global_pool, sizeof(server_env)); - server_env_image->control = (server_env_control*)shmem; -- shmem += sizeof(server_env_control*); -+ shmem += sizeof(server_env_control); - server_env_image->table = (server_env_t*)shmem; - } -- -- if(restart_num <= 2) { -- _DBG("Cleaning server environments table"); - -- server_env_image->control->num = 0; -- for (i = 0; i < tmp_server_limit; i++) { -- SENV[i].processor_id = -1; -- SENV[i].uid = -1; -- SENV[i].gid = -1; -- SENV[i].chroot = NULL; -- SENV[i].input = -1; -- SENV[i].output = -1; -- } -+ _DBG("Clearing server environment table"); -+ server_env_image->control->num = 0; -+ -+ for (i = 0; i < tmp_server_limit; i++) { -+ SENV[i].processor_id = -1; -+ SENV[i].uid = -1; -+ SENV[i].gid = -1; -+ SENV[i].chroot = NULL; -+ SENV[i].input = -1; -+ SENV[i].output = -1; - } - - return OK; -@@ -3196,14 +3194,11 @@ - "Error: Directive %s> takes one argument", cmd->cmd->name); - } - -- /* Check for existing processors on first launch and between gracefuls */ -- if (restart_num == 1 || is_graceful) { -- server_env_t *old_senv = find_senv_by_name(senv.name); -+ server_env_t *old_senv = find_senv_by_name(senv.name); - -- if (old_senv) { -- return apr_psprintf(cmd->temp_pool, -- "Error: Processor %s already defined", senv.name); -- } -+ if (old_senv) { -+ return apr_psprintf(cmd->temp_pool, -+ "Error: Processor %s already defined", senv.name); - } - - senv.nice_lvl = 0; diff --git a/www/apache22-peruser-mpm/files/httpd-2.2.3-peruser-0.3.0-dc3.patch b/www/apache22-peruser-mpm/files/httpd-2.2.3-peruser-0.3.0-dc3.patch deleted file mode 100644 index 4a61ce7..0000000 --- a/www/apache22-peruser-mpm/files/httpd-2.2.3-peruser-0.3.0-dc3.patch +++ /dev/null @@ -1,1211 +0,0 @@ ---- server/mpm/experimental/peruser/mpm_default.h 2009-05-27 15:09:19.000000000 +0300 -+++ server/mpm/experimental/peruser/mpm_default.h 2009-05-28 10:10:42.000000000 +0300 -@@ -77,6 +77,12 @@ - #define DEFAULT_MIN_FREE_PROCESSORS 2 - #endif - -+/* Maximum --- more than this, and idle processors will be killed (0 = disable) */ -+ -+#ifndef DEFAULT_MAX_FREE_PROCESSORS -+#define DEFAULT_MAX_FREE_PROCESSORS 0 -+#endif -+ - /* Maximum processors per ServerEnvironment */ - - #ifndef DEFAULT_MAX_PROCESSORS -@@ -107,4 +113,50 @@ - #define DEFAULT_MAX_REQUESTS_PER_CHILD 10000 - #endif - -+/* Maximum multiplexers */ -+ -+#ifndef DEFAULT_MAX_MULTIPLEXERS -+#define DEFAULT_MAX_MULTIPLEXERS 20 -+#endif -+ -+/* Minimum multiplexers */ -+ -+#ifndef DEFAULT_MIN_MULTIPLEXERS -+#define DEFAULT_MIN_MULTIPLEXERS 3 -+#endif -+ -+/* Amount of time a child can run before it expires (0 = turn off) */ -+ -+#ifndef DEFAULT_EXPIRE_TIMEOUT -+#define DEFAULT_EXPIRE_TIMEOUT 1800 -+#endif -+ -+/* Amount of time a child can stay idle (0 = turn off) */ -+ -+#ifndef DEFAULT_IDLE_TIMEOUT -+#define DEFAULT_IDLE_TIMEOUT 900 -+#endif -+ -+/* Amount of time a multiplexer can stay idle (0 = turn off) */ -+ -+#ifndef DEFAULT_MULTIPLEXER_IDLE_TIMEOUT -+#define DEFAULT_MULTIPLEXER_IDLE_TIMEOUT 0 -+#endif -+ -+/* Amount of maximum time a multiplexer can wait for processor if it is busy (0 = never wait) -+ * This is decreased with every busy request -+ */ -+ -+#ifndef DEFAULT_PROCESSOR_WAIT_TIMEOUT -+#define DEFAULT_PROCESSOR_WAIT_TIMEOUT 5 -+#endif -+ -+/* The number of different levels there are when a multiplexer is waiting for processor -+ * (between maximum waiting time and no waiting) -+ */ -+ -+#ifndef DEFAULT_PROCESSOR_WAIT_STEPS -+#define DEFAULT_PROCESSOR_WAIT_STEPS 10 -+#endif -+ - #endif /* AP_MPM_DEFAULT_H */ ---- server/mpm/experimental/peruser/mpm.h 2009-03-22 22:46:45.000000000 +0200 -+++ server/mpm/experimental/peruser/mpm.h 2009-03-22 22:39:10.000000000 +0200 -@@ -84,6 +84,7 @@ - #define AP_MPM_USES_POD 1 - #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid) - #define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0) -+#define MPM_VALID_PID(p) (getpgid(p) == getpgrp()) - #define MPM_ACCEPT_FUNC unixd_accept - - extern int ap_threads_per_child; ---- server/mpm/experimental/peruser/peruser.c 2009-05-27 15:09:19.000000000 +0300 -+++ server/mpm/experimental/peruser/peruser.c 2009-05-28 13:54:27.000000000 +0300 -@@ -195,20 +195,30 @@ - - #define CHILD_STATUS_STANDBY 0 /* wait for a request before starting */ - #define CHILD_STATUS_STARTING 1 /* wait for socket creation */ --#define CHILD_STATUS_READY 2 /* wait for mux to restart */ --#define CHILD_STATUS_ACTIVE 3 /* ready to take requests */ -+#define CHILD_STATUS_READY 2 /* is ready to take requests */ -+#define CHILD_STATUS_ACTIVE 3 /* is currently busy handling requests */ - #define CHILD_STATUS_RESTART 4 /* child about to die and restart */ - -+/* cgroup settings */ -+#define CGROUP_TASKS_FILE "/tasks" -+#define CGROUP_TASKS_FILE_LEN 7 -+ - /* config globals */ - - int ap_threads_per_child=0; /* Worker threads per child */ - static apr_proc_mutex_t *accept_mutex; - static int ap_min_processors=DEFAULT_MIN_PROCESSORS; - static int ap_min_free_processors=DEFAULT_MIN_FREE_PROCESSORS; -+static int ap_max_free_processors=DEFAULT_MAX_FREE_PROCESSORS; - static int ap_max_processors=DEFAULT_MAX_PROCESSORS; -+static int ap_min_multiplexers=DEFAULT_MIN_MULTIPLEXERS; -+static int ap_max_multiplexers=DEFAULT_MAX_MULTIPLEXERS; - static int ap_daemons_limit=0; /* MaxClients */ --static int expire_timeout=1800; --static int idle_timeout=900; -+static int expire_timeout=DEFAULT_EXPIRE_TIMEOUT; -+static int idle_timeout=DEFAULT_IDLE_TIMEOUT; -+static int multiplexer_idle_timeout=DEFAULT_MULTIPLEXER_IDLE_TIMEOUT; -+static int processor_wait_timeout=DEFAULT_PROCESSOR_WAIT_TIMEOUT; -+static int processor_wait_steps=DEFAULT_PROCESSOR_WAIT_STEPS; - static int server_limit = DEFAULT_SERVER_LIMIT; - static int first_server_limit; - static int changed_limit_at_restart; -@@ -222,15 +232,21 @@ - { - int processor_id; - -+ const char *name; /* Server environment's unique string identifier */ -+ - /* security settings */ - uid_t uid; /* user id */ - gid_t gid; /* group id */ - const char *chroot; /* directory to chroot() to, can be null */ -+ int nice_lvl; -+ const char *cgroup; /* cgroup directory, can be null */ - - /* resource settings */ - int min_processors; - int min_free_processors; -+ int max_free_processors; - int max_processors; -+ int availability; - - /* sockets */ - int input; /* The socket descriptor */ -@@ -437,6 +453,25 @@ - return "UNKNOWN"; - } - -+char* scoreboard_status_string(int status) { -+ switch(status) -+ { -+ case SERVER_DEAD: return "DEAD"; -+ case SERVER_STARTING: return "STARTING"; -+ case SERVER_READY: return "READY"; -+ case SERVER_BUSY_READ: return "BUSY_READ"; -+ case SERVER_BUSY_WRITE: return "BUSY_WRITE"; -+ case SERVER_BUSY_KEEPALIVE: return "BUSY_KEEPALIVE"; -+ case SERVER_BUSY_LOG: return "BUSY_LOG"; -+ case SERVER_BUSY_DNS: return "BUSY_DNS"; -+ case SERVER_CLOSING: return "CLOSING"; -+ case SERVER_GRACEFUL: return "GRACEFUL"; -+ case SERVER_NUM_STATUS: return "NUM_STATUS"; -+ } -+ -+ return "UNKNOWN"; -+} -+ - void dump_child_table() - { - #ifdef MPM_PERUSER_DEBUG -@@ -511,10 +546,6 @@ - - static void accept_mutex_on(void) - { --/* for some reason this fails if we listen on the pipe_of_death. -- fortunately I don't think we currently need it */ -- --#if 0 - apr_status_t rv = apr_proc_mutex_lock(accept_mutex); - if (rv != APR_SUCCESS) { - const char *msg = "couldn't grab the accept mutex"; -@@ -529,12 +560,10 @@ - exit(APEXIT_CHILDFATAL); - } - } --#endif - } - - static void accept_mutex_off(void) - { --#if 0 - apr_status_t rv = apr_proc_mutex_unlock(accept_mutex); - if (rv != APR_SUCCESS) { - const char *msg = "couldn't release the accept mutex"; -@@ -552,7 +581,6 @@ - exit(APEXIT_CHILDFATAL); - } - } --#endif - } - - /* On some architectures it's safe to do unserialized accept()s in the single -@@ -715,8 +743,10 @@ - ret = apr_socket_recv(lr->sd, &pipe_read_char, &n); - if (APR_STATUS_IS_EAGAIN(ret)) - { -- /* It lost the lottery. It must continue to suffer -- * through a life of servitude. */ -+ /* It lost the lottery. It must continue to suffer -+ * through a life of servitude. */ -+ _DBG("POD read EAGAIN"); -+ return ret; - } - else - { -@@ -1087,8 +1117,7 @@ - for(i = 0, total = 0; i < NUM_CHILDS; ++i) - { - if(CHILD_INFO_TABLE[i].senv == CHILD_INFO_TABLE[child_num].senv && -- (SCOREBOARD_STATUS(i) == SERVER_STARTING || -- SCOREBOARD_STATUS(i) == SERVER_READY)) -+ (CHILD_INFO_TABLE[i].status == CHILD_STATUS_READY)) - { - total++; - } -@@ -1116,7 +1145,7 @@ - apr_bucket *bucket; - const apr_array_header_t *headers_in_array; - const apr_table_entry_t *headers_in; -- int counter; -+ int counter, wait_time, wait_step_size; - - apr_socket_t *thesock = ap_get_module_config(r->connection->conn_config, &core_module); - -@@ -1137,10 +1166,73 @@ - apr_table_get(r->headers_in, "Host"), my_child_num, processor->senv->output); - _DBG("r->the_request=\"%s\" len=%d", r->the_request, strlen(r->the_request)); - -- ap_get_brigade(r->connection->input_filters, bb, AP_MODE_EXHAUSTIVE, APR_NONBLOCK_READ, len); -+ wait_step_size = 100 / processor_wait_steps; - -- /* Scan the brigade looking for heap-buckets */ -+ /* Check if the processor is available */ -+ if (total_processors(processor->id) == processor->senv->max_processors && -+ idle_processors(processor->id) == 0) { -+ /* The processor is currently busy, try to wait (a little) */ -+ _DBG("processor seems to be busy, trying to wait for it"); -+ -+ if (processor->senv->availability == 0) { -+ processor->senv->availability = 0; -+ -+ _DBG("processor is very busy (availability = 0) - not passing request"); -+ -+ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf, -+ "Too many requests for processor %s, increase MaxProcessors", processor->senv->name); -+ -+ /* No point in waiting for the processor, it's very busy */ -+ return -1; -+ } -+ -+ /* We sleep a little (depending how available the processor usually is) */ -+ int i; -+ -+ wait_time = (processor_wait_timeout / processor_wait_steps) * 1000000; -+ -+ for(i = 0; i <= processor->senv->availability; i += wait_step_size) { -+ usleep(wait_time); - -+ /* Check if the processor is ready */ -+ if (total_processors(processor->id) < processor->senv->max_processors || -+ idle_processors(processor->id) > 0) { -+ /* The processor has freed - lets use it */ -+ _DBG("processor freed before wait time expired"); -+ break; -+ } -+ } -+ -+ if (processor->senv->availability <= wait_step_size) { -+ processor->senv->availability = 0; -+ } -+ else processor->senv->availability -= wait_step_size; -+ -+ /* Check if we waited all the time */ -+ if (i > processor->senv->availability) { -+ _DBG("processor is busy - not passing request (availability = %d)", -+ processor->senv->availability); -+ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf, -+ "Too many requests for processor %s, increase MaxProcessors", processor->senv->name); -+ return -1; -+ } -+ -+ /* We could increase the availability a little here, -+ * because the processor got freed eventually -+ */ -+ } -+ else { -+ /* Smoothly increment the availability back to 100 */ -+ if (processor->senv->availability >= 100-wait_step_size) { -+ processor->senv->availability = 100; -+ } -+ else processor->senv->availability += wait_step_size; -+ } -+ -+ ap_get_brigade(r->connection->input_filters, bb, AP_MODE_EXHAUSTIVE, APR_NONBLOCK_READ, len); -+ -+ /* Scan the brigade looking for heap-buckets */ -+ - _DBG("Scanning the brigade",0); - bucket = APR_BRIGADE_FIRST(bb); - while (bucket != APR_BRIGADE_SENTINEL(bb) && -@@ -1294,12 +1386,22 @@ - /* -- receive data from socket -- */ - apr_os_sock_get(&ctrl_sock_fd, lr->sd); - _DBG("receiving from sock_fd=%d", ctrl_sock_fd); -- ret = recvmsg(ctrl_sock_fd, &msg, 0); - -- if(ret == -1) -- _DBG("recvmsg failed with error \"%s\"", strerror(errno)); -- else -- _DBG("recvmsg returned %d", ret); -+ // Don't block -+ ret = recvmsg(ctrl_sock_fd, &msg, MSG_DONTWAIT); -+ -+ if (ret == -1 && errno == EAGAIN) { -+ _DBG("receive_from_multiplexer recvmsg() EAGAIN, someone was faster"); -+ -+ return APR_EAGAIN; -+ } -+ else if (ret == -1) { -+ _DBG("recvmsg failed with error \"%s\"", strerror(errno)); -+ -+ // Error, better kill this child to be on the safe side -+ return APR_EGENERAL; -+ } -+ else _DBG("recvmsg returned %d", ret); - - /* -- extract socket from the cmsg -- */ - memcpy(&trans_sock_fd, CMSG_DATA(cmsg), sizeof(trans_sock_fd)); -@@ -1399,10 +1501,58 @@ - return 0; - } - --static int peruser_setup_child(int childnum) -+static int peruser_setup_cgroup(int childnum, server_env_t *senv, apr_pool_t *pool) -+{ -+ apr_file_t *file; -+ int length; -+ apr_size_t content_len; -+ char *tasks_file, *content, *pos; -+ -+ _DBG("starting to add pid to cgroup %s", senv->cgroup); -+ -+ length = strlen(senv->cgroup) + CGROUP_TASKS_FILE_LEN; -+ tasks_file = malloc(length); -+ -+ if (!tasks_file) return -1; -+ -+ pos = apr_cpystrn(tasks_file, senv->cgroup, length); -+ apr_cpystrn(pos, CGROUP_TASKS_FILE, CGROUP_TASKS_FILE_LEN); -+ -+ /* Prepare the data to be written to tasks file */ -+ content = apr_itoa(pool, ap_my_pid); -+ content_len = strlen(content); -+ -+ _DBG("writing pid %s to tasks file %s", content, tasks_file); -+ -+ if (apr_file_open(&file, tasks_file, APR_WRITE, APR_OS_DEFAULT, pool)) { -+ ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL, -+ "cgroup: unable to open file %s", -+ tasks_file); -+ free(tasks_file); -+ return OK; /* don't fail if cgroup not available */ -+ } -+ -+ if (apr_file_write(file, content, &content_len)) { -+ ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL, -+ "cgroup: unable to write pid to file %s", -+ tasks_file); -+ } -+ -+ apr_file_close(file); -+ -+ free(tasks_file); -+ -+ return OK; -+} -+ -+static int peruser_setup_child(int childnum, apr_pool_t *pool) - { - server_env_t *senv = CHILD_INFO_TABLE[childnum].senv; - -+ if (senv->nice_lvl != 0) { -+ nice(senv->nice_lvl); -+ } -+ - if(senv->chroot) { - _DBG("chdir to %s", senv->chroot); - if(chdir(senv->chroot)) { -@@ -1421,6 +1571,10 @@ - } - } - -+ if(senv->cgroup) { -+ peruser_setup_cgroup(childnum, senv, pool); -+ } -+ - if (senv->uid == -1 && senv->gid == -1) { - return unixd_setup_child(); - } -@@ -1594,15 +1748,6 @@ - { - case CHILD_TYPE_MULTIPLEXER: - _DBG("MULTIPLEXER %d", my_child_num); -- -- /* update status on processors that are ready to accept requests */ -- _DBG("updating processor stati", 0); -- for(i = 0; i < NUM_CHILDS; ++i) -- { -- if(CHILD_INFO_TABLE[i].status == CHILD_STATUS_READY) -- CHILD_INFO_TABLE[i].status = CHILD_STATUS_ACTIVE; -- } -- - break; - - case CHILD_TYPE_PROCESSOR: -@@ -1626,7 +1771,7 @@ - apr_os_sock_put(&pod_sock, &fd, pconf); - listen_add(pconf, pod_sock, check_pipe_of_death); - -- if(peruser_setup_child(my_child_num) != 0) -+ if(peruser_setup_child(my_child_num, pchild) != 0) - clean_child_exit(APEXIT_CHILDFATAL); - - ap_run_child_init(pchild, ap_server_conf); -@@ -1670,14 +1815,19 @@ - clean_child_exit(0); - } - -- (void) ap_update_child_status(sbh, SERVER_READY, (request_rec *) NULL); -+ (void) ap_update_child_status(sbh, SERVER_READY, (request_rec *) NULL); -+ -+ CHILD_INFO_TABLE[my_child_num].status = CHILD_STATUS_READY; -+ _DBG("Child %d (%s) is now ready", my_child_num, child_type_string(CHILD_INFO_TABLE[my_child_num].type)); - - /* - * Wait for an acceptable connection to arrive. - */ - -- /* Lock around "accept", if necessary */ -- SAFE_ACCEPT(accept_mutex_on()); -+ /* Lock around "accept", if necessary */ -+ if (CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER) { -+ SAFE_ACCEPT(accept_mutex_on()); -+ } - - if (num_listensocks == 1) { - offset = 0; -@@ -1729,18 +1879,27 @@ - * defer the exit - */ - status = listensocks[offset].accept_func((void *)&sock, &listensocks[offset], ptrans); -- SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */ -+ -+ if (CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER) { -+ SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */ -+ } - - if (status == APR_EGENERAL) { - /* resource shortage or should-not-occur occurred */ - clean_child_exit(1); - } -- else if (status != APR_SUCCESS || die_now) { -+ else if (status != APR_SUCCESS || die_now || sock == NULL) { - continue; - } - -+ if (CHILD_INFO_TABLE[my_child_num].status == CHILD_STATUS_READY) { -+ CHILD_INFO_TABLE[my_child_num].status = CHILD_STATUS_ACTIVE; -+ _DBG("Child %d (%s) is now active", my_child_num, child_type_string(CHILD_INFO_TABLE[my_child_num].type)); -+ } -+ - if (CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_PROCESSOR || -- CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_WORKER) -+ CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_WORKER || -+ CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER) - { - _DBG("CHECKING IF WE SHOULD CLONE A CHILD..."); - -@@ -1754,8 +1913,11 @@ - - if(total_processors(my_child_num) < - CHILD_INFO_TABLE[my_child_num].senv->max_processors && -- idle_processors(my_child_num) <= -- CHILD_INFO_TABLE[my_child_num].senv->min_free_processors) -+ (idle_processors(my_child_num) <= -+ CHILD_INFO_TABLE[my_child_num].senv->min_free_processors || -+ total_processors(my_child_num) < -+ CHILD_INFO_TABLE[my_child_num].senv->min_processors -+ )) - { - _DBG("CLONING CHILD"); - child_clone(); -@@ -1804,46 +1966,80 @@ - clean_child_exit(0); - } - --static server_env_t* senv_add(int uid, int gid, const char* chroot) --{ -+static server_env_t* find_senv_by_name(const char *name) { - int i; -- int socks[2]; - -- _DBG("Searching for matching senv..."); -+ if (name == NULL) return NULL; -+ -+ _DBG("name=%s", name); -+ -+ for(i = 0; i < NUM_SENV; i++) -+ { -+ if(SENV[i].name != NULL && !strcmp(SENV[i].name, name)) { -+ return &SENV[i]; -+ } -+ } -+ -+ return NULL; -+} -+ -+static server_env_t* find_matching_senv(server_env_t* senv) { -+ int i; -+ -+ _DBG("name=%s uid=%d gid=%d chroot=%s", senv->name, senv->uid, senv->gid, senv->chroot); - - for(i = 0; i < NUM_SENV; i++) -- { -- if(SENV[i].uid == uid && SENV[i].gid == gid && -- (SENV[i].chroot == NULL || !strcmp(SENV[i].chroot, chroot))) - { -- _DBG("Found existing senv: %i", i); -- return &SENV[i]; -+ if((senv->name != NULL && SENV[i].name != NULL && !strcmp(SENV[i].name, senv->name)) || -+ (senv->name == NULL && SENV[i].uid == senv->uid && SENV[i].gid == senv->gid && -+ ( -+ (SENV[i].chroot == NULL && senv->chroot == NULL) || -+ ((SENV[i].chroot != NULL || senv->chroot != NULL) && !strcmp(SENV[i].chroot, senv->chroot))) -+ ) -+ ) { -+ return &SENV[i]; -+ } - } -+ -+ return NULL; -+} -+ -+static server_env_t* senv_add(server_env_t *senv) -+{ -+ int socks[2]; -+ server_env_t *old_senv; -+ -+ _DBG("Searching for matching senv..."); -+ -+ old_senv = find_matching_senv(senv); -+ -+ if (old_senv) { -+ _DBG("Found existing senv"); -+ senv = old_senv; -+ return old_senv; - } - - if(NUM_SENV >= server_limit) -- { -- _DBG("server_limit reached!"); -- return NULL; -- } -+ { -+ _DBG("server_limit reached!"); -+ return NULL; -+ } - - _DBG("Creating new senv"); - -- SENV[NUM_SENV].uid = uid; -- SENV[NUM_SENV].gid = gid; -- SENV[NUM_SENV].chroot = chroot; -- -- SENV[NUM_SENV].min_processors = ap_min_processors; -- SENV[NUM_SENV].min_free_processors = ap_min_free_processors; -- SENV[NUM_SENV].max_processors = ap_max_processors; -+ memcpy(&SENV[NUM_SENV], senv, sizeof(server_env_t)); -+ -+ SENV[NUM_SENV].availability = 100; - - socketpair(PF_UNIX, SOCK_STREAM, 0, socks); - SENV[NUM_SENV].input = socks[0]; - SENV[NUM_SENV].output = socks[1]; - -+ senv = &SENV[NUM_SENV]; - return &SENV[server_env_image->control->num++]; - } - -+ - static const char* child_clone() - { - int i; -@@ -1869,7 +2065,14 @@ - new = &CHILD_INFO_TABLE[i]; - - new->senv = this->senv; -- new->type = CHILD_TYPE_WORKER; -+ -+ if (this->type == CHILD_TYPE_MULTIPLEXER) { -+ new->type = CHILD_TYPE_MULTIPLEXER; -+ } -+ else { -+ new->type = CHILD_TYPE_WORKER; -+ } -+ - new->sock_fd = this->sock_fd; - new->status = CHILD_STATUS_STARTING; - -@@ -1878,7 +2081,7 @@ - } - - static const char* child_add(int type, int status, -- apr_pool_t *pool, uid_t uid, gid_t gid, const char* chroot) -+ apr_pool_t *pool, server_env_t *senv) - { - _DBG("adding child #%d", NUM_CHILDS); - -@@ -1888,10 +2091,10 @@ - "Increase NumServers in your config file."; - } - -- if (chroot && !ap_is_directory(pool, chroot)) -- return apr_psprintf(pool, "Error: chroot directory [%s] does not exist", chroot); -+ if (senv->chroot && !ap_is_directory(pool, senv->chroot)) -+ return apr_psprintf(pool, "Error: chroot directory [%s] does not exist", senv->chroot); - -- CHILD_INFO_TABLE[NUM_CHILDS].senv = senv_add(uid, gid, chroot); -+ CHILD_INFO_TABLE[NUM_CHILDS].senv = senv_add(senv); - - if(CHILD_INFO_TABLE[NUM_CHILDS].senv == NULL) - { -@@ -1907,10 +2110,10 @@ - CHILD_INFO_TABLE[NUM_CHILDS].status = status; - - _DBG("[%d] uid=%d gid=%d type=%d chroot=%s", -- NUM_CHILDS, uid, gid, type, -- chroot); -+ NUM_CHILDS, senv->uid, senv->gid, type, -+ senv->chroot); - -- if (uid == 0 || gid == 0) -+ if (senv->uid == 0 || senv->gid == 0) - { - _DBG("Assigning root user/group to a child.", 0); - } -@@ -1957,7 +2160,7 @@ - (void) ap_update_child_status_from_indexes(slot, 0, SERVER_STARTING, - (request_rec *) NULL); - -- CHILD_INFO_TABLE[slot].status = CHILD_STATUS_ACTIVE; -+ CHILD_INFO_TABLE[slot].status = CHILD_STATUS_READY; - - - #ifdef _OSD_POSIX -@@ -2062,19 +2265,31 @@ - if(CHILD_INFO_TABLE[i].status == CHILD_STATUS_STARTING) - make_child(ap_server_conf, i); - } -- else if(((CHILD_INFO_TABLE[i].type == CHILD_TYPE_PROCESSOR || -- CHILD_INFO_TABLE[i].type == CHILD_TYPE_WORKER) && -- ap_scoreboard_image->parent[i].pid > 1) && -- (idle_processors (i) > 1 || total_processes (i) == 1) && ( -- (expire_timeout > 0 && ap_scoreboard_image->servers[i][0].status != SERVER_DEAD && -- apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > expire_timeout) || -- (idle_timeout > 0 && ap_scoreboard_image->servers[i][0].status == SERVER_READY && -- apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > idle_timeout))) -+ else if( -+ (((CHILD_INFO_TABLE[i].type == CHILD_TYPE_PROCESSOR || -+ CHILD_INFO_TABLE[i].type == CHILD_TYPE_WORKER) && -+ ap_scoreboard_image->parent[i].pid > 1) && -+ (idle_processors (i) > CHILD_INFO_TABLE[i].senv->min_free_processors || CHILD_INFO_TABLE[i].senv->min_free_processors == 0) && -+ total_processes (i) > CHILD_INFO_TABLE[i].senv->min_processors && -+ ( -+ (expire_timeout > 0 && ap_scoreboard_image->servers[i][0].status != SERVER_DEAD && -+ apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > expire_timeout) || -+ (idle_timeout > 0 && ap_scoreboard_image->servers[i][0].status == SERVER_READY && -+ apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > idle_timeout) || -+ (CHILD_INFO_TABLE[i].senv->max_free_processors > 0 && CHILD_INFO_TABLE[i].status == CHILD_STATUS_READY && -+ idle_processors(i) > CHILD_INFO_TABLE[i].senv->max_free_processors)) -+ ) -+ || (CHILD_INFO_TABLE[i].type == CHILD_TYPE_MULTIPLEXER && -+ (multiplexer_idle_timeout > 0 && ap_scoreboard_image->servers[i][0].status == SERVER_READY && -+ apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > multiplexer_idle_timeout) && -+ total_processors(i) > CHILD_INFO_TABLE[i].senv->min_processors -+ ) -+ ) - { - CHILD_INFO_TABLE[i].pid = 0; - CHILD_INFO_TABLE[i].status = CHILD_STATUS_STANDBY; - -- if(CHILD_INFO_TABLE[i].type == CHILD_TYPE_WORKER) -+ if(CHILD_INFO_TABLE[i].type == CHILD_TYPE_WORKER || CHILD_INFO_TABLE[i].type == CHILD_TYPE_MULTIPLEXER) - { - /* completely free up this slot */ - -@@ -2173,7 +2388,6 @@ - return 1; - } - --#if 0 - #if APR_USE_SYSVSEM_SERIALIZE - if (ap_accept_lock_mech == APR_LOCK_DEFAULT || - ap_accept_lock_mech == APR_LOCK_SYSVSEM) { -@@ -2189,7 +2403,6 @@ - return 1; - } - } --#endif - - if (!is_graceful) { - if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) { -@@ -2598,7 +2811,10 @@ - ap_listen_pre_config(); - ap_min_processors = DEFAULT_MIN_PROCESSORS; - ap_min_free_processors = DEFAULT_MIN_FREE_PROCESSORS; -+ ap_max_free_processors = DEFAULT_MAX_FREE_PROCESSORS; - ap_max_processors = DEFAULT_MAX_PROCESSORS; -+ ap_min_multiplexers = DEFAULT_MIN_MULTIPLEXERS; -+ ap_max_multiplexers = DEFAULT_MAX_MULTIPLEXERS; - ap_daemons_limit = server_limit; - ap_pid_fname = DEFAULT_PIDLOG; - ap_lock_fname = DEFAULT_LOCKFILE; -@@ -2608,6 +2824,13 @@ - ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED; - #endif - -+ expire_timeout = DEFAULT_EXPIRE_TIMEOUT; -+ idle_timeout = DEFAULT_IDLE_TIMEOUT; -+ multiplexer_idle_timeout = DEFAULT_MULTIPLEXER_IDLE_TIMEOUT; -+ processor_wait_timeout = DEFAULT_PROCESSOR_WAIT_TIMEOUT; -+ processor_wait_steps = DEFAULT_PROCESSOR_WAIT_STEPS; -+ -+ - apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); - - /* we need to know ServerLimit and ThreadLimit before we start processing -@@ -2709,11 +2932,13 @@ - server_env_image->control = (server_env_control*)shmem; - shmem += sizeof(server_env_control*); - server_env_image->table = (server_env_t*)shmem; -+ } - -+ if(restart_num <= 2) { -+ _DBG("Cleaning server environments table"); -+ - server_env_image->control->num = 0; -- -- for (i = 0; i < tmp_server_limit; i++) -- { -+ for (i = 0; i < tmp_server_limit; i++) { - SENV[i].processor_id = -1; - SENV[i].uid = -1; - SENV[i].gid = -1; -@@ -2781,8 +3006,8 @@ - if (pass_request(r, processor) == -1) - { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, -- ap_server_conf, "Could not pass request to proper " "child, request will not be honoured."); -- return DECLINED; -+ ap_server_conf, "Could not pass request to processor %s (virtualhost %s), request will not be honoured.", -+ processor->senv->name, r->hostname); - } - _DBG("doing longjmp",0); - longjmp(CHILD_INFO_TABLE[my_child_num].jmpbuffer, 1); -@@ -2859,32 +3084,37 @@ - ap_rputs("<hr>\n", r); - ap_rputs("<h2>peruser status</h2>\n", r); - ap_rputs("<table border=\"0\">\n", r); -- ap_rputs("<tr><td>ID</td><td>PID</td><td>STATUS</td><td>TYPE</td><td>UID</td>" -- "<td>GID</td><td>CHROOT</td><td>INPUT</td>" -+ ap_rputs("<tr><td>ID</td><td>PID</td><td>STATUS</td><td>SB STATUS</td><td>TYPE</td><td>UID</td>" -+ "<td>GID</td><td>CHROOT</td><td>NICE</td><td>INPUT</td>" - "<td>OUTPUT</td><td>SOCK_FD</td>" - "<td>TOTAL PROCESSORS</td><td>MAX PROCESSORS</td>" -- "<td>IDLE PROCESSORS</td><td>MIN FREE PROCESSORS</td></tr>\n", r); -+ "<td>IDLE PROCESSORS</td><td>MIN FREE PROCESSORS</td>" -+ "<td>AVAIL</td>" -+ "</tr>\n", r); - for (x = 0; x < NUM_CHILDS; x++) - { - senv = CHILD_INFO_TABLE[x].senv; -- ap_rprintf(r, "<tr><td>%3d</td><td>%5d</td><td>%8s</td><td>%12s</td>" -- "<td>%4d</td><td>%4d</td><td>%25s</td><td>%5d</td>" -+ ap_rprintf(r, "<tr><td>%3d</td><td>%5d</td><td>%8s</td><td>%8s</td><td>%12s</td>" -+ "<td>%4d</td><td>%4d</td><td>%25s</td><td>%3d</td><td>%5d</td>" - "<td>%6d</td><td>%7d</td><td>%d</td><td>%d</td>" -- "<td>%d</td><td>%d</td></tr>\n", -+ "<td>%d</td><td>%d</td><td>%3d</td></tr>\n", - CHILD_INFO_TABLE[x].id, - CHILD_INFO_TABLE[x].pid, - child_status_string(CHILD_INFO_TABLE[x].status), -+ scoreboard_status_string(SCOREBOARD_STATUS(x)), - child_type_string(CHILD_INFO_TABLE[x].type), - senv == NULL ? -1 : senv->uid, - senv == NULL ? -1 : senv->gid, - senv == NULL ? NULL : senv->chroot, -+ senv == NULL ? 0 : senv->nice_lvl, - senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->input, - senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->output, - CHILD_INFO_TABLE[x].sock_fd, - total_processors(x), - senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->max_processors, - idle_processors(x), -- senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->min_free_processors -+ senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->min_free_processors, -+ senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->availability - ); - } - ap_rputs("</table>\n", r); -@@ -2938,50 +3168,183 @@ - APR_OPTIONAL_HOOK(ap, status_hook, peruser_status_hook, NULL, NULL, APR_HOOK_MIDDLE); - } - --/* we define an Processor w/ specific uid/gid */ --static const char *cf_Processor(cmd_parms *cmd, void *dummy, -- const char *user_name, const char *group_name, const char *chroot) -+static const char *cf_Processor(cmd_parms *cmd, void *dummy, const char *arg) - { -- uid_t uid = ap_uname2id(user_name); -- gid_t gid = ap_gname2id(group_name); -+ const char *user_name = NULL, *group_name = NULL, *directive; -+ server_env_t senv; -+ ap_directive_t *current; -+ -+ const char *endp = ap_strrchr_c(arg, '>'); -+ -+ if (endp == NULL) { -+ return apr_psprintf(cmd->temp_pool, -+ "Error: Directive %s> missing closing '>'", cmd->cmd->name); -+ } -+ -+ arg = apr_pstrndup(cmd->pool, arg, endp - arg); -+ -+ if (!arg) { -+ return apr_psprintf(cmd->temp_pool, -+ "Error: %s> must specify a processor name", cmd->cmd->name); -+ } -+ -+ senv.name = ap_getword_conf(cmd->pool, &arg); -+ _DBG("processor_name: %s", senv.name); -+ -+ if (strlen(senv.name) == 0) { -+ return apr_psprintf(cmd->temp_pool, -+ "Error: Directive %s> takes one argument", cmd->cmd->name); -+ } -+ -+ /* Check for existing processors on first launch and between gracefuls */ -+ if (restart_num == 1 || is_graceful) { -+ server_env_t *old_senv = find_senv_by_name(senv.name); -+ -+ if (old_senv) { -+ return apr_psprintf(cmd->temp_pool, -+ "Error: Processor %s already defined", senv.name); -+ } -+ } -+ -+ senv.nice_lvl = 0; -+ senv.chroot = NULL; -+ senv.cgroup = NULL; -+ senv.min_processors = ap_min_processors; -+ senv.min_free_processors = ap_min_free_processors; -+ senv.max_free_processors = ap_max_free_processors; -+ senv.max_processors = ap_max_processors; -+ -+ current = cmd->directive->first_child; -+ -+ int proc_temp = 0; -+ for(; current != NULL; current = current->next) { -+ directive = current->directive; -+ -+ if (!strcasecmp(directive, "user")) { -+ user_name = current->args; -+ } -+ else if (!strcasecmp(directive, "group")) { -+ group_name = current->args; -+ } -+ else if (!strcasecmp(directive, "chroot")) { -+ senv.chroot = ap_getword_conf(cmd->pool, ¤t->args); -+ } -+ else if (!strcasecmp(directive, "nicelevel")) { -+ senv.nice_lvl = atoi(current->args); -+ } -+ else if (!strcasecmp(directive, "maxprocessors")) { -+ proc_temp = atoi(current->args); -+ -+ if (proc_temp < 1) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: Require MaxProcessors > 0, setting to 1"); -+ proc_temp = 1; -+ } -+ -+ senv.max_processors = proc_temp; -+ } -+ else if (!strcasecmp(directive, "minprocessors")) { -+ proc_temp = atoi(current->args); -+ -+ if (proc_temp < 0) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: Require MinProcessors >= 0, setting to 0"); -+ proc_temp = 0; -+ } -+ -+ senv.min_processors = proc_temp; -+ } -+ else if (!strcasecmp(directive, "minspareprocessors")) { -+ proc_temp = atoi(current->args); - -- _DBG("user=%s:%d group=%s:%d chroot=%s", -- user_name, uid, group_name, gid, chroot); -+ if (proc_temp < 0) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: Require MinSpareProcessors >= 0, setting to 0"); -+ proc_temp = 0; -+ } -+ -+ senv.min_free_processors = proc_temp; -+ } -+ else if (!strcasecmp(directive, "maxspareprocessors")) { -+ proc_temp = atoi(current->args); -+ -+ if (proc_temp < 0) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: Require MaxSpareProcessors >= 0, setting to 0"); -+ proc_temp = 0; -+ } -+ -+ senv.max_free_processors = proc_temp; -+ } -+ else if (!strcasecmp(directive, "cgroup")) { -+ senv.cgroup = ap_getword_conf(cmd->pool, ¤t->args); -+ } -+ else { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "Unknown directive %s in %s>", directive, cmd->cmd->name); -+ } -+ } -+ -+ if (user_name == NULL || group_name == NULL) { -+ return apr_psprintf(cmd->temp_pool, -+ "Error: User or Group must be set in %s>", cmd->cmd->name); -+ } -+ -+ senv.uid = ap_uname2id(user_name); -+ senv.gid = ap_gname2id(group_name); -+ -+ _DBG("name=%s user=%s:%d group=%s:%d chroot=%s nice_lvl=%d", -+ senv.name, user_name, senv.uid, group_name, senv.gid, senv.chroot, senv.nice_lvl); -+ -+ _DBG("min_processors=%d min_free_processors=%d max_spare_processors=%d max_processors=%d", -+ senv.min_processors, senv.min_free_processors, senv.max_free_processors, senv.max_processors); - - return child_add(CHILD_TYPE_PROCESSOR, CHILD_STATUS_STANDBY, -- cmd->pool, uid, gid, chroot); -+ cmd->pool, &senv); - } - - /* we define an Multiplexer child w/ specific uid/gid */ - static const char *cf_Multiplexer(cmd_parms *cmd, void *dummy, - const char *user_name, const char *group_name, const char *chroot) - { -- uid_t uid = ap_uname2id(user_name); -- gid_t gid = ap_gname2id(group_name); -+ server_env_t senv; -+ -+ senv.name = NULL; -+ -+ senv.uid = ap_uname2id(user_name); -+ senv.gid = ap_gname2id(group_name); -+ senv.nice_lvl = 0; -+ senv.cgroup = NULL; -+ senv.chroot = chroot; -+ -+ senv.min_processors = ap_min_multiplexers; -+ senv.min_free_processors = ap_min_free_processors; -+ senv.max_free_processors = ap_max_free_processors; -+ senv.max_processors = ap_max_multiplexers; - - _DBG("user=%s:%d group=%s:%d chroot=%s [multiplexer id %d]", -- user_name, uid, group_name, gid, chroot, NUM_CHILDS); -+ user_name, senv.uid, group_name, senv.gid, senv.chroot, NUM_CHILDS); - - return child_add(CHILD_TYPE_MULTIPLEXER, CHILD_STATUS_STARTING, -- cmd->pool, uid, gid, chroot); -+ cmd->pool, &senv); - } - - static const char* cf_ServerEnvironment(cmd_parms *cmd, void *dummy, -- const char *user_name, const char *group_name, const char *chroot) -+ const char *name) - { -- int uid = ap_uname2id(user_name); -- int gid = ap_gname2id(group_name); - peruser_server_conf *sconf = PERUSER_SERVER_CONF(cmd->server->module_config); - - _DBG("function entered", 0); - -- if (chroot && !ap_is_directory(cmd->pool, chroot)) -- return apr_psprintf(cmd->pool, "Error: chroot directory [%s] does not exist", chroot); -+ sconf->senv = find_senv_by_name(name); - -- sconf->senv = senv_add(uid, gid, chroot); -+ if (sconf->senv == NULL) { -+ return apr_psprintf(cmd->pool, -+ "Error: Processor %s not defined", name); -+ } - -- _DBG("user=%s:%d group=%s:%d chroot=%s numchilds=%d", -- user_name, uid, group_name, gid, chroot, NUM_CHILDS); -+ _DBG("user=%d group=%d chroot=%s numchilds=%d", -+ sconf->senv->uid, sconf->senv->gid, sconf->senv->chroot, NUM_CHILDS); - - return NULL; - } -@@ -3046,10 +3409,10 @@ - - min_procs = atoi(arg); - -- if (min_procs < 1) { -+ if (min_procs < 0) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -- "WARNING: Require MaxProcessors > 0, setting to 1"); -- min_procs = 1; -+ "WARNING: Require MinProcessors >= 0, setting to 0"); -+ min_procs = 0; - } - - if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) { -@@ -3075,10 +3438,10 @@ - - min_free_procs = atoi(arg); - -- if (min_free_procs < 1) { -+ if (min_free_procs < 0) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -- "WARNING: Require MinSpareProcessors > 0, setting to 1"); -- min_free_procs = 1; -+ "WARNING: Require MinSpareProcessors >= 0, setting to 0"); -+ min_free_procs = 0; - } - - if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) { -@@ -3092,6 +3455,35 @@ - return NULL; - } - -+static const char *set_max_free_processors (cmd_parms *cmd, void *dummy, const char *arg) -+{ -+ peruser_server_conf *sconf; -+ int max_free_procs; -+ const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); -+ -+ if (err != NULL) { -+ return err; -+ } -+ -+ max_free_procs = atoi(arg); -+ -+ if (max_free_procs < 0) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: Require MaxSpareProcessors >= 0, setting to 0"); -+ max_free_procs = 0; -+ } -+ -+ if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) { -+ sconf = PERUSER_SERVER_CONF(cmd->server->module_config); -+ sconf->senv->max_free_processors = max_free_procs; -+ } -+ else { -+ ap_max_free_processors = max_free_procs; -+ } -+ -+ return NULL; -+} -+ - static const char *set_max_processors (cmd_parms *cmd, void *dummy, const char *arg) - { - peruser_server_conf *sconf; -@@ -3121,6 +3513,50 @@ - return NULL; - } - -+static const char *set_min_multiplexers (cmd_parms *cmd, void *dummy, const char *arg) -+{ -+ int min_multiplexers; -+ const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); -+ -+ if (err != NULL) { -+ return err; -+ } -+ -+ min_multiplexers = atoi(arg); -+ -+ if (min_multiplexers < 1) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: Require MinMultiplexers > 0, setting to 1"); -+ min_multiplexers = 1; -+ } -+ -+ ap_min_multiplexers = min_multiplexers; -+ -+ return NULL; -+} -+ -+static const char *set_max_multiplexers (cmd_parms *cmd, void *dummy, const char *arg) -+{ -+ int max_multiplexers; -+ const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); -+ -+ if (err != NULL) { -+ return err; -+ } -+ -+ max_multiplexers = atoi(arg); -+ -+ if (max_multiplexers < 1) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: Require MaxMultiplexers > 0, setting to 1"); -+ max_multiplexers = 1; -+ } -+ -+ ap_max_multiplexers = max_multiplexers; -+ -+ return NULL; -+} -+ - static const char *set_server_limit (cmd_parms *cmd, void *dummy, const char *arg) - { - int tmp_server_limit; -@@ -3183,6 +3619,42 @@ - return NULL; - } - -+static const char *set_multiplexer_idle_timeout (cmd_parms *cmd, void *dummy, const char *arg) { -+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); -+ -+ if (err != NULL) { -+ return err; -+ } -+ -+ multiplexer_idle_timeout = atoi(arg); -+ -+ return NULL; -+} -+ -+static const char *set_processor_wait_timeout (cmd_parms *cmd, void *dummy, const char *timeout, const char *steps) { -+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); -+ -+ if (err != NULL) { -+ return err; -+ } -+ -+ processor_wait_timeout = atoi(timeout); -+ -+ if (steps != NULL) { -+ int steps_tmp = atoi(steps); -+ -+ if (steps_tmp < 1) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: Require ProcessorWaitTimeout steps > 0, setting to 1"); -+ steps_tmp = 1; -+ } -+ -+ processor_wait_steps = steps_tmp; -+ } -+ -+ return NULL; -+} -+ - static const command_rec peruser_cmds[] = { - UNIX_DAEMON_COMMANDS, - LISTEN_COMMANDS, -@@ -3190,23 +3662,33 @@ - "Minimum number of idle children, to handle request spikes"), - AP_INIT_TAKE1("MinSpareServers", set_min_free_servers, NULL, RSRC_CONF, - "Minimum number of idle children, to handle request spikes"), -+AP_INIT_TAKE1("MaxSpareProcessors", set_max_free_processors, NULL, RSRC_CONF, -+ "Maximum number of idle children, 0 to disable"), - AP_INIT_TAKE1("MaxClients", set_max_clients, NULL, RSRC_CONF, - "Maximum number of children alive at the same time"), - AP_INIT_TAKE1("MinProcessors", set_min_processors, NULL, RSRC_CONF, - "Minimum number of processors per vhost"), - AP_INIT_TAKE1("MaxProcessors", set_max_processors, NULL, RSRC_CONF, - "Maximum number of processors per vhost"), -+AP_INIT_TAKE1("MinMultiplexers", set_min_multiplexers, NULL, RSRC_CONF, -+ "Minimum number of multiplexers the server can have"), -+AP_INIT_TAKE1("MaxMultiplexers", set_max_multiplexers, NULL, RSRC_CONF, -+ "Maximum number of multiplexers the server can have"), - AP_INIT_TAKE1("ServerLimit", set_server_limit, NULL, RSRC_CONF, - "Maximum value of MaxClients for this run of Apache"), - AP_INIT_TAKE1("ExpireTimeout", set_expire_timeout, NULL, RSRC_CONF, -- "Maximum idle time before a child is killed, 0 to disable"), -+ "Maximum time a child can live, 0 to disable"), - AP_INIT_TAKE1("IdleTimeout", set_idle_timeout, NULL, RSRC_CONF, - "Maximum time before a child is killed after being idle, 0 to disable"), -+AP_INIT_TAKE1("MultiplexerIdleTimeout", set_multiplexer_idle_timeout, NULL, RSRC_CONF, -+ "Maximum time before a multiplexer is killed after being idle, 0 to disable"), -+AP_INIT_TAKE12("ProcessorWaitTimeout", set_processor_wait_timeout, NULL, RSRC_CONF, -+ "Maximum time a multiplexer waits for the processor if it is busy"), - AP_INIT_TAKE23("Multiplexer", cf_Multiplexer, NULL, RSRC_CONF, - "Specify an Multiplexer Child configuration."), --AP_INIT_TAKE23("Processor", cf_Processor, NULL, RSRC_CONF, -- "Specify a User and Group for a specific child process."), --AP_INIT_TAKE23("ServerEnvironment", cf_ServerEnvironment, NULL, RSRC_CONF, -+AP_INIT_RAW_ARGS("<Processor", cf_Processor, NULL, RSRC_CONF, -+ "Specify settings for processor."), -+AP_INIT_TAKE1("ServerEnvironment", cf_ServerEnvironment, NULL, RSRC_CONF, - "Specify the server environment for this virtual host."), - { NULL } - }; diff --git a/www/apache22-peruser-mpm/files/httpd-2.2.3-peruser-0.3.0.patch b/www/apache22-peruser-mpm/files/httpd-2.2.3-peruser-0.3.0.patch deleted file mode 100644 index da5714e..0000000 --- a/www/apache22-peruser-mpm/files/httpd-2.2.3-peruser-0.3.0.patch +++ /dev/null @@ -1,3498 +0,0 @@ -diff -Nur httpd-2.2.3/server/mpm/config.m4 httpd-2.2.3-peruser/server/mpm/config.m4 ---- server/mpm/config.m4 2005-10-30 10:05:26.000000000 -0700 -+++ server/mpm/config.m4 2007-09-24 22:52:22.000000000 -0600 -@@ -1,7 +1,7 @@ - AC_MSG_CHECKING(which MPM to use) - AC_ARG_WITH(mpm, - APACHE_HELP_STRING(--with-mpm=MPM,Choose the process model for Apache to use. -- MPM={beos|event|worker|prefork|mpmt_os2|winnt}),[ -+ MPM={beos|event|worker|prefork|mpmt_os2|winnt|peruser}),[ - APACHE_MPM=$withval - ],[ - if test "x$APACHE_MPM" = "x"; then -@@ -23,7 +23,7 @@ - - ap_mpm_is_experimental () - { -- if test "$apache_cv_mpm" = "event" ; then -+ if test "$apache_cv_mpm" = "event" -o "$apache_cv_mpm" = "peruser" ; then - return 0 - else - return 1 -diff -Nur httpd-2.2.3/server/mpm/experimental/peruser/AUTHORS httpd-2.2.3-peruser/server/mpm/experimental/peruser/AUTHORS ---- server/mpm/experimental/peruser/AUTHORS 1969-12-31 17:00:00.000000000 -0700 -+++ server/mpm/experimental/peruser/AUTHORS 2007-09-28 17:29:01.000000000 -0600 -@@ -0,0 +1,9 @@ -+Enrico Weigelt <weigelt [at] metux.de> (MetuxMPM maintainer) -+Sean Gabriel Heacock <gabriel [at] telana.com> (Peruser maintainer) -+Stefan Seufert <stefan [at] seuf.de> -+Janno Sannik <janno [at] kood.ee> -+Taavi Sannik <taavi [at] kood.ee> -+Rommer <rommer [at] active.by> -+Bert <bert [at] ev6.net> -+Leen Besselink <leen [at] consolejunkie.net> -+Steve Amerige <mpm [at] fatbear.com> -diff -Nur httpd-2.2.3/server/mpm/experimental/peruser/Makefile.in httpd-2.2.3-peruser/server/mpm/experimental/peruser/Makefile.in ---- server/mpm/experimental/peruser/Makefile.in 1969-12-31 17:00:00.000000000 -0700 -+++ server/mpm/experimental/peruser/Makefile.in 2007-09-28 17:29:01.000000000 -0600 -@@ -0,0 +1,5 @@ -+ -+LTLIBRARY_NAME = libperuser.la -+LTLIBRARY_SOURCES = peruser.c -+ -+include $(top_srcdir)/build/ltlib.mk -diff -Nur httpd-2.2.3/server/mpm/experimental/peruser/config.m4 httpd-2.2.3-peruser/server/mpm/experimental/peruser/config.m4 ---- server/mpm/experimental/peruser/config.m4 1969-12-31 17:00:00.000000000 -0700 -+++ server/mpm/experimental/peruser/config.m4 2007-09-28 17:29:01.000000000 -0600 -@@ -0,0 +1,3 @@ -+if test "$MPM_NAME" = "peruser" ; then -+ APACHE_FAST_OUTPUT(server/mpm/experimental/$MPM_NAME/Makefile) -+fi -diff -Nur httpd-2.2.3/server/mpm/experimental/peruser/mpm.h httpd-2.2.3-peruser/server/mpm/experimental/peruser/mpm.h ---- server/mpm/experimental/peruser/mpm.h 1969-12-31 17:00:00.000000000 -0700 -+++ server/mpm/experimental/peruser/mpm.h 2007-09-28 17:29:01.000000000 -0600 -@@ -0,0 +1,103 @@ -+/* ==================================================================== -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2000-2003 The Apache Software Foundation. All rights -+ * reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, -+ * if any, must include the following acknowledgment: -+ * "This product includes software developed by the -+ * Apache Software Foundation (http://www.apache.org/)." -+ * Alternately, this acknowledgment may appear in the software itself, -+ * if and wherever such third-party acknowledgments normally appear. -+ * -+ * 4. The names "Apache" and "Apache Software Foundation" must -+ * not be used to endorse or promote products derived from this -+ * software without prior written permission. For written -+ * permission, please contact apache@apache.org. -+ * -+ * 5. Products derived from this software may not be called "Apache", -+ * nor may "Apache" appear in their name, without prior written -+ * permission of the Apache Software Foundation. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR -+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -+ * SUCH DAMAGE. -+ * ==================================================================== -+ * -+ * This software consists of voluntary contributions made by many -+ * individuals on behalf of the Apache Software Foundation. For more -+ * information on the Apache Software Foundation, please see -+ * <http://www.apache.org/>. -+ * -+ * Portions of this software are based upon public domain software -+ * originally written at the National Center for Supercomputing Applications, -+ * University of Illinois, Urbana-Champaign. -+ */ -+ -+#include "httpd.h" -+#include "mpm_default.h" -+#include "scoreboard.h" -+#include "unixd.h" -+ -+#ifndef APACHE_MPM_PERUSER_H -+#define APACHE_MPM_PERUSER_H -+ -+#define PERUSER_MPM -+ -+#define MPM_NAME "Peruser" -+ -+#define AP_MPM_WANT_RECLAIM_CHILD_PROCESSES -+#define AP_MPM_WANT_WAIT_OR_TIMEOUT -+#define AP_MPM_WANT_PROCESS_CHILD_STATUS -+#define AP_MPM_WANT_SET_PIDFILE -+#define AP_MPM_WANT_SET_SCOREBOARD -+#define AP_MPM_WANT_SET_LOCKFILE -+#define AP_MPM_WANT_SET_MAX_REQUESTS -+#define AP_MPM_WANT_SET_COREDUMPDIR -+#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH -+#define AP_MPM_WANT_SIGNAL_SERVER -+#define AP_MPM_WANT_SET_MAX_MEM_FREE -+#define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK -+ -+#define AP_MPM_USES_POD 1 -+#define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid) -+#define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0) -+#define MPM_ACCEPT_FUNC unixd_accept -+ -+extern int ap_threads_per_child; -+extern int ap_max_daemons_limit; -+extern server_rec *ap_server_conf; -+ -+/* Table of child status */ -+#define SERVER_DEAD 0 -+#define SERVER_DYING 1 -+#define SERVER_ALIVE 2 -+ -+typedef struct ap_ctable { -+ pid_t pid; -+ unsigned char status; -+} ap_ctable; -+ -+#endif /* APACHE_MPM_PERUSER_H */ -diff -Nur httpd-2.2.3/server/mpm/experimental/peruser/mpm_default.h httpd-2.2.3-peruser/server/mpm/experimental/peruser/mpm_default.h ---- server/mpm/experimental/peruser/mpm_default.h 1969-12-31 17:00:00.000000000 -0700 -+++ server/mpm/experimental/peruser/mpm_default.h 2007-09-28 17:29:01.000000000 -0600 -@@ -0,0 +1,110 @@ -+/* ==================================================================== -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2000-2003 The Apache Software Foundation. All rights -+ * reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, -+ * if any, must include the following acknowledgment: -+ * "This product includes software developed by the -+ * Apache Software Foundation (http://www.apache.org/)." -+ * Alternately, this acknowledgment may appear in the software itself, -+ * if and wherever such third-party acknowledgments normally appear. -+ * -+ * 4. The names "Apache" and "Apache Software Foundation" must -+ * not be used to endorse or promote products derived from this -+ * software without prior written permission. For written -+ * permission, please contact apache@apache.org. -+ * -+ * 5. Products derived from this software may not be called "Apache", -+ * nor may "Apache" appear in their name, without prior written -+ * permission of the Apache Software Foundation. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR -+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -+ * SUCH DAMAGE. -+ * ==================================================================== -+ * -+ * This software consists of voluntary contributions made by many -+ * individuals on behalf of the Apache Software Foundation. For more -+ * information on the Apache Software Foundation, please see -+ * <http://www.apache.org/>. -+ * -+ * Portions of this software are based upon public domain software -+ * originally written at the National Center for Supercomputing Applications, -+ * University of Illinois, Urbana-Champaign. -+ */ -+ -+#ifndef APACHE_MPM_DEFAULT_H -+#define APACHE_MPM_DEFAULT_H -+ -+/* Number of processors to spawn off for each ServerEnvironment by default */ -+ -+#ifndef DEFAULT_START_PROCESSORS -+#define DEFAULT_START_PROCESSORS 0 -+#endif -+ -+/* Minimum number of running processors per ServerEnvironment */ -+ -+#ifndef DEFAULT_MIN_PROCESSORS -+#define DEFAULT_MIN_PROCESSORS 0 -+#endif -+ -+/* Minimum --- fewer than this, and more will be created */ -+ -+#ifndef DEFAULT_MIN_FREE_PROCESSORS -+#define DEFAULT_MIN_FREE_PROCESSORS 2 -+#endif -+ -+/* Maximum processors per ServerEnvironment */ -+ -+#ifndef DEFAULT_MAX_PROCESSORS -+#define DEFAULT_MAX_PROCESSORS 10 -+#endif -+ -+/* File used for accept locking, when we use a file */ -+#ifndef DEFAULT_LOCKFILE -+#define DEFAULT_LOCKFILE DEFAULT_REL_RUNTIMEDIR "/accept.lock" -+#endif -+ -+/* Where the main/parent process's pid is logged */ -+#ifndef DEFAULT_PIDLOG -+#define DEFAULT_PIDLOG DEFAULT_REL_RUNTIMEDIR "/httpd.pid" -+#endif -+ -+/* -+ * Interval, in microseconds, between scoreboard maintenance. -+ */ -+#ifndef SCOREBOARD_MAINTENANCE_INTERVAL -+#define SCOREBOARD_MAINTENANCE_INTERVAL 1000000 -+#endif -+ -+/* Number of requests to try to handle in a single process. If <= 0, -+ * the children don't die off. -+ */ -+#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD -+#define DEFAULT_MAX_REQUESTS_PER_CHILD 10000 -+#endif -+ -+#endif /* AP_MPM_DEFAULT_H */ -diff -Nur httpd-2.2.3/server/mpm/experimental/peruser/peruser.c httpd-2.2.3-peruser/server/mpm/experimental/peruser/peruser.c ---- server/mpm/experimental/peruser/peruser.c 1969-12-31 17:00:00.000000000 -0700 -+++ server/mpm/experimental/peruser/peruser.c 2007-10-03 11:28:06.000000000 -0600 -@@ -0,0 +1,3223 @@ -+/* ==================================================================== -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2000-2003 The Apache Software Foundation. All rights -+ * reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, -+ * if any, must include the following acknowledgment: -+ * "This product includes software developed by the -+ * Apache Software Foundation (http://www.apache.org/)." -+ * Alternately, this acknowledgment may appear in the software itself, -+ * if and wherever such third-party acknowledgments normally appear. -+ * -+ * 4. The names "Apache" and "Apache Software Foundation" must -+ * not be used to endorse or promote products derived from this -+ * software without prior written permission. For written -+ * permission, please contact apache@apache.org. -+ * -+ * 5. Products derived from this software may not be called "Apache", -+ * nor may "Apache" appear in their name, without prior written -+ * permission of the Apache Software Foundation. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR -+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -+ * SUCH DAMAGE. -+ * ==================================================================== -+ * -+ * This software consists of voluntary contributions made by many -+ * individuals on behalf of the Apache Software Foundation. For more -+ * information on the Apache Software Foundation, please see -+ * <http://www.apache.org/>. -+ * -+ * Portions of this software are based upon public domain software -+ * originally written at the National Center for Supercomputing Applications, -+ * University of Illinois, Urbana-Champaign. -+ */ -+ -+/* Peruser version 0.3.0 */ -+ -+/* #define MPM_PERUSER_DEBUG */ -+ -+#include "apr.h" -+#include "apr_hash.h" -+#include "apr_pools.h" -+#include "apr_file_io.h" -+#include "apr_portable.h" -+#include "apr_strings.h" -+#include "apr_thread_proc.h" -+#include "apr_signal.h" -+#define APR_WANT_STDIO -+#define APR_WANT_STRFUNC -+#define APR_WANT_IOVEC -+#include "apr_want.h" -+ -+#if APR_HAVE_UNISTD_H -+#include <unistd.h> -+#endif -+#if APR_HAVE_SYS_TYPES_H -+#include <sys/types.h> -+#endif -+ -+#define CORE_PRIVATE -+ -+#include "ap_config.h" -+#include "httpd.h" -+#include "mpm_default.h" -+#include "http_main.h" -+#include "http_log.h" -+#include "http_config.h" -+#include "http_core.h" /* for get_remote_host */ -+#include "http_connection.h" -+#include "http_protocol.h" /* for ap_hook_post_read_request */ -+#include "http_vhost.h" /* for ap_update_vhost_given_ip */ -+#include "scoreboard.h" -+#include "ap_mpm.h" -+#include "unixd.h" -+#include "mpm_common.h" -+#include "ap_listen.h" -+#include "ap_mmn.h" -+#include "apr_poll.h" -+#include "util_ebcdic.h" -+#include "mod_status.h" -+ -+#ifdef HAVE_BSTRING_H -+#include <bstring.h> /* for IRIX, FD_SET calls bzero() */ -+#endif -+ -+#ifdef HAVE_TIME_H -+#include <time.h> -+#endif -+ -+#ifdef HAVE_SYS_PROCESSOR_H -+#include <sys/processor.h> /* for bindprocessor() */ -+#endif -+ -+#if APR_HAS_SHARED_MEMORY -+#include "apr_shm.h" -+#else -+#error "Peruser MPM requres shared memory support." -+#endif -+ -+ -+/* should be APR-ized */ -+#include <grp.h> -+#include <pwd.h> -+#include <sys/stat.h> -+#include <sys/un.h> -+#include <setjmp.h> -+ -+#include <signal.h> -+#include <sys/times.h> -+ -+ -+#ifdef MPM_PERUSER_DEBUG -+# define _DBG(text,par...) \ -+ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, \ -+ "(peruser: pid=%d uid=%d child=%d) %s(): " text, \ -+ getpid(), getuid(), my_child_num, __FUNCTION__, ##par, 0) -+ -+# define _TRACE_CALL(text,par...) _DBG("calling " text, ##par) -+# define _TRACE_RET(text,par...) _DBG("returned from " text, ##par) -+#else -+# define _DBG(text,par...) -+# define _TRACE_RET(text,par...) -+# define _TRACE_CALL(text,par...) -+#endif /* MPM_PERUSER_DEBUG */ -+ -+/* char of death - for signalling children to die */ -+#define AP_PERUSER_CHAR_OF_DEATH '!' -+ -+#define PERUSER_SERVER_CONF(cf) \ -+ ((peruser_server_conf *) ap_get_module_config(cf, &mpm_peruser_module)) -+ -+#define SCOREBOARD_STATUS(i) ap_scoreboard_image->servers[i][0].status -+ -+/* -+ * Define some magic numbers that we use for the state of the incomming -+ * request. These must be < 0 so they don't collide with a file descriptor. -+ */ -+#define AP_PERUSER_THISCHILD -1 -+#define AP_PERUSER_OTHERCHILD -2 -+ -+ -+/* Limit on the total --- clients will be locked out if more servers than -+ * this are needed. It is intended solely to keep the server from crashing -+ * when things get out of hand. -+ * -+ * We keep a hard maximum number of servers, for two reasons --- first off, -+ * in case something goes seriously wrong, we want to stop the fork bomb -+ * short of actually crashing the machine we're running on by filling some -+ * kernel table. Secondly, it keeps the size of the scoreboard file small -+ * enough that we can read the whole thing without worrying too much about -+ * the overhead. -+ */ -+#ifndef DEFAULT_SERVER_LIMIT -+#define DEFAULT_SERVER_LIMIT 256 -+#endif -+ -+/* Admin can't tune ServerLimit beyond MAX_SERVER_LIMIT. We want -+ * some sort of compile-time limit to help catch typos. -+ */ -+#ifndef MAX_SERVER_LIMIT -+#define MAX_SERVER_LIMIT 20000 -+#endif -+ -+#ifndef HARD_THREAD_LIMIT -+#define HARD_THREAD_LIMIT 1 -+#endif -+ -+#define CHILD_TYPE_UNKNOWN 0 -+#define CHILD_TYPE_MULTIPLEXER 1 -+#define CHILD_TYPE_PROCESSOR 2 -+#define CHILD_TYPE_WORKER 3 -+ -+#define CHILD_STATUS_STANDBY 0 /* wait for a request before starting */ -+#define CHILD_STATUS_STARTING 1 /* wait for socket creation */ -+#define CHILD_STATUS_READY 2 /* wait for mux to restart */ -+#define CHILD_STATUS_ACTIVE 3 /* ready to take requests */ -+#define CHILD_STATUS_RESTART 4 /* child about to die and restart */ -+ -+/* config globals */ -+ -+int ap_threads_per_child=0; /* Worker threads per child */ -+static apr_proc_mutex_t *accept_mutex; -+static int ap_min_processors=DEFAULT_MIN_PROCESSORS; -+static int ap_min_free_processors=DEFAULT_MIN_FREE_PROCESSORS; -+static int ap_max_processors=DEFAULT_MAX_PROCESSORS; -+static int ap_daemons_limit=0; /* MaxClients */ -+static int expire_timeout=1800; -+static int idle_timeout=900; -+static int server_limit = DEFAULT_SERVER_LIMIT; -+static int first_server_limit; -+static int changed_limit_at_restart; -+static int requests_this_child; -+static int mpm_state = AP_MPMQ_STARTING; -+static ap_pod_t *pod; -+ -+/* === configuration stuff === */ -+ -+typedef struct -+{ -+ int processor_id; -+ -+ /* security settings */ -+ uid_t uid; /* user id */ -+ gid_t gid; /* group id */ -+ const char *chroot; /* directory to chroot() to, can be null */ -+ -+ /* resource settings */ -+ int min_processors; -+ int min_free_processors; -+ int max_processors; -+ -+ /* sockets */ -+ int input; /* The socket descriptor */ -+ int output; /* The socket descriptor */ -+} server_env_t; -+ -+typedef struct -+{ -+ apr_size_t num; -+} server_env_control; -+ -+typedef struct -+{ -+ server_env_control *control; -+ server_env_t *table; -+} server_env; -+ -+ -+typedef struct -+{ -+ /* identification */ -+ int id; /* index in child_info_table */ -+ pid_t pid; /* process id */ -+ int status; /* status of child */ -+ int type; /* multiplexer or processor */ -+ server_env_t *senv; -+ -+ /* sockets */ -+ int sock_fd; -+ -+ /* stack context saved state */ -+ jmp_buf jmpbuffer; -+} child_info_t; -+ -+typedef struct -+{ -+ /* identification */ -+ int id; /* index in child_info_table */ -+ pid_t pid; /* process id */ -+ int status; /* status of child */ -+ int type; /* multiplexer or processor */ -+ apr_time_t last_used; -+} child_grace_info_t; -+ -+typedef struct -+{ -+ apr_size_t num; -+} child_info_control; -+ -+typedef struct -+{ -+ child_info_control *control; -+ child_info_t *table; -+} child_info; -+ -+typedef struct -+{ -+ server_env_t *senv; -+} peruser_server_conf; -+ -+ -+typedef struct peruser_header -+{ -+ char *headers; -+ apr_pool_t *p; -+} peruser_header; -+ -+ -+/* Tables used to determine the user and group each child process should -+ * run as. The hash table is used to correlate a server name with a child -+ * process. -+ */ -+static apr_size_t child_info_size; -+static child_info *child_info_image; -+static child_grace_info_t *child_grace_info_table; -+struct ap_ctable *ap_child_table; -+ -+#define NUM_CHILDS (child_info_image != NULL ? child_info_image->control->num : 0) -+#define CHILD_INFO_TABLE (child_info_image != NULL ? child_info_image->table : NULL) -+ -+static apr_size_t server_env_size; -+static server_env *server_env_image = NULL; -+ -+#define NUM_SENV (server_env_image != NULL ? server_env_image->control->num : 0) -+#define SENV (server_env_image != NULL ? server_env_image->table : NULL) -+ -+#if APR_HAS_SHARED_MEMORY -+#ifndef WIN32 -+static /* but must be exported to mpm_winnt */ -+#endif -+ apr_shm_t *child_info_shm = NULL; -+ apr_shm_t *server_env_shm = NULL; -+#endif -+ -+/* -+ * The max child slot ever assigned, preserved across restarts. Necessary -+ * to deal with MaxClients changes across AP_SIG_GRACEFUL restarts. We -+ * use this value to optimize routines that have to scan the entire scoreboard. -+ */ -+int ap_max_daemons_limit = -1; -+server_rec *ap_server_conf; -+ -+module AP_MODULE_DECLARE_DATA mpm_peruser_module; -+ -+/* -- replace the pipe-of-death by an control socket -- */ -+static apr_file_t *pipe_of_death_in = NULL; -+static apr_file_t *pipe_of_death_out = NULL; -+ -+ -+/* one_process --- debugging mode variable; can be set from the command line -+ * with the -X flag. If set, this gets you the child_main loop running -+ * in the process which originally started up (no detach, no make_child), -+ * which is a pretty nice debugging environment. (You'll get a SIGHUP -+ * early in standalone_main; just continue through. This is the server -+ * trying to kill off any child processes which it might have lying -+ * around --- Apache doesn't keep track of their pids, it just sends -+ * SIGHUP to the process group, ignoring it in the root process. -+ * Continue through and you'll be fine.). -+ */ -+ -+static int one_process = 0; -+ -+static apr_pool_t *pconf; /* Pool for config stuff */ -+static apr_pool_t *pchild; /* Pool for httpd child stuff */ -+ -+static pid_t ap_my_pid; /* it seems silly to call getpid all the time */ -+static pid_t parent_pid; -+static int my_child_num; -+ap_generation_t volatile ap_my_generation=0; -+ -+#ifdef TPF -+int tpf_child = 0; -+char tpf_server_name[INETD_SERVNAME_LENGTH+1]; -+#endif /* TPF */ -+ -+static int die_now = 0; -+ -+int grace_children = 0; -+int grace_children_alive = 0; -+int server_env_cleanup = 1; -+ -+#ifdef GPROF -+/* -+ * change directory for gprof to plop the gmon.out file -+ * configure in httpd.conf: -+ * GprofDir $RuntimeDir/ -> $ServerRoot/$RuntimeDir/gmon.out -+ * GprofDir $RuntimeDir/% -> $ServerRoot/$RuntimeDir/gprof.$pid/gmon.out -+ */ -+static void chdir_for_gprof(void) -+{ -+ core_server_config *sconf = -+ ap_get_module_config(ap_server_conf->module_config, &core_module); -+ char *dir = sconf->gprof_dir; -+ const char *use_dir; -+ -+ if(dir) { -+ apr_status_t res; -+ char buf[512]; -+ int len = strlen(sconf->gprof_dir) - 1; -+ if(*(dir + len) == '%') { -+ dir[len] = '\0'; -+ apr_snprintf(buf, sizeof(buf), "%sgprof.%d", dir, (int)getpid()); -+ } -+ use_dir = ap_server_root_relative(pconf, buf[0] ? buf : dir); -+ res = apr_dir_make(use_dir, 0755, pconf); -+ if(res != APR_SUCCESS && !APR_STATUS_IS_EEXIST(res)) { -+ ap_log_error(APLOG_MARK, APLOG_ERR, errno, ap_server_conf, -+ "gprof: error creating directory %s", dir); -+ } -+ } -+ else { -+ use_dir = ap_server_root_relative(pconf, DEFAULT_REL_RUNTIMEDIR); -+ } -+ -+ chdir(use_dir); -+} -+#else -+#define chdir_for_gprof() -+#endif -+ -+char* child_type_string(int type) -+{ -+ switch(type) -+ { -+ case CHILD_TYPE_MULTIPLEXER: return "MULTIPLEXER"; -+ case CHILD_TYPE_PROCESSOR: return "PROCESSOR"; -+ case CHILD_TYPE_WORKER: return "WORKER"; -+ } -+ -+ return "UNKNOWN"; -+} -+ -+char* child_status_string(int status) -+{ -+ switch(status) -+ { -+ case CHILD_STATUS_STANDBY: return "STANDBY"; -+ case CHILD_STATUS_STARTING: return "STARTING"; -+ case CHILD_STATUS_READY: return "READY"; -+ case CHILD_STATUS_ACTIVE: return "ACTIVE"; -+ case CHILD_STATUS_RESTART: return "RESTART"; -+ } -+ -+ return "UNKNOWN"; -+} -+ -+void dump_child_table() -+{ -+#ifdef MPM_PERUSER_DEBUG -+ int x; -+ server_env_t *senv; -+ -+ _DBG("%-3s %-5s %-8s %-12s %-4s %-4s %-25s %5s %6s %7s", -+ "ID", "PID", "STATUS", "TYPE", "UID", "GID", "CHROOT", "INPUT", "OUTPUT", "SOCK_FD"); -+ -+ for(x = 0; x < NUM_CHILDS; x++) -+ { -+ senv = CHILD_INFO_TABLE[x].senv; -+ _DBG("%-3d %-5d %-8s %-12s %-4d %-4d %-25s %-5d %-6d %-7d", -+ CHILD_INFO_TABLE[x].id, -+ CHILD_INFO_TABLE[x].pid, -+ child_status_string(CHILD_INFO_TABLE[x].status), -+ child_type_string(CHILD_INFO_TABLE[x].type), -+ senv == NULL ? -1 : senv->uid, -+ senv == NULL ? -1 : senv->gid, -+ senv == NULL ? NULL : senv->chroot, -+ senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->input, -+ senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->output, -+ CHILD_INFO_TABLE[x].sock_fd); -+ } -+#endif -+} -+ -+void dump_server_env_image() -+{ -+#ifdef MPM_PERUSER_DEBUG -+ int x; -+ _DBG("%-3s %-7s %-7s", "N", "INPUT", "OUTPUT"); -+ for(x = 0; x < NUM_SENV; x++) -+ { -+ _DBG("%-3d %-7d %-7d", x, SENV[x].input, SENV[x].output); -+ } -+#endif -+} -+ -+ -+/* XXX - I don't know if TPF will ever use this module or not, so leave -+ * the ap_check_signals calls in but disable them - manoj */ -+#define ap_check_signals() -+ -+/* a clean exit from a child with proper cleanup */ -+static inline int clean_child_exit(int code) __attribute__ ((noreturn)); -+static inline int clean_child_exit(int code) -+{ -+ int retval; -+ -+ mpm_state = AP_MPMQ_STOPPING; -+ -+ if (CHILD_INFO_TABLE[my_child_num].type != CHILD_TYPE_MULTIPLEXER && -+ CHILD_INFO_TABLE[my_child_num].senv) -+ { -+ retval = close(CHILD_INFO_TABLE[my_child_num].senv->input); -+ _DBG("close(CHILD_INFO_TABLE[%d].senv->input) = %d", -+ my_child_num, retval); -+ -+ retval = close(CHILD_INFO_TABLE[my_child_num].senv->output); -+ _DBG("close(CHILD_INFO_TABLE[%d].senv->output) = %d", -+ my_child_num, retval); -+ } -+ -+ if (pchild) { -+ apr_pool_destroy(pchild); -+ } -+ ap_mpm_pod_close(pod); -+ chdir_for_gprof(); -+ exit(code); -+} -+ -+static void accept_mutex_on(void) -+{ -+/* for some reason this fails if we listen on the pipe_of_death. -+ fortunately I don't think we currently need it */ -+ -+#if 0 -+ apr_status_t rv = apr_proc_mutex_lock(accept_mutex); -+ if (rv != APR_SUCCESS) { -+ const char *msg = "couldn't grab the accept mutex"; -+ -+ if (ap_my_generation != -+ ap_scoreboard_image->global->running_generation) { -+ ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, NULL, msg); -+ clean_child_exit(0); -+ } -+ else { -+ ap_log_error(APLOG_MARK, APLOG_EMERG, rv, NULL, msg); -+ exit(APEXIT_CHILDFATAL); -+ } -+ } -+#endif -+} -+ -+static void accept_mutex_off(void) -+{ -+#if 0 -+ apr_status_t rv = apr_proc_mutex_unlock(accept_mutex); -+ if (rv != APR_SUCCESS) { -+ const char *msg = "couldn't release the accept mutex"; -+ -+ if (ap_my_generation != -+ ap_scoreboard_image->global->running_generation) { -+ ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, NULL, msg); -+ /* don't exit here... we have a connection to -+ * process, after which point we'll see that the -+ * generation changed and we'll exit cleanly -+ */ -+ } -+ else { -+ ap_log_error(APLOG_MARK, APLOG_EMERG, rv, NULL, msg); -+ exit(APEXIT_CHILDFATAL); -+ } -+ } -+#endif -+} -+ -+/* On some architectures it's safe to do unserialized accept()s in the single -+ * Listen case. But it's never safe to do it in the case where there's -+ * multiple Listen statements. Define SINGLE_LISTEN_UNSERIALIZED_ACCEPT -+ * when it's safe in the single Listen case. -+ */ -+#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT -+#define SAFE_ACCEPT(stmt) do {if (ap_listeners->next) {stmt;}} while(0) -+#else -+#define SAFE_ACCEPT(stmt) do {stmt;} while(0) -+#endif -+ -+AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result) -+{ -+ switch(query_code){ -+ case AP_MPMQ_MAX_DAEMON_USED: -+ *result = ap_daemons_limit; -+ return APR_SUCCESS; -+ case AP_MPMQ_IS_THREADED: -+ *result = AP_MPMQ_NOT_SUPPORTED; -+ return APR_SUCCESS; -+ case AP_MPMQ_IS_FORKED: -+ *result = AP_MPMQ_DYNAMIC; -+ return APR_SUCCESS; -+ case AP_MPMQ_HARD_LIMIT_DAEMONS: -+ *result = server_limit; -+ return APR_SUCCESS; -+ case AP_MPMQ_HARD_LIMIT_THREADS: -+ *result = HARD_THREAD_LIMIT; -+ return APR_SUCCESS; -+ case AP_MPMQ_MAX_THREADS: -+ *result = 0; -+ return APR_SUCCESS; -+ case AP_MPMQ_MIN_SPARE_DAEMONS: -+ *result = ap_min_free_processors; -+ return APR_SUCCESS; -+ case AP_MPMQ_MIN_SPARE_THREADS: -+ *result = 0; -+ return APR_SUCCESS; -+ case AP_MPMQ_MAX_SPARE_THREADS: -+ *result = 0; -+ return APR_SUCCESS; -+ case AP_MPMQ_MAX_REQUESTS_DAEMON: -+ *result = ap_max_requests_per_child; -+ return APR_SUCCESS; -+ case AP_MPMQ_MAX_DAEMONS: -+ *result = server_limit; -+ return APR_SUCCESS; -+ case AP_MPMQ_MPM_STATE: -+ *result = mpm_state; -+ return APR_SUCCESS; -+ } -+ return APR_ENOTIMPL; -+} -+ -+#if defined(NEED_WAITPID) -+/* -+ Systems without a real waitpid sometimes lose a child's exit while waiting -+ for another. Search through the scoreboard for missing children. -+ */ -+int reap_children(int *exitcode, apr_exit_why_e *status) -+{ -+ int n, pid; -+ -+ for (n = 0; n < ap_max_daemons_limit; ++n) { -+ if (ap_scoreboard_image->servers[n][0].status != SERVER_DEAD && -+ kill((pid = ap_scoreboard_image->parent[n].pid), 0) == -1) { -+ ap_update_child_status_from_indexes(n, 0, SERVER_DEAD, NULL); -+ /* just mark it as having a successful exit status */ -+ *status = APR_PROC_EXIT; -+ *exitcode = 0; -+ return(pid); -+ } -+ } -+ return 0; -+} -+#endif -+ -+/* handle all varieties of core dumping signals */ -+static void sig_coredump(int sig) -+{ -+ int retval; -+ retval = chdir(ap_coredump_dir); -+ apr_signal(sig, SIG_DFL); -+ if (ap_my_pid == parent_pid) { -+ ap_log_error(APLOG_MARK, APLOG_NOTICE, -+ 0, ap_server_conf, -+ "seg fault or similar nasty error detected " -+ "in the parent process"); -+ } -+ kill(getpid(), sig); -+ /* At this point we've got sig blocked, because we're still inside -+ * the signal handler. When we leave the signal handler it will -+ * be unblocked, and we'll take the signal... and coredump or whatever -+ * is appropriate for this particular Unix. In addition the parent -+ * will see the real signal we received -- whereas if we called -+ * abort() here, the parent would only see SIGABRT. -+ */ -+} -+ -+/***************************************************************** -+ * Connection structures and accounting... -+ */ -+ -+static void just_die(int sig) -+{ -+_DBG("function called"); -+ clean_child_exit(0); -+} -+ -+/* volatile just in case */ -+static int volatile shutdown_pending; -+static int volatile restart_pending; -+static int volatile is_graceful; -+/* XXX static int volatile child_fatal; */ -+ -+static void sig_term(int sig) -+{ -+ if (shutdown_pending == 1) { -+ /* Um, is this _probably_ not an error, if the user has -+ * tried to do a shutdown twice quickly, so we won't -+ * worry about reporting it. -+ */ -+ return; -+ } -+ shutdown_pending = 1; -+} -+ -+/* restart() is the signal handler for SIGHUP and AP_SIG_GRACEFUL -+ * in the parent process, unless running in ONE_PROCESS mode -+ */ -+static void restart(int sig) -+{ -+ if (restart_pending == 1) { -+ /* Probably not an error - don't bother reporting it */ -+ return; -+ } -+ restart_pending = 1; -+ is_graceful = (sig == AP_SIG_GRACEFUL); -+} -+ -+/* Sets die_now if we received a character on the pipe_of_death */ -+static apr_status_t check_pipe_of_death -+( -+ void **csd, -+ ap_listen_rec *lr, -+ apr_pool_t *ptrans -+) -+{ -+ int ret; -+ char pipe_read_char; -+ apr_size_t n = 1; -+ -+ _DBG("WATCH: die_now=%d", die_now); -+ -+ if (die_now) return APR_SUCCESS; -+ -+ /* apr_thread_mutex_lock(pipe_of_death_mutex); */ -+ ret = apr_socket_recv(lr->sd, &pipe_read_char, &n); -+ if (APR_STATUS_IS_EAGAIN(ret)) -+ { -+ /* It lost the lottery. It must continue to suffer -+ * through a life of servitude. */ -+ } -+ else -+ { -+ if (pipe_read_char != AP_PERUSER_CHAR_OF_DEATH) -+ { -+ _DBG("got wrong char %c", pipe_read_char); -+ return APR_SUCCESS; -+ } -+ /* It won the lottery (or something else is very -+ * wrong). Embrace death with open arms. */ -+ die_now = 1; -+ _DBG("WATCH: die_now=%d", die_now); -+ } -+ /* apr_thread_mutex_unlock(pipe_of_death_mutex); */ -+ return APR_SUCCESS; -+} -+ -+static void set_signals(void) -+{ -+#ifndef NO_USE_SIGACTION -+ struct sigaction sa; -+ -+ sigemptyset(&sa.sa_mask); -+ sa.sa_flags = 0; -+ -+ if (!one_process) { -+ sa.sa_handler = sig_coredump; -+#if defined(SA_ONESHOT) -+ sa.sa_flags = SA_ONESHOT; -+#elif defined(SA_RESETHAND) -+ sa.sa_flags = SA_RESETHAND; -+#endif -+ if (sigaction(SIGSEGV, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGSEGV)"); -+#ifdef SIGBUS -+ if (sigaction(SIGBUS, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGBUS)"); -+#endif -+#ifdef SIGABORT -+ if (sigaction(SIGABORT, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGABORT)"); -+#endif -+#ifdef SIGABRT -+ if (sigaction(SIGABRT, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGABRT)"); -+#endif -+#ifdef SIGILL -+ if (sigaction(SIGILL, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGILL)"); -+#endif -+ sa.sa_flags = 0; -+ } -+ sa.sa_handler = sig_term; -+ if (sigaction(SIGTERM, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGTERM)"); -+#ifdef SIGINT -+ if (sigaction(SIGINT, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGINT)"); -+#endif -+#ifdef SIGXCPU -+ sa.sa_handler = SIG_DFL; -+ if (sigaction(SIGXCPU, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGXCPU)"); -+#endif -+#ifdef SIGXFSZ -+ sa.sa_handler = SIG_IGN; -+ if (sigaction(SIGXFSZ, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGXFSZ)"); -+#endif -+#ifdef SIGPIPE -+ sa.sa_handler = SIG_IGN; -+ if (sigaction(SIGPIPE, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGPIPE)"); -+#endif -+ -+ /* we want to ignore HUPs and AP_SIG_GRACEFUL while we're busy -+ * processing one */ -+ sigaddset(&sa.sa_mask, SIGHUP); -+ sigaddset(&sa.sa_mask, AP_SIG_GRACEFUL); -+ sa.sa_handler = restart; -+ if (sigaction(SIGHUP, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGHUP)"); -+ if (sigaction(AP_SIG_GRACEFUL, &sa, NULL) < 0) -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(" AP_SIG_GRACEFUL_STRING ")"); -+#else -+ if (!one_process) { -+ apr_signal(SIGSEGV, sig_coredump); -+#ifdef SIGBUS -+ apr_signal(SIGBUS, sig_coredump); -+#endif /* SIGBUS */ -+#ifdef SIGABORT -+ apr_signal(SIGABORT, sig_coredump); -+#endif /* SIGABORT */ -+#ifdef SIGABRT -+ apr_signal(SIGABRT, sig_coredump); -+#endif /* SIGABRT */ -+#ifdef SIGILL -+ apr_signal(SIGILL, sig_coredump); -+#endif /* SIGILL */ -+#ifdef SIGXCPU -+ apr_signal(SIGXCPU, SIG_DFL); -+#endif /* SIGXCPU */ -+#ifdef SIGXFSZ -+ apr_signal(SIGXFSZ, SIG_DFL); -+#endif /* SIGXFSZ */ -+ } -+ -+ apr_signal(SIGTERM, sig_term); -+#ifdef SIGHUP -+ apr_signal(SIGHUP, restart); -+#endif /* SIGHUP */ -+#ifdef AP_SIG_GRACEFUL -+ apr_signal(AP_SIG_GRACEFUL, restart); -+#endif /* AP_SIG_GRACEFUL */ -+#ifdef SIGPIPE -+ apr_signal(SIGPIPE, SIG_IGN); -+#endif /* SIGPIPE */ -+ -+#endif -+} -+ -+/***************************************************************** -+ * Child process main loop. -+ * The following vars are static to avoid getting clobbered by longjmp(); -+ * they are really private to child_main. -+ */ -+ -+static int requests_this_child; -+static int num_listensocks = 0; -+static ap_listen_rec *listensocks; -+ -+int ap_graceful_stop_signalled(void) -+{ -+ /* not ever called anymore... */ -+ return 0; -+} -+ -+/* -+ * This function sends a raw socket over to a processor. It uses the same -+ * on-wire format as pass_request. The recipient can determine if he got -+ * a socket or a whole request by inspecting the header_length of the -+ * message. If it is zero then only a socket was sent. -+ */ -+static int pass_socket(apr_socket_t *thesock, child_info_t *processor, apr_pool_t *pool) -+{ -+ int rv; -+ struct msghdr msg; -+ struct cmsghdr *cmsg; -+ apr_sockaddr_t *remote_addr; -+ int sock_fd; -+ char *body = ""; -+ struct iovec iov[5]; -+ apr_size_t header_len = 0; -+ apr_size_t body_len = 0; -+ peruser_header h; -+ -+ if (!processor) -+ { -+ _DBG("server %s in child %d has no child_info associated", -+ "(unkonwn)", my_child_num); -+ return -1; -+ } -+ -+ _DBG("passing request to another child.", 0); -+ -+ apr_os_sock_get(&sock_fd, thesock); -+ /* passing remote_addr too, see comments below */ -+ apr_socket_addr_get(&remote_addr, APR_REMOTE, thesock); -+ -+ header_len = 0; -+ body_len = 0; -+ -+ iov[0].iov_base = &header_len; -+ iov[0].iov_len = sizeof(header_len); -+ iov[1].iov_base = &body_len; -+ iov[1].iov_len = sizeof(body_len); -+ iov[2].iov_base = remote_addr; -+ iov[2].iov_len = sizeof(*remote_addr); -+ iov[3].iov_base = h.headers; -+ iov[3].iov_len = 0; -+ iov[4].iov_base = body; -+ iov[4].iov_len = body_len; -+ -+ msg.msg_name = NULL; -+ msg.msg_namelen = 0; -+ msg.msg_iov = iov; -+ msg.msg_iovlen = 5; -+ -+ cmsg = apr_palloc(pool, sizeof(*cmsg) + sizeof(sock_fd)); -+ cmsg->cmsg_len = sizeof(*cmsg) + sizeof(sock_fd); -+ cmsg->cmsg_level = SOL_SOCKET; -+ cmsg->cmsg_type = SCM_RIGHTS; -+ -+ memcpy(CMSG_DATA(cmsg), &sock_fd, sizeof(sock_fd)); -+ -+ msg.msg_control = cmsg; -+ msg.msg_controllen = cmsg->cmsg_len; -+ -+ if (processor->status == CHILD_STATUS_STANDBY) -+ { -+ _DBG("Activating child #%d", processor->id); -+ processor->status = CHILD_STATUS_STARTING; -+ } -+ -+ _DBG("Writing message to %d, passing sock_fd: %d", processor->senv->output, sock_fd); -+ _DBG("header_len=%d headers=\"%s\"", header_len, h.headers); -+ _DBG("body_len=%d body=\"%s\"", body_len, body); -+ -+ if ((rv = sendmsg(processor->senv->output, &msg, 0)) == -1) -+ { -+ apr_pool_destroy(pool); -+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, -+ "Writing message failed %d %d", rv, errno); -+ return -1; -+ } -+ -+ _DBG("Writing message succeeded %d", rv); -+ -+ /* -- close the socket on our side -- */ -+ _DBG("closing socket %d on our side", sock_fd); -+ apr_socket_close(thesock); -+ -+ apr_pool_destroy(pool); -+ return 1; -+} -+ -+static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id, -+ apr_bucket_alloc_t *bucket_alloc, apr_pool_t *pool) -+{ -+ conn_rec *current_conn; -+ int sock_fd; -+ apr_status_t rv; -+ ap_sb_handle_t *sbh; -+ child_info_t *processor; -+ apr_pool_t *ptrans; -+ peruser_server_conf *sconf; -+ -+ _DBG("Creating dummy connection to use the vhost lookup api", 0); -+ -+ ap_create_sb_handle(&sbh, p, conn_id, 0); -+ current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id, -+ sbh, bucket_alloc); -+ _DBG("Looking up the right vhost"); -+ if (current_conn) { -+ ap_update_vhost_given_ip(current_conn); -+ _DBG("Base server is %s, name based vhosts %s", current_conn->base_server->server_hostname, -+ current_conn->vhost_lookup_data ? "on" : "off"); -+ } -+ -+ if (current_conn && !current_conn->vhost_lookup_data && CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER) { -+ _DBG("We are not using name based vhosts, we'll directly pass the socket."); -+ -+ sconf = PERUSER_SERVER_CONF(current_conn->base_server->module_config); -+ processor = &CHILD_INFO_TABLE[sconf->senv->processor_id]; -+ -+ _DBG("Forwarding without further inspection, processor %d", processor->id); -+ if (processor->status == CHILD_STATUS_STANDBY) -+ { -+ _DBG("Activating child #%d", processor->id); -+ processor->status = CHILD_STATUS_STARTING; -+ } -+ -+ _DBG("Creating new pool",0); -+ apr_pool_create(&ptrans, pool); -+ _DBG("Passing request.",0); -+ if (pass_socket(sock, processor, ptrans) == -1) -+ { -+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, -+ ap_server_conf, "Could not pass request to proper " -+ "child, request will not be honoured."); -+ return; -+ } -+ if (current_conn) -+ { -+ _DBG("freeing connection",0); -+ ap_lingering_close(current_conn); -+ } -+ _DBG("doing longjmp",0); -+ longjmp(CHILD_INFO_TABLE[my_child_num].jmpbuffer, 1); -+ return; -+ } -+ -+ if ((rv = apr_os_sock_get(&sock_fd, sock)) != APR_SUCCESS) -+ { -+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "apr_os_sock_get"); -+ } -+ -+ _DBG("child_num=%d sock=%ld sock_fd=%d\n", my_child_num, sock, sock_fd); -+ _DBG("type=%s %d", child_type_string(CHILD_INFO_TABLE[my_child_num].type), my_child_num); -+ -+ if (sock_fd >= FD_SETSIZE) -+ { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, -+ "new file descriptor %d is too large; you probably need " -+ "to rebuild Apache with a larger FD_SETSIZE " -+ "(currently %d)", -+ sock_fd, FD_SETSIZE); -+ apr_socket_close(sock); -+ _DBG("child_num=%d: exiting with error", my_child_num); -+ return; -+ } -+ -+ if (CHILD_INFO_TABLE[my_child_num].sock_fd < 0) -+ { -+ ap_sock_disable_nagle(sock); -+ } -+ -+ if (!current_conn) { -+ ap_create_sb_handle(&sbh, p, conn_id, 0); -+ current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id, -+ sbh, bucket_alloc); -+ } -+ -+ if (current_conn) -+ { -+ ap_process_connection(current_conn, sock); -+ ap_lingering_close(current_conn); -+ } -+} -+ -+static int peruser_process_connection(conn_rec *conn) -+{ -+ ap_filter_t *filter; -+ apr_bucket_brigade *bb; -+ core_net_rec *net; -+ -+ _DBG("function entered",0); -+ -+ /* -- fetch our sockets from the pool -- */ -+ apr_pool_userdata_get((void **)&bb, "PERUSER_SOCKETS", conn->pool); -+ if (bb != NULL) -+ { -+ /* -- find the 'core' filter and give the socket data to it -- */ -+ for (filter = conn->output_filters; filter != NULL; filter = filter->next) -+ { -+ if (!strcmp(filter->frec->name, "core")) break; -+ } -+ if (filter != NULL) -+ { -+ net = filter->ctx; -+ net->in_ctx = apr_palloc(conn->pool, sizeof(*net->in_ctx)); -+ net->in_ctx->b = bb; -+ net->in_ctx->tmpbb = apr_brigade_create(net->in_ctx->b->p, -+ net->in_ctx->b->bucket_alloc); -+ } -+ } -+ _DBG("leaving (DECLINED)", 0); -+ return DECLINED; -+} -+ -+static int total_processors(int child_num) -+{ -+ int i, total; -+ -+ for(i = 0, total = 0; i < NUM_CHILDS; ++i) -+ { -+ if(CHILD_INFO_TABLE[i].senv == CHILD_INFO_TABLE[child_num].senv) -+ total++; -+ } -+ -+ return total; -+} -+ -+static int idle_processors(int child_num) -+{ -+ int i, total; -+ -+ for(i = 0, total = 0; i < NUM_CHILDS; ++i) -+ { -+ if(CHILD_INFO_TABLE[i].senv == CHILD_INFO_TABLE[child_num].senv && -+ (SCOREBOARD_STATUS(i) == SERVER_STARTING || -+ SCOREBOARD_STATUS(i) == SERVER_READY)) -+ { -+ total++; -+ } -+ } -+ -+ return total; -+} -+ -+static int pass_request(request_rec *r, child_info_t *processor) -+{ -+ int rv; -+ struct msghdr msg; -+ struct cmsghdr *cmsg; -+ apr_sockaddr_t *remote_addr; -+ int sock_fd; -+ char *body = ""; -+ struct iovec iov[5]; -+ conn_rec *c = r->connection; -+ apr_bucket_brigade *bb = apr_brigade_create(r->pool, c->bucket_alloc); -+ apr_bucket_brigade *body_bb = NULL; -+ apr_size_t len = 0; -+ apr_size_t header_len = 0; -+ apr_size_t body_len = 0; -+ peruser_header h; -+ apr_bucket *bucket; -+ const apr_array_header_t *headers_in_array; -+ const apr_table_entry_t *headers_in; -+ int counter; -+ -+ apr_socket_t *thesock = ap_get_module_config(r->connection->conn_config, &core_module); -+ -+ if ((!r->the_request) || (!strlen(r->the_request))) -+ { -+ _DBG("empty request. dropping it (%ld)", r->the_request); -+ return -1; -+ } -+ -+ if (!processor) -+ { -+ _DBG("server %s in child %d has no child_info associated", -+ r->hostname, my_child_num); -+ return -1; -+ } -+ -+ _DBG("passing request to another child. Vhost: %s, child %d %d", -+ apr_table_get(r->headers_in, "Host"), my_child_num, processor->senv->output); -+ _DBG("r->the_request=\"%s\" len=%d", r->the_request, strlen(r->the_request)); -+ -+ ap_get_brigade(r->connection->input_filters, bb, AP_MODE_EXHAUSTIVE, APR_NONBLOCK_READ, len); -+ -+ /* Scan the brigade looking for heap-buckets */ -+ -+ _DBG("Scanning the brigade",0); -+ bucket = APR_BRIGADE_FIRST(bb); -+ while (bucket != APR_BRIGADE_SENTINEL(bb) && -+ APR_BUCKET_IS_HEAP(bucket)) { -+ _DBG("HEAP BUCKET is found, length=%d", bucket->length); -+ bucket = APR_BUCKET_NEXT(bucket); -+ if (!APR_BUCKET_IS_HEAP(bucket)) { -+ _DBG("NON-HEAP BUCKET is found, extracting the part of brigade before it",0); -+ body_bb = bb; -+ bb = apr_brigade_split(body_bb, bucket); -+ /* Do we need to apr_destroy_brigade(bb) here? -+ * Yeah, I know we do apr_pool_destroy(r->pool) before return, but -+ * ap_get_brigade is in non-blocking mode (however len is zero). -+ */ -+ if (apr_brigade_pflatten(body_bb, &body, &body_len, r->pool) != APR_SUCCESS) { -+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, -+ "Unable to flatten brigade, declining request"); -+ apr_pool_destroy(r->pool); -+ return DECLINED; -+ } -+ _DBG("Brigade is flattened as body (body_len=%d)", body_len); -+ } -+ } -+ _DBG("Scanning is finished",0); -+ -+ apr_os_sock_get(&sock_fd, thesock); -+ /* looks like a bug while sending/receiving SCM_RIGHTS related to ipv6 -+ workaround: send remote_addr structure too */ -+ apr_socket_addr_get(&remote_addr, APR_REMOTE, thesock); -+ -+ h.p = r->pool; -+ -+ headers_in_array = apr_table_elts(r->headers_in); -+ headers_in = (const apr_table_entry_t *) headers_in_array->elts; -+ -+ h.headers = apr_pstrcat(h.p, r->the_request, CRLF, NULL); -+ for (counter = 0; counter < headers_in_array->nelts; counter++) { -+ if (headers_in[counter].key == NULL -+ || headers_in[counter].val == NULL) { -+ continue; -+ } -+ h.headers = apr_pstrcat(h.p, h.headers, headers_in[counter].key, ": ", -+ headers_in[counter].val, CRLF, NULL); -+ -+ } -+ h.headers = apr_pstrcat(h.p, h.headers, CRLF, NULL); -+ ap_xlate_proto_to_ascii(h.headers, strlen(h.headers)); -+ -+ header_len = strlen(h.headers); -+ -+ iov[0].iov_base = &header_len; -+ iov[0].iov_len = sizeof(header_len); -+ iov[1].iov_base = &body_len; -+ iov[1].iov_len = sizeof(body_len); -+ iov[2].iov_base = remote_addr; -+ iov[2].iov_len = sizeof(*remote_addr); -+ iov[3].iov_base = h.headers; -+ iov[3].iov_len = strlen(h.headers) + 1; -+ iov[4].iov_base = body; -+ iov[4].iov_len = body_len; -+ -+ msg.msg_name = NULL; -+ msg.msg_namelen = 0; -+ msg.msg_iov = iov; -+ msg.msg_iovlen = 5; -+ -+ cmsg = apr_palloc(r->pool, sizeof(*cmsg) + sizeof(sock_fd)); -+ cmsg->cmsg_len = sizeof(*cmsg) + sizeof(sock_fd); -+ cmsg->cmsg_level = SOL_SOCKET; -+ cmsg->cmsg_type = SCM_RIGHTS; -+ -+ memcpy(CMSG_DATA(cmsg), &sock_fd, sizeof(sock_fd)); -+ -+ msg.msg_control = cmsg; -+ msg.msg_controllen = cmsg->cmsg_len; -+ -+ -+ if (processor->status == CHILD_STATUS_STANDBY) -+ { -+ _DBG("Activating child #%d", processor->id); -+ processor->status = CHILD_STATUS_STARTING; -+ } -+ -+ _DBG("Writing message to %d, passing sock_fd: %d", processor->senv->output, sock_fd); -+ _DBG("header_len=%d headers=\"%s\"", header_len, h.headers); -+ _DBG("body_len=%d body=\"%s\"", body_len, body); -+ -+ if ((rv = sendmsg(processor->senv->output, &msg, 0)) == -1) -+ { -+ apr_pool_destroy(r->pool); -+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, -+ "Writing message failed %d %d", rv, errno); -+ return -1; -+ } -+ -+ _DBG("Writing message succeeded %d", rv); -+ -+ /* -- close the socket on our side -- */ -+ _DBG("closing socket %d on our side", sock_fd); -+ apr_socket_close(thesock); -+ -+ apr_pool_destroy(r->pool); -+ return 1; -+} -+ -+ -+static apr_status_t receive_from_multiplexer( -+ void **trans_sock, /* will be filled out w/ the received socket */ -+ ap_listen_rec *lr, /* listener to receive from */ -+ apr_pool_t *ptrans /* transaction wide pool */ -+) -+{ -+ struct msghdr msg; -+ struct cmsghdr *cmsg; -+ char buff[HUGE_STRING_LEN] = ""; -+ char headers[HUGE_STRING_LEN] = ""; -+ char *body = ""; -+ apr_size_t header_len, body_len; -+ struct iovec iov[4]; -+ int ret, fd_tmp; -+ apr_os_sock_t ctrl_sock_fd; -+ apr_os_sock_t trans_sock_fd; -+ apr_sockaddr_t remote_addr; -+ apr_os_sock_info_t sockinfo; -+ -+ /* -- bucket's, brigades and their allocators */ -+ apr_bucket_alloc_t *alloc = apr_bucket_alloc_create(ptrans); -+ apr_bucket_brigade *bb = apr_brigade_create(ptrans, alloc); -+ apr_bucket *bucket; -+ -+ /* prepare the buffers for receiving data from remote side */ -+ iov[0].iov_base = &header_len; -+ iov[0].iov_len = sizeof(header_len); -+ iov[1].iov_base = &body_len; -+ iov[1].iov_len = sizeof(body_len); -+ iov[2].iov_base = &remote_addr; -+ iov[2].iov_len = sizeof(remote_addr); -+ iov[3].iov_base = (char*)&buff; -+ iov[3].iov_len = HUGE_STRING_LEN; -+ -+ cmsg = apr_palloc(ptrans, sizeof(*cmsg) + sizeof(trans_sock_fd)); -+ cmsg->cmsg_len = sizeof(*cmsg) + sizeof(trans_sock_fd); -+ -+ msg.msg_name = NULL; -+ msg.msg_namelen = 0; -+ msg.msg_iov = iov; -+ msg.msg_iovlen = 4; -+ msg.msg_control = cmsg; -+ msg.msg_controllen = cmsg->cmsg_len; -+ -+ /* -- receive data from socket -- */ -+ apr_os_sock_get(&ctrl_sock_fd, lr->sd); -+ _DBG("receiving from sock_fd=%d", ctrl_sock_fd); -+ ret = recvmsg(ctrl_sock_fd, &msg, 0); -+ -+ if(ret == -1) -+ _DBG("recvmsg failed with error \"%s\"", strerror(errno)); -+ else -+ _DBG("recvmsg returned %d", ret); -+ -+ /* -- extract socket from the cmsg -- */ -+ memcpy(&trans_sock_fd, CMSG_DATA(cmsg), sizeof(trans_sock_fd)); -+ /* here *trans_sock always == NULL (socket reset at got_fd), so -+ we can use apr_os_sock_make() instead of apr_os_sock_put() */ -+ sockinfo.os_sock = &trans_sock_fd; -+ sockinfo.local = NULL; -+ sockinfo.remote = (struct sockaddr *)&remote_addr.sa.sin; -+ sockinfo.family = remote_addr.family; -+ sockinfo.type = SOCK_STREAM; -+#ifdef APR_ENABLE_FOR_1_0 -+ sockinfo.protocol = 0; -+#endif -+ apr_os_sock_make((apr_socket_t **)trans_sock, &sockinfo, ptrans); -+ apr_os_sock_get(&fd_tmp, *trans_sock); -+ -+ _DBG("trans_sock=%ld fdx=%d sock_fd=%d", -+ *trans_sock, trans_sock_fd, fd_tmp); -+ -+ apr_cpystrn(headers, buff, header_len + 1); -+ _DBG("header_len=%d headers=\"%s\"", header_len, headers); -+ -+if (header_len) { -+ _DBG("header_len > 0, we got a request", 0); -+ /* -- store received data into an brigade and add -+ it to the current transaction's pool -- */ -+ bucket = apr_bucket_eos_create(alloc); -+ APR_BRIGADE_INSERT_HEAD(bb, bucket); -+ bucket = apr_bucket_socket_create(*trans_sock, alloc); -+ APR_BRIGADE_INSERT_HEAD(bb, bucket); -+ -+ if (body_len) { -+ body = (char*)&buff[header_len + 1]; -+ _DBG("body_len=%d body=\"%s\"", body_len, body); -+ -+ bucket = apr_bucket_heap_create(body, body_len, NULL, alloc); -+ APR_BRIGADE_INSERT_HEAD(bb, bucket); -+ } else { -+ _DBG("There is no body",0); -+ } -+ -+ bucket = apr_bucket_heap_create(headers, header_len, NULL, alloc); -+ -+ APR_BRIGADE_INSERT_HEAD(bb, bucket); -+ apr_pool_userdata_set(bb, "PERUSER_SOCKETS", NULL, ptrans); -+} else { -+ _DBG("header_len == 0, we got a socket only", 0); -+} -+ _DBG("returning 0", 0); -+ return 0; -+} -+ -+ -+/* Set group privileges. -+ * -+ * Note that we use the username as set in the config files, rather than -+ * the lookup of to uid --- the same uid may have multiple passwd entries, -+ * with different sets of groups for each. -+ */ -+ -+static int set_group_privs(uid_t uid, gid_t gid) -+{ -+ if (!geteuid()) -+ { -+ struct passwd *ent; -+ const char *name; -+ -+ /* -+ * Set the GID before initgroups(), since on some platforms -+ * setgid() is known to zap the group list. -+ */ -+ if (setgid(gid) == -1) -+ { -+ ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL, -+ "setgid: unable to set group id to Group %u", -+ (unsigned)gid); -+ return -1; -+ } -+ -+ /* if getpwuid() fails, just skip initgroups() */ -+ -+ if ((ent = getpwuid(uid)) != NULL) -+ { -+ name = ent->pw_name; -+ -+ /* Reset `groups' attributes. */ -+ -+ if (initgroups(name, gid) == -1) -+ { -+ ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL, -+ "initgroups: unable to set groups for User %s " -+ "and Group %u", name, (unsigned)gid); -+ return -1; -+ } -+ } -+ } -+ return 0; -+} -+ -+static int peruser_setup_child(int childnum) -+{ -+ server_env_t *senv = CHILD_INFO_TABLE[childnum].senv; -+ -+ if(senv->chroot) { -+ _DBG("chdir to %s", senv->chroot); -+ if(chdir(senv->chroot)) { -+ ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL, -+ "chdir: unable to change to directory: %s", -+ senv->chroot); -+ return -1; -+ } -+ -+ _DBG("chroot to %s", senv->chroot); -+ if(chroot(senv->chroot)) { -+ ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL, -+ "chroot: unable to change root to: %s", -+ senv->chroot); -+ return -1; -+ } -+ } -+ -+ if (senv->uid == -1 && senv->gid == -1) { -+ return unixd_setup_child(); -+ } -+ if (set_group_privs(senv->uid, senv->gid)) { -+ return -1; -+ } -+ /* Only try to switch if we're running as root */ -+ if (!geteuid() -+ && ( -+#ifdef _OSD_POSIX -+ os_init_job_environment(ap_server_conf, unixd_config.user_name, -+ one_process) != 0 || -+#endif -+ setuid(senv->uid) == -1)) { -+ ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL, -+ "setuid: unable to change to uid: %ld", -+ (long) senv->uid); -+ return -1; -+ } -+ return 0; -+} -+ -+static int check_signal(int signum) -+{ -+ _DBG("signum=%d", signum); -+ switch (signum) { -+ case SIGTERM: -+ case SIGINT: -+ just_die(signum); -+ return 1; -+ } -+ return 0; -+} -+ -+/* Send a single HTTP header field to the client. Note that this function -+ * is used in calls to table_do(), so their interfaces are co-dependent. -+ * In other words, don't change this one without checking table_do in alloc.c. -+ * It returns true unless there was a write error of some kind. -+ */ -+static int peruser_header_field(peruser_header *h, -+ const char *fieldname, const char *fieldval) -+{ -+ apr_pstrcat(h->p, h->headers, fieldname, ": ", fieldval, CRLF, NULL); -+ return 1; -+} -+ -+static inline ap_listen_rec* listen_add(apr_pool_t* pool, apr_socket_t *sock, void* accept_func) -+{ -+ ap_listen_rec *lr_walk, *lr_new; -+ -+ _DBG("function entered", 0); -+ /* -- create an new listener for this child -- */ -+ lr_new = apr_palloc(pool, sizeof(*lr_new)); -+ lr_new->sd = sock; -+ lr_new->active = 1; -+ lr_new->accept_func = accept_func; -+ lr_new->next = NULL; -+ -+ /* -- add the new listener_rec into the list -- */ -+ /* FIXME: should we somehow lock this list ? */ -+ lr_walk = ap_listeners; -+ if (lr_walk) -+ { -+ while (lr_walk->next) lr_walk = lr_walk->next; -+ lr_walk->next = lr_new; -+ } -+ else -+ { -+ ap_listeners = lr_walk = lr_new; -+ } -+ num_listensocks++; -+ return lr_new; -+} -+ -+static inline void listen_clear() -+{ -+ ap_listen_rec *lr_walk; -+ -+ _DBG("function entered", 0); -+ -+ /* FIXME: should we somehow lock this list ? */ -+ while (ap_listeners) -+ { -+ lr_walk = ap_listeners->next; -+ apr_socket_close(ap_listeners->sd); -+ ap_listeners = lr_walk; -+ } -+ num_listensocks=0; -+} -+ -+apr_status_t cleanup_child_info(void *d) -+{ -+ if (child_info_image == NULL) { -+ return APR_SUCCESS; -+ } -+ -+ free(child_info_image); -+ child_info_image = NULL; -+ apr_shm_destroy(child_info_shm); -+ -+ return APR_SUCCESS; -+} -+ -+apr_status_t cleanup_server_environments(void *d) -+{ -+ if (server_env_image == NULL) { -+ return APR_SUCCESS; -+ } -+ -+ free(server_env_image); -+ server_env_image = NULL; -+ apr_shm_destroy(server_env_shm); -+ -+ return APR_SUCCESS; -+} -+ -+static const char* child_clone(); -+ -+static void child_main(int child_num_arg) -+{ -+ apr_pool_t *ptrans; -+ apr_allocator_t *allocator; -+ conn_rec *current_conn; -+ apr_status_t status = APR_EINIT; -+ int i; -+ ap_listen_rec *lr; -+ int curr_pollfd, last_pollfd = 0; -+ apr_pollfd_t *pollset; -+ int offset; -+ ap_sb_handle_t *sbh; -+ apr_status_t rv; -+ apr_bucket_alloc_t *bucket_alloc; -+ int fd; -+ apr_socket_t *sock = NULL; -+ apr_socket_t *pod_sock = NULL; -+ -+ mpm_state = AP_MPMQ_STARTING; /* for benefit of any hooks that run as this -+ * child initializes -+ */ -+ -+ my_child_num = child_num_arg; -+ ap_my_pid = getpid(); -+ requests_this_child = 0; -+ -+ _DBG("sock_fd_in=%d sock_fd_out=%d", -+ CHILD_INFO_TABLE[my_child_num].senv->input, -+ CHILD_INFO_TABLE[my_child_num].senv->output); -+ -+ /* Get a sub context for global allocations in this child, so that -+ * we can have cleanups occur when the child exits. -+ */ -+ apr_allocator_create(&allocator); -+ apr_allocator_max_free_set(allocator, ap_max_mem_free); -+ apr_pool_create_ex(&pchild, pconf, NULL, allocator); -+ apr_allocator_owner_set(allocator, pchild); -+ -+ apr_pool_create(&ptrans, pchild); -+ apr_pool_tag(ptrans, "transaction"); -+ -+ /* needs to be done before we switch UIDs so we have permissions */ -+ ap_reopen_scoreboard(pchild, NULL, 0); -+ -+ rv = apr_proc_mutex_child_init(&accept_mutex, ap_lock_fname, pchild); -+ if (rv != APR_SUCCESS) { -+ ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, -+ "Couldn't initialize cross-process lock in child"); -+ clean_child_exit(APEXIT_CHILDFATAL); -+ } -+ -+ switch(CHILD_INFO_TABLE[my_child_num].type) -+ { -+ case CHILD_TYPE_MULTIPLEXER: -+ _DBG("MULTIPLEXER %d", my_child_num); -+ -+ /* update status on processors that are ready to accept requests */ -+ _DBG("updating processor stati", 0); -+ for(i = 0; i < NUM_CHILDS; ++i) -+ { -+ if(CHILD_INFO_TABLE[i].status == CHILD_STATUS_READY) -+ CHILD_INFO_TABLE[i].status = CHILD_STATUS_ACTIVE; -+ } -+ -+ break; -+ -+ case CHILD_TYPE_PROCESSOR: -+ case CHILD_TYPE_WORKER: -+ _DBG("%s %d", child_type_string(CHILD_INFO_TABLE[my_child_num].type), my_child_num); -+ -+ /* -- create new listener to receive from multiplexer -- */ -+ apr_os_sock_put(&sock, &CHILD_INFO_TABLE[my_child_num].senv->input, pconf); -+ listen_clear(); -+ listen_add(pconf, sock, receive_from_multiplexer); -+ -+ break; -+ -+ default: -+ _DBG("unspecified child type for %d sleeping a while ...", my_child_num); -+ sleep(5); -+ return; -+ } -+ -+ apr_os_file_get(&fd, pipe_of_death_in); -+ apr_os_sock_put(&pod_sock, &fd, pconf); -+ listen_add(pconf, pod_sock, check_pipe_of_death); -+ -+ if(peruser_setup_child(my_child_num) != 0) -+ clean_child_exit(APEXIT_CHILDFATAL); -+ -+ ap_run_child_init(pchild, ap_server_conf); -+ -+ ap_create_sb_handle(&sbh, pchild, my_child_num, 0); -+ (void) ap_update_child_status(sbh, SERVER_READY, (request_rec *) NULL); -+ -+ /* Set up the pollfd array */ -+ listensocks = apr_pcalloc(pchild, -+ sizeof(*listensocks) * (num_listensocks)); -+ for (lr = ap_listeners, i = 0; i < num_listensocks; lr = lr->next, i++) { -+ listensocks[i].accept_func = lr->accept_func; -+ listensocks[i].sd = lr->sd; -+ } -+ -+ pollset = apr_palloc(pchild, sizeof(*pollset) * num_listensocks); -+ pollset[0].p = pchild; -+ for (i = 0; i < num_listensocks; i++) { -+ pollset[i].desc.s = listensocks[i].sd; -+ pollset[i].desc_type = APR_POLL_SOCKET; -+ pollset[i].reqevents = APR_POLLIN; -+ } -+ -+ mpm_state = AP_MPMQ_RUNNING; -+ -+ bucket_alloc = apr_bucket_alloc_create(pchild); -+ -+ while (!die_now) { -+ /* -+ * (Re)initialize this child to a pre-connection state. -+ */ -+ -+ current_conn = NULL; -+ -+ apr_pool_clear(ptrans); -+ -+ if (CHILD_INFO_TABLE[my_child_num].type != CHILD_TYPE_MULTIPLEXER -+ && ap_max_requests_per_child > 0 -+ && requests_this_child++ >= ap_max_requests_per_child) { -+ _DBG("max requests reached, dying now", 0); -+ clean_child_exit(0); -+ } -+ -+ (void) ap_update_child_status(sbh, SERVER_READY, (request_rec *) NULL); -+ -+ /* -+ * Wait for an acceptable connection to arrive. -+ */ -+ -+ /* Lock around "accept", if necessary */ -+ SAFE_ACCEPT(accept_mutex_on()); -+ -+ if (num_listensocks == 1) { -+ offset = 0; -+ } -+ else { -+ /* multiple listening sockets - need to poll */ -+ for (;;) { -+ apr_status_t ret; -+ apr_int32_t n; -+ -+ ret = apr_poll(pollset, num_listensocks, &n, -1); -+ if (ret != APR_SUCCESS) { -+ if (APR_STATUS_IS_EINTR(ret)) { -+ continue; -+ } -+ /* Single Unix documents select as returning errnos -+ * EBADF, EINTR, and EINVAL... and in none of those -+ * cases does it make sense to continue. In fact -+ * on Linux 2.0.x we seem to end up with EFAULT -+ * occasionally, and we'd loop forever due to it. -+ */ -+ ap_log_error(APLOG_MARK, APLOG_ERR, ret, ap_server_conf, -+ "apr_poll: (listen)"); -+ clean_child_exit(1); -+ } -+ /* find a listener */ -+ curr_pollfd = last_pollfd; -+ do { -+ curr_pollfd++; -+ if (curr_pollfd >= num_listensocks) { -+ curr_pollfd = 0; -+ } -+ /* XXX: Should we check for POLLERR? */ -+ if (pollset[curr_pollfd].rtnevents & APR_POLLIN) { -+ last_pollfd = curr_pollfd; -+ offset = curr_pollfd; -+ goto got_fd; -+ } -+ } while (curr_pollfd != last_pollfd); -+ -+ continue; -+ } -+ } -+ got_fd: -+ _DBG("input available ... resetting socket.",0); -+ sock = NULL; /* important! */ -+ -+ /* if we accept() something we don't want to die, so we have to -+ * defer the exit -+ */ -+ status = listensocks[offset].accept_func((void *)&sock, &listensocks[offset], ptrans); -+ SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */ -+ -+ if (status == APR_EGENERAL) { -+ /* resource shortage or should-not-occur occurred */ -+ clean_child_exit(1); -+ } -+ else if (status != APR_SUCCESS || die_now) { -+ continue; -+ } -+ -+ if (CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_PROCESSOR || -+ CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_WORKER) -+ { -+ _DBG("CHECKING IF WE SHOULD CLONE A CHILD..."); -+ -+ _DBG("total_processors = %d, max_processors = %d", -+ total_processors(my_child_num), -+ CHILD_INFO_TABLE[my_child_num].senv->max_processors); -+ -+ _DBG("idle_processors = %d, min_free_processors = %d", -+ idle_processors(my_child_num), -+ CHILD_INFO_TABLE[my_child_num].senv->min_free_processors); -+ -+ if(total_processors(my_child_num) < -+ CHILD_INFO_TABLE[my_child_num].senv->max_processors && -+ idle_processors(my_child_num) <= -+ CHILD_INFO_TABLE[my_child_num].senv->min_free_processors) -+ { -+ _DBG("CLONING CHILD"); -+ child_clone(); -+ } -+ } -+ -+ if (!setjmp(CHILD_INFO_TABLE[my_child_num].jmpbuffer)) -+ { -+ _DBG("marked jmpbuffer",0); -+ _TRACE_CALL("process_socket()",0); -+ process_socket(ptrans, sock, my_child_num, bucket_alloc, pchild); -+ _TRACE_RET("process_socket()",0); -+ } -+ else -+ { -+ _DBG("landed from longjmp",0); -+ CHILD_INFO_TABLE[my_child_num].sock_fd = AP_PERUSER_THISCHILD; -+ } -+ -+ /* Check the pod and the generation number after processing a -+ * connection so that we'll go away if a graceful restart occurred -+ * while we were processing the connection or we are the lucky -+ * idle server process that gets to die. -+ */ -+ if (ap_mpm_pod_check(pod) == APR_SUCCESS) { /* selected as idle? */ -+ _DBG("ap_mpm_pod_check(pod) = APR_SUCCESS; dying now", 0); -+ die_now = 1; -+ } -+ else if (ap_my_generation != -+ ap_scoreboard_image->global->running_generation) { /* restart? */ -+ /* yeah, this could be non-graceful restart, in which case the -+ * parent will kill us soon enough, but why bother checking? -+ */ -+ _DBG("ap_my_generation != ap_scoreboard_image->global->running_generation; dying now", 0); -+ die_now = 1; -+ } -+ -+ if(CHILD_INFO_TABLE[my_child_num].status == CHILD_STATUS_RESTART) -+ { -+ _DBG("restarting", 0); -+ die_now = 1; -+ } -+ } -+ -+ _DBG("clean_child_exit(0)"); -+ clean_child_exit(0); -+} -+ -+static server_env_t* senv_add(int uid, int gid, const char* chroot) -+{ -+ int i; -+ int socks[2]; -+ -+ _DBG("Searching for matching senv..."); -+ -+ for(i = 0; i < NUM_SENV; i++) -+ { -+ if(SENV[i].uid == uid && SENV[i].gid == gid && -+ (SENV[i].chroot == NULL || !strcmp(SENV[i].chroot, chroot))) -+ { -+ _DBG("Found existing senv: %i", i); -+ return &SENV[i]; -+ } -+ } -+ -+ if(NUM_SENV >= server_limit) -+ { -+ _DBG("server_limit reached!"); -+ return NULL; -+ } -+ -+ _DBG("Creating new senv"); -+ -+ SENV[NUM_SENV].uid = uid; -+ SENV[NUM_SENV].gid = gid; -+ SENV[NUM_SENV].chroot = chroot; -+ -+ SENV[NUM_SENV].min_processors = ap_min_processors; -+ SENV[NUM_SENV].min_free_processors = ap_min_free_processors; -+ SENV[NUM_SENV].max_processors = ap_max_processors; -+ -+ socketpair(PF_UNIX, SOCK_STREAM, 0, socks); -+ SENV[NUM_SENV].input = socks[0]; -+ SENV[NUM_SENV].output = socks[1]; -+ -+ return &SENV[server_env_image->control->num++]; -+} -+ -+static const char* child_clone() -+{ -+ int i; -+ child_info_t *this; -+ child_info_t *new; -+ -+ for(i = 0; i < NUM_CHILDS; i++) -+ { -+ if(CHILD_INFO_TABLE[i].pid == 0 && -+ CHILD_INFO_TABLE[i].type == CHILD_TYPE_UNKNOWN) break; -+ } -+ -+ if(i == NUM_CHILDS && NUM_CHILDS >= server_limit) -+ { -+ _DBG("Trying to use more child ID's than NumServers. " -+ "Increase NumServers in your config file."); -+ return NULL; -+ } -+ -+ _DBG("cloning child #%d from #%d", i, my_child_num); -+ -+ this = &CHILD_INFO_TABLE[my_child_num]; -+ new = &CHILD_INFO_TABLE[i]; -+ -+ new->senv = this->senv; -+ new->type = CHILD_TYPE_WORKER; -+ new->sock_fd = this->sock_fd; -+ new->status = CHILD_STATUS_STARTING; -+ -+ if(i == NUM_CHILDS) child_info_image->control->num++; -+ return NULL; -+} -+ -+static const char* child_add(int type, int status, -+ apr_pool_t *pool, uid_t uid, gid_t gid, const char* chroot) -+{ -+ _DBG("adding child #%d", NUM_CHILDS); -+ -+ if(NUM_CHILDS >= server_limit) -+ { -+ return "Trying to use more child ID's than NumServers. " -+ "Increase NumServers in your config file."; -+ } -+ -+ if (chroot && !ap_is_directory(pool, chroot)) -+ return apr_psprintf(pool, "Error: chroot directory [%s] does not exist", chroot); -+ -+ CHILD_INFO_TABLE[NUM_CHILDS].senv = senv_add(uid, gid, chroot); -+ -+ if(CHILD_INFO_TABLE[NUM_CHILDS].senv == NULL) -+ { -+ return "Trying to use more server environments than NumServers. " -+ "Increase NumServers in your config file."; -+ } -+ -+ if(type != CHILD_TYPE_WORKER) -+ CHILD_INFO_TABLE[NUM_CHILDS].senv->processor_id = NUM_CHILDS; -+ -+ CHILD_INFO_TABLE[NUM_CHILDS].type = type; -+ CHILD_INFO_TABLE[NUM_CHILDS].sock_fd = AP_PERUSER_THISCHILD; -+ CHILD_INFO_TABLE[NUM_CHILDS].status = status; -+ -+ _DBG("[%d] uid=%d gid=%d type=%d chroot=%s", -+ NUM_CHILDS, uid, gid, type, -+ chroot); -+ -+ if (uid == 0 || gid == 0) -+ { -+ _DBG("Assigning root user/group to a child.", 0); -+ } -+ -+ child_info_image->control->num++; -+ -+ return NULL; -+} -+ -+static int make_child(server_rec *s, int slot) -+{ -+ int pid; -+ -+ _DBG("function entered", 0); -+ dump_server_env_image(); -+ -+ switch (CHILD_INFO_TABLE[slot].type) -+ { -+ case CHILD_TYPE_MULTIPLEXER: break; -+ case CHILD_TYPE_PROCESSOR: break; -+ case CHILD_TYPE_WORKER: break; -+ -+ default: -+ _DBG("no valid client in slot %d", slot); -+ /* sleep(1); */ -+ return 0; -+ } -+ -+ if (slot + 1 > ap_max_daemons_limit) { -+ ap_max_daemons_limit = slot + 1; -+ } -+ -+ if (one_process) { -+ apr_signal(SIGHUP, just_die); -+ /* Don't catch AP_SIG_GRACEFUL in ONE_PROCESS mode :) */ -+ apr_signal(SIGINT, just_die); -+#ifdef SIGQUIT -+ apr_signal(SIGQUIT, SIG_DFL); -+#endif -+ apr_signal(SIGTERM, just_die); -+ child_main(slot); -+ } -+ -+ (void) ap_update_child_status_from_indexes(slot, 0, SERVER_STARTING, -+ (request_rec *) NULL); -+ -+ CHILD_INFO_TABLE[slot].status = CHILD_STATUS_ACTIVE; -+ -+ -+#ifdef _OSD_POSIX -+ /* BS2000 requires a "special" version of fork() before a setuid() call */ -+ if ((pid = os_fork(unixd_config.user_name)) == -1) { -+#elif defined(TPF) -+ if ((pid = os_fork(s, slot)) == -1) { -+#else -+ if ((pid = fork()) == -1) { -+#endif -+ ap_log_error(APLOG_MARK, APLOG_ERR, errno, s, "fork: Unable to fork new process"); -+ -+ /* fork didn't succeed. Fix the scoreboard or else -+ * it will say SERVER_STARTING forever and ever -+ */ -+ (void) ap_update_child_status_from_indexes(slot, 0, SERVER_DEAD, -+ (request_rec *) NULL); -+ -+ /* In case system resources are maxxed out, we don't want -+ Apache running away with the CPU trying to fork over and -+ over and over again. */ -+ sleep(10); -+ -+ return -1; -+ } -+ -+ if (!pid) { -+#ifdef HAVE_BINDPROCESSOR -+ /* by default AIX binds to a single processor -+ * this bit unbinds children which will then bind to another cpu -+ */ -+ int status = bindprocessor(BINDPROCESS, (int)getpid(), -+ PROCESSOR_CLASS_ANY); -+ if (status != OK) { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, -+ ap_server_conf, "processor unbind failed %d", status); -+ } -+#endif -+ RAISE_SIGSTOP(MAKE_CHILD); -+ AP_MONCONTROL(1); -+ /* Disable the parent's signal handlers and set up proper handling in -+ * the child. -+ */ -+ apr_signal(SIGHUP, just_die); -+ apr_signal(SIGTERM, just_die); -+ /* The child process doesn't do anything for AP_SIG_GRACEFUL. -+ * Instead, the pod is used for signalling graceful restart. -+ */ -+ /* apr_signal(AP_SIG_GRACEFUL, restart); */ -+ child_main(slot); -+ clean_child_exit(0); -+ } -+ -+ ap_scoreboard_image->parent[slot].pid = pid; -+ CHILD_INFO_TABLE[slot].pid = pid; -+ -+ ap_child_table[slot].pid = pid; -+ ap_child_table[slot].status = SERVER_ALIVE; -+ -+ return 0; -+} -+ -+ -+/* -+ * idle_spawn_rate is the number of children that will be spawned on the -+ * next maintenance cycle if there aren't enough idle servers. It is -+ * doubled up to MAX_SPAWN_RATE, and reset only when a cycle goes by -+ * without the need to spawn. -+ */ -+static int idle_spawn_rate = 1; -+#ifndef MAX_SPAWN_RATE -+#define MAX_SPAWN_RATE (32) -+#endif -+static int total_processes(int child_num) -+{ -+ int i, total; -+ for(i = 0, total = 0; i < NUM_CHILDS; ++i) -+ { -+ if(CHILD_INFO_TABLE[i].senv == CHILD_INFO_TABLE[child_num].senv && -+ (!(CHILD_INFO_TABLE[i].type == CHILD_TYPE_PROCESSOR && -+ CHILD_INFO_TABLE[i].status == CHILD_STATUS_STANDBY))) -+ { -+ total++; -+ } -+ } -+ return total; -+} -+ -+static void perform_idle_server_maintenance(apr_pool_t *p) -+{ -+ int i; -+ apr_time_t now; -+ -+ /* _DBG("function entered", 0); */ -+ -+ now = apr_time_now(); -+ -+ for (i = 0; i < NUM_CHILDS; ++i) -+ { -+ if(CHILD_INFO_TABLE[i].pid == 0) -+ { -+ if(CHILD_INFO_TABLE[i].status == CHILD_STATUS_STARTING) -+ make_child(ap_server_conf, i); -+ } -+ else if(((CHILD_INFO_TABLE[i].type == CHILD_TYPE_PROCESSOR || -+ CHILD_INFO_TABLE[i].type == CHILD_TYPE_WORKER) && -+ ap_scoreboard_image->parent[i].pid > 1) && -+ (idle_processors (i) > 1 || total_processes (i) == 1) && ( -+ (expire_timeout > 0 && ap_scoreboard_image->servers[i][0].status != SERVER_DEAD && -+ apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > expire_timeout) || -+ (idle_timeout > 0 && ap_scoreboard_image->servers[i][0].status == SERVER_READY && -+ apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > idle_timeout))) -+ { -+ CHILD_INFO_TABLE[i].pid = 0; -+ CHILD_INFO_TABLE[i].status = CHILD_STATUS_STANDBY; -+ -+ if(CHILD_INFO_TABLE[i].type == CHILD_TYPE_WORKER) -+ { -+ /* completely free up this slot */ -+ -+ CHILD_INFO_TABLE[i].senv = (server_env_t*)NULL; -+ CHILD_INFO_TABLE[i].type = CHILD_TYPE_UNKNOWN; -+ CHILD_INFO_TABLE[i].sock_fd = -3; /* -1 and -2 are taken */ -+ } -+ if(kill(ap_scoreboard_image->parent[i].pid, SIGTERM) == -1) -+ { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, -+ ap_server_conf, "kill SIGTERM"); -+ } -+ -+ -+ ap_update_child_status_from_indexes(i, 0, SERVER_DEAD, NULL); -+ } -+ } -+ -+ for(i=0;i<grace_children;i++) { -+ if (child_grace_info_table[i].pid > 0 && expire_timeout > 0 && -+ apr_time_sec(now - child_grace_info_table[i].last_used) > expire_timeout) { -+ -+ _DBG("Killing a child from last graceful (pid=%d,childno=%d,last_used=%d)", -+ child_grace_info_table[i].pid, child_grace_info_table[i].id, -+ child_grace_info_table[i].last_used); -+ -+ if(kill(child_grace_info_table[i].pid, SIGTERM) == -1) -+ { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, -+ ap_server_conf, "kill SIGTERM"); -+ } -+ -+ /* We don't need to do remove_grace_child() here, -+ * because it will be automatically done once -+ * the child dies by ap_mpm_run() */ -+ } -+ } -+} -+ -+int remove_grace_child(int slot) { -+ if (slot < grace_children) { -+ child_grace_info_table[slot].id = 0; -+ child_grace_info_table[slot].pid = 0; -+ child_grace_info_table[slot].status = CHILD_STATUS_STANDBY; -+ child_grace_info_table[slot].type = CHILD_TYPE_UNKNOWN; -+ child_grace_info_table[slot].last_used = 0; -+ grace_children_alive--; -+ -+ if (grace_children_alive <= 0) { /* All children have returned from graceful */ -+ _DBG("Every child has returned from graceful restart - freeing child_grace_info_table"); -+ grace_children_alive = 0; -+ is_graceful = 0; -+ grace_children = 0; -+ free(child_grace_info_table); -+ } -+ return 0; -+ } -+ return 1; -+} -+ -+/***************************************************************** -+ * Executive routines. -+ */ -+ -+int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) -+{ -+ int i; -+/* int fd; */ -+ apr_status_t rv; -+ apr_size_t one = 1; -+/* apr_socket_t *sock = NULL; */ -+ -+ ap_log_pid(pconf, ap_pid_fname); -+ -+ first_server_limit = server_limit; -+ if (changed_limit_at_restart) { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, 0, s, -+ "WARNING: Attempt to change ServerLimit " -+ "ignored during restart"); -+ changed_limit_at_restart = 0; -+ } -+ -+ ap_server_conf = s; -+ -+ /* Initialize cross-process accept lock */ -+ ap_lock_fname = apr_psprintf(_pconf, "%s.%" APR_PID_T_FMT, -+ ap_server_root_relative(_pconf, ap_lock_fname), -+ ap_my_pid); -+ -+ rv = apr_proc_mutex_create(&accept_mutex, ap_lock_fname, -+ ap_accept_lock_mech, _pconf); -+ if (rv != APR_SUCCESS) { -+ ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, -+ "Couldn't create accept lock"); -+ mpm_state = AP_MPMQ_STOPPING; -+ return 1; -+ } -+ -+#if 0 -+#if APR_USE_SYSVSEM_SERIALIZE -+ if (ap_accept_lock_mech == APR_LOCK_DEFAULT || -+ ap_accept_lock_mech == APR_LOCK_SYSVSEM) { -+#else -+ if (ap_accept_lock_mech == APR_LOCK_SYSVSEM) { -+#endif -+ rv = unixd_set_proc_mutex_perms(accept_mutex); -+ if (rv != APR_SUCCESS) { -+ ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, -+ "Couldn't set permissions on cross-process lock; " -+ "check User and Group directives"); -+ mpm_state = AP_MPMQ_STOPPING; -+ return 1; -+ } -+ } -+#endif -+ -+ if (!is_graceful) { -+ if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) { -+ mpm_state = AP_MPMQ_STOPPING; -+ return 1; -+ } -+ /* fix the generation number in the global score; we just got a new, -+ * cleared scoreboard -+ */ -+ ap_scoreboard_image->global->running_generation = ap_my_generation; -+ } -+ -+ /* Initialize the child table */ -+ if (!is_graceful) -+ { -+ for (i = 0; i < server_limit; i++) -+ { -+ ap_child_table[i].pid = 0; -+ } -+ } -+ -+ /* We need to put the new listeners at the end of the ap_listeners -+ * list. If we don't, then the pool will be cleared before the -+ * open_logs phase is called for the second time, and ap_listeners -+ * will have only invalid data. If that happens, then the sockets -+ * that we opened using make_sock() will be lost, and the server -+ * won't start. -+ */ -+ -+/* -+ apr_os_file_get(&fd, pipe_of_death_in); -+ apr_os_sock_put(&sock, &fd, pconf); -+ -+ listen_add(pconf, sock, check_pipe_of_death); -+*/ -+ set_signals(); -+ -+ if (one_process) { -+ AP_MONCONTROL(1); -+ } -+ -+ ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, -+ "%s configured -- resuming normal operations", -+ ap_get_server_version()); -+ ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf, -+ "Server built: %s", ap_get_server_built()); -+#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH -+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, -+ "AcceptMutex: %s (default: %s)", -+ apr_proc_mutex_name(accept_mutex), -+ apr_proc_mutex_defname()); -+#endif -+ restart_pending = shutdown_pending = 0; -+ -+ mpm_state = AP_MPMQ_RUNNING; -+ -+ _DBG("sizeof(child_info_t) = %d", sizeof(child_info_t)); -+ -+ while (!restart_pending && !shutdown_pending) { -+ int child_slot; -+ apr_exit_why_e exitwhy; -+ int status, processed_status; -+ /* this is a memory leak, but I'll fix it later. */ -+ apr_proc_t pid; -+ -+ ap_wait_or_timeout(&exitwhy, &status, &pid, pconf); -+ -+ /* XXX: if it takes longer than 1 second for all our children -+ * to start up and get into IDLE state then we may spawn an -+ * extra child -+ */ -+ if (pid.pid != -1) { -+ processed_status = ap_process_child_status(&pid, exitwhy, status); -+ if (processed_status == APEXIT_CHILDFATAL) { -+ mpm_state = AP_MPMQ_STOPPING; -+ return 1; -+ } -+ -+ if (grace_children > 0) { -+ for(i=0;i<grace_children;i++) { -+ if (child_grace_info_table[i].pid == pid.pid) { -+ break; -+ } -+ } -+ if (i != grace_children) { -+ _DBG("Child returned from graceful (%d)", i); -+ remove_grace_child(i); -+ continue; -+ } -+ } -+ -+ /* non-fatal death... note that it's gone in the scoreboard. */ -+ child_slot = find_child_by_pid(&pid); -+ _DBG("child #%d has died ...", child_slot); -+ -+ for (i = 0; i < ap_max_daemons_limit; ++i) -+ { -+ if (ap_child_table[i].pid == pid.pid) -+ { -+ child_slot = i; -+ break; -+ } -+ } -+ -+ if (child_slot >= 0) { -+ ap_child_table[child_slot].pid = 0; -+ _TRACE_CALL("ap_update_child_status_from_indexes", 0); -+ (void) ap_update_child_status_from_indexes(child_slot, 0, SERVER_DEAD, -+ (request_rec *) NULL); -+ _TRACE_RET("ap_update_child_status_from_indexes", 0); -+ -+ if (processed_status == APEXIT_CHILDSICK) { -+ /* child detected a resource shortage (E[NM]FILE, ENOBUFS, etc) -+ * cut the fork rate to the minimum -+ */ -+ _DBG("processed_status = APEXIT_CHILDSICK", 0); -+ idle_spawn_rate = 1; -+ } -+ else if (CHILD_INFO_TABLE[child_slot].status == CHILD_STATUS_STANDBY) { -+ _DBG("leaving child in standby state", 0); -+ } -+ else if (child_slot < ap_daemons_limit && -+ CHILD_INFO_TABLE[child_slot].type != -+ CHILD_TYPE_UNKNOWN) { -+ /* we're still doing a 1-for-1 replacement of dead -+ * children with new children -+ */ -+ _DBG("replacing by new child ...", 0); -+ make_child(ap_server_conf, child_slot); -+ } -+#if APR_HAS_OTHER_CHILD -+ } -+ else if (apr_proc_other_child_alert(&pid, APR_OC_REASON_DEATH, status) == APR_SUCCESS) { -+ _DBG("Already handled", 0); -+ /* handled */ -+#endif -+ } -+ else if (is_graceful) { -+ /* Great, we've probably just lost a slot in the -+ * scoreboard. Somehow we don't know about this -+ * child. -+ */ -+ _DBG("long lost child came home, whatever that means", 0); -+ -+ ap_log_error(APLOG_MARK, APLOG_WARNING, -+ 0, ap_server_conf, -+ "long lost child came home! (pid %ld)", (long)pid.pid); -+ } -+ /* Don't perform idle maintenance when a child dies, -+ * only do it when there's a timeout. Remember only a -+ * finite number of children can die, and it's pretty -+ * pathological for a lot to die suddenly. -+ */ -+ continue; -+ } -+ -+ perform_idle_server_maintenance(pconf); -+#ifdef TPF -+ shutdown_pending = os_check_server(tpf_server_name); -+ ap_check_signals(); -+ sleep(1); -+#endif /*TPF */ -+ } -+ -+ mpm_state = AP_MPMQ_STOPPING; -+ -+ if (shutdown_pending) { -+ /* Time to gracefully shut down: -+ * Kill child processes, tell them to call child_exit, etc... -+ */ -+ if (unixd_killpg(getpgrp(), SIGTERM) < 0) { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "killpg SIGTERM"); -+ } -+ ap_reclaim_child_processes(1); /* Start with SIGTERM */ -+ -+ /* cleanup pid file on normal shutdown */ -+ { -+ const char *pidfile = NULL; -+ pidfile = ap_server_root_relative (pconf, ap_pid_fname); -+ if ( pidfile != NULL && unlink(pidfile) == 0) -+ ap_log_error(APLOG_MARK, APLOG_INFO, -+ 0, ap_server_conf, -+ "removed PID file %s (pid=%ld)", -+ pidfile, (long)getpid()); -+ } -+ -+ ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, -+ "caught SIGTERM, shutting down"); -+ return 1; -+ } -+ -+ /* we've been told to restart */ -+ apr_signal(SIGHUP, SIG_IGN); -+ if (one_process) { -+ /* not worth thinking about */ -+ return 1; -+ } -+ -+ /* advance to the next generation */ -+ /* XXX: we really need to make sure this new generation number isn't in -+ * use by any of the children. -+ */ -+ ++ap_my_generation; -+ ap_scoreboard_image->global->running_generation = ap_my_generation; -+ -+ if (is_graceful) { -+ char char_of_death = AP_PERUSER_CHAR_OF_DEATH; -+ -+ ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, -+ "Graceful restart requested, doing restart"); -+ -+#if 0 -+ /* kill off the idle ones */ -+ ap_mpm_pod_killpg(pod, ap_max_daemons_limit); -+ -+ /* This is mostly for debugging... so that we know what is still -+ * gracefully dealing with existing request. This will break -+ * in a very nasty way if we ever have the scoreboard totally -+ * file-based (no shared memory) -+ */ -+ for (i = 0; i < ap_daemons_limit; ++i) { -+ if (ap_scoreboard_image->servers[i][0].status != SERVER_DEAD) { -+ ap_scoreboard_image->servers[i][0].status = SERVER_GRACEFUL; -+ } -+ } -+#endif -+ -+ ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, -+ ap_server_conf, AP_SIG_GRACEFUL_STRING " received. " -+ "Doing graceful restart"); -+ -+ /* This is mostly for debugging... so that we know what is still -+ * gracefully dealing with existing request. -+ */ -+ -+ int alivechildren = 0; -+ child_grace_info_t* old_grace_info; -+ -+ for (i = 0; i < NUM_CHILDS; ++i) -+ { -+ ((ap_child_table[i].pid) && (ap_child_table[i].status = SERVER_DYING)); -+ -+ if (CHILD_INFO_TABLE[i].pid) { -+ alivechildren++; -+ } -+ } -+ -+ _DBG("Initializing child_grace_info_table", 0); -+ -+ if (alivechildren > 0) { -+ if (grace_children > 0) { -+ old_grace_info = child_grace_info_table; -+ _DBG("%d children still living from last graceful " -+ "- adding to new child_grace_info_table", -+ grace_children); -+ } -+ -+ child_grace_info_table = (child_grace_info_t*)calloc(alivechildren+grace_children, -+ sizeof(child_grace_info_t)); -+ -+ if (grace_children > 0) { -+ for(i=0;i<grace_children;i++) { -+ child_grace_info_table[i] = old_grace_info[i]; -+ } -+ grace_children = i; -+ free(old_grace_info); -+ } -+ else grace_children = 0; -+ -+ } -+ -+ /* give the children the signal to die */ -+ for (i = 0; i < NUM_CHILDS;) -+ { -+ if ((rv = apr_file_write(pipe_of_death_out, &char_of_death, &one)) != APR_SUCCESS) -+ { -+ if (APR_STATUS_IS_EINTR(rv)) continue; -+ ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf, -+ "write pipe_of_death"); -+ } -+ if (CHILD_INFO_TABLE[i].pid) { -+ child_grace_info_table[grace_children].id = CHILD_INFO_TABLE[i].id; -+ child_grace_info_table[grace_children].pid = CHILD_INFO_TABLE[i].pid; -+ child_grace_info_table[grace_children].status = CHILD_INFO_TABLE[i].status; -+ child_grace_info_table[grace_children].type = CHILD_INFO_TABLE[i].type; -+ child_grace_info_table[grace_children].last_used= ap_scoreboard_image->servers[i][0].last_used; -+ grace_children++; -+ grace_children_alive++; -+ } -+ i++; -+ } -+ _DBG("Total children of %d leaving behind for graceful restart (%d living)", -+ grace_children, grace_children_alive); -+ -+ /* destroy server_env_image */ -+ for (i = 0; i < NUM_SENV; i++) -+ { -+ close(SENV[i].input); -+ close(SENV[i].output); -+ } -+ cleanup_server_environments(NULL); -+ } -+ else { -+ /* Kill 'em off */ -+ if (unixd_killpg(getpgrp(), SIGHUP) < 0) { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "killpg SIGHUP"); -+ } -+ ap_reclaim_child_processes(0); /* Not when just starting up */ -+ ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, -+ "SIGHUP received. Attempting to restart"); -+ } -+ -+ return 0; -+} -+ -+/* == allocate an private server config structure == */ -+static void *peruser_create_config(apr_pool_t *p, server_rec *s) -+{ -+ peruser_server_conf *c = (peruser_server_conf *) -+ apr_pcalloc(p, sizeof(peruser_server_conf)); -+ return c; -+} -+ -+/* This really should be a post_config hook, but the error log is already -+ * redirected by that point, so we need to do this in the open_logs phase. -+ */ -+static int peruser_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) -+{ -+ apr_status_t rv; -+ -+ pconf = p; -+ ap_server_conf = s; -+ -+ if ((num_listensocks = ap_setup_listeners(ap_server_conf)) < 1) { -+ ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_STARTUP, 0, -+ NULL, "no listening sockets available, shutting down"); -+ return DONE; -+ } -+ -+ ap_log_pid(pconf, ap_pid_fname); -+ -+ if ((rv = ap_mpm_pod_open(pconf, &pod))) { -+ ap_log_error(APLOG_MARK, APLOG_CRIT|APLOG_STARTUP, rv, NULL, -+ "Could not open pipe-of-death."); -+ return DONE; -+ } -+ -+ if ((rv = apr_file_pipe_create(&pipe_of_death_in, &pipe_of_death_out, -+ pconf)) != APR_SUCCESS) { -+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, -+ (const server_rec*) ap_server_conf, -+ "apr_file_pipe_create (pipe_of_death)"); -+ exit(1); -+ } -+ if ((rv = apr_file_pipe_timeout_set(pipe_of_death_in, 0)) != APR_SUCCESS) { -+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, -+ (const server_rec*) ap_server_conf, -+ "apr_file_pipe_timeout_set (pipe_of_death)"); -+ exit(1); -+ } -+ -+ return OK; -+} -+ -+static int restart_num = 0; -+static int peruser_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) -+{ -+ int no_detach, debug, foreground, i; -+ int tmp_server_limit = DEFAULT_SERVER_LIMIT; -+ ap_directive_t *pdir; -+ apr_status_t rv; -+ apr_pool_t *global_pool; -+ void *shmem; -+ -+ mpm_state = AP_MPMQ_STARTING; -+ -+ debug = ap_exists_config_define("DEBUG"); -+ -+ if (debug) { -+ foreground = one_process = 1; -+ no_detach = 0; -+ } -+ else -+ { -+ no_detach = ap_exists_config_define("NO_DETACH"); -+ one_process = ap_exists_config_define("ONE_PROCESS"); -+ foreground = ap_exists_config_define("FOREGROUND"); -+ } -+ -+ /* sigh, want this only the second time around */ -+ if (restart_num++ == 1) { -+ if (!one_process && !foreground) { -+ rv = apr_proc_detach(no_detach ? APR_PROC_DETACH_FOREGROUND -+ : APR_PROC_DETACH_DAEMONIZE); -+ if (rv != APR_SUCCESS) { -+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, -+ "apr_proc_detach failed"); -+ return HTTP_INTERNAL_SERVER_ERROR; -+ } -+ } -+ -+ parent_pid = ap_my_pid = getpid(); -+ } -+ -+ unixd_pre_config(ptemp); -+ ap_listen_pre_config(); -+ ap_min_processors = DEFAULT_MIN_PROCESSORS; -+ ap_min_free_processors = DEFAULT_MIN_FREE_PROCESSORS; -+ ap_max_processors = DEFAULT_MAX_PROCESSORS; -+ ap_daemons_limit = server_limit; -+ ap_pid_fname = DEFAULT_PIDLOG; -+ ap_lock_fname = DEFAULT_LOCKFILE; -+ ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD; -+ ap_extended_status = 1; -+#ifdef AP_MPM_WANT_SET_MAX_MEM_FREE -+ ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED; -+#endif -+ -+ apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); -+ -+ /* we need to know ServerLimit and ThreadLimit before we start processing -+ * the tree because we need to already have allocated child_info_table -+ */ -+ for (pdir = ap_conftree; pdir != NULL; pdir = pdir->next) -+ { -+ if (!strcasecmp(pdir->directive, "ServerLimit")) -+ { -+ if (atoi(pdir->args) > tmp_server_limit) -+ { -+ tmp_server_limit = atoi(pdir->args); -+ if (tmp_server_limit > MAX_SERVER_LIMIT) -+ { -+ tmp_server_limit = MAX_SERVER_LIMIT; -+ } -+ } -+ } -+ } -+ -+ /* We don't want to have to recreate the scoreboard after -+ * restarts, so we'll create a global pool and never clean it. -+ */ -+ rv = apr_pool_create(&global_pool, NULL); -+ if (rv != APR_SUCCESS) { -+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, -+ "Fatal error: unable to create global pool"); -+ return rv; -+ } -+ -+ -+ _DBG("Initializing child_info_table", 0); -+ child_info_size = tmp_server_limit * sizeof(child_info_t) + sizeof(apr_size_t); -+ -+ rv = apr_shm_create(&child_info_shm, child_info_size, NULL, global_pool); -+ -+/* if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) { */ -+ if (rv != APR_SUCCESS) { -+ _DBG("shared memory creation failed", 0); -+ -+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, -+ "Unable to create shared memory segment " -+ "(anonymous shared memory failure)"); -+ } -+ else if (rv == APR_ENOTIMPL) { -+ _DBG("anonymous shared memory not available", 0); -+ /* TODO: make up a filename and do name-based shmem */ -+ } -+ -+ if (rv || !(shmem = apr_shm_baseaddr_get(child_info_shm))) { -+ _DBG("apr_shm_baseaddr_get() failed", 0); -+ return HTTP_INTERNAL_SERVER_ERROR; -+ } -+ -+ memset(shmem, 0, sizeof(child_info_size)); -+ child_info_image = (child_info*)calloc(1, sizeof(child_info_size)); -+ child_info_image->control = (child_info_control*)shmem; -+ shmem += sizeof(child_info_control*); -+ child_info_image->table = (child_info_t*)shmem; -+ -+ child_info_image->control->num = 0; -+ -+ for (i = 0; i < tmp_server_limit; i++) -+ { -+ CHILD_INFO_TABLE[i].pid = 0; -+ CHILD_INFO_TABLE[i].senv = (server_env_t*)NULL; -+ CHILD_INFO_TABLE[i].type = CHILD_TYPE_UNKNOWN; -+ CHILD_INFO_TABLE[i].status = CHILD_STATUS_STANDBY; -+ CHILD_INFO_TABLE[i].sock_fd = -3; /* -1 and -2 are taken */ -+ CHILD_INFO_TABLE[i].id = i; -+ } -+ -+ if (!server_env_image) -+ { -+ _DBG("Initializing server_environments_table", 0); -+ server_env_size = tmp_server_limit * sizeof(server_env_t) + sizeof(apr_size_t); -+ -+ rv = apr_shm_create(&server_env_shm, server_env_size, NULL, global_pool); -+ -+ if (rv != APR_SUCCESS) { -+ _DBG("shared memory creation failed", 0); -+ -+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, -+ "Unable to create shared memory segment " -+ "(anonymous shared memory failure)"); -+ } -+ else if (rv == APR_ENOTIMPL) { -+ _DBG("anonymous shared memory not available", 0); -+ /* TODO: make up a filename and do name-based shmem */ -+ } -+ -+ if (rv || !(shmem = apr_shm_baseaddr_get(server_env_shm))) { -+ _DBG("apr_shm_baseaddr_get() failed", 0); -+ return HTTP_INTERNAL_SERVER_ERROR; -+ } -+ -+ memset(shmem, 0, sizeof(server_env_size)); -+ server_env_image = (server_env*)calloc(1, sizeof(server_env_size)); -+ server_env_image->control = (server_env_control*)shmem; -+ shmem += sizeof(server_env_control*); -+ server_env_image->table = (server_env_t*)shmem; -+ -+ server_env_image->control->num = 0; -+ -+ for (i = 0; i < tmp_server_limit; i++) -+ { -+ SENV[i].processor_id = -1; -+ SENV[i].uid = -1; -+ SENV[i].gid = -1; -+ SENV[i].chroot = NULL; -+ SENV[i].input = -1; -+ SENV[i].output = -1; -+ } -+ } -+ -+ return OK; -+} -+ -+static int peruser_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *server_list) -+{ -+ ap_child_table = (ap_ctable *)apr_pcalloc(p, server_limit * sizeof(ap_ctable)); -+ -+ return OK; -+} -+ -+static int peruser_post_read(request_rec *r) -+{ -+ peruser_server_conf *sconf = PERUSER_SERVER_CONF(r->server->module_config); -+ child_info_t *processor; -+ -+ if(CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER) -+ processor = &CHILD_INFO_TABLE[sconf->senv->processor_id]; -+ else -+ processor = &CHILD_INFO_TABLE[r->connection->id]; -+ -+ -+ if (!strlen(r->the_request)) -+ { -+ _DBG("corrupt request. aborting",0); -+ return DECLINED; -+ } -+ -+ if (processor->sock_fd != AP_PERUSER_THISCHILD) -+ { -+ apr_socket_t *sock = NULL; -+ -+ apr_os_sock_put(&sock, &processor->sock_fd, r->connection->pool); -+ ap_sock_disable_nagle(sock); -+ ap_set_module_config(r->connection->conn_config, &core_module, sock); -+ _DBG("not the right socket?", 0); -+ return OK; -+ } -+ -+ switch (CHILD_INFO_TABLE[my_child_num].type) -+ { -+ case CHILD_TYPE_MULTIPLEXER: -+ { -+ _DBG("MULTIPLEXER => Determining if request should be passed. " -+ "Child Num: %d, dest-child: %d, hostname from server: %s r->hostname=%s r->the_request=\"%s\"", -+ my_child_num, processor->id, r->server->server_hostname, r->hostname, r->the_request); -+ -+ if (processor->id != my_child_num) -+ { -+ if (processor->status == CHILD_STATUS_STANDBY) -+ { -+ _DBG("Activating child #%d", processor->id); -+ processor->status = CHILD_STATUS_STARTING; -+ } -+ -+ _DBG("Passing request.",0); -+ if (pass_request(r, processor) == -1) -+ { -+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, -+ ap_server_conf, "Could not pass request to proper " "child, request will not be honoured."); -+ return DECLINED; -+ } -+ _DBG("doing longjmp",0); -+ longjmp(CHILD_INFO_TABLE[my_child_num].jmpbuffer, 1); -+ _DBG("request declined at our site",0); -+ return DECLINED; -+ _DBG("OUH! we should never reach this point",0); -+ } -+ _DBG("WTF: the server is assigned to the multiplexer! ... dropping request",0); -+ return DECLINED; -+ } -+ case CHILD_TYPE_PROCESSOR: -+ case CHILD_TYPE_WORKER: -+ { -+ if (sconf->senv != CHILD_INFO_TABLE[my_child_num].senv) { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, -+ 0, ap_server_conf, -+ "invalid virtualhost for this child! (%s)", r->hostname); -+ ap_lingering_close(r->connection); -+ return HTTP_REQUEST_TIME_OUT; -+ } -+ -+ _DBG("%s %d", child_type_string(CHILD_INFO_TABLE[my_child_num].type), my_child_num); -+ _DBG("request for %s / (server %s) seems to be for us", r->hostname, r->server->server_hostname); -+ -+ if (server_env_cleanup) -+ { -+ int i; -+ int input = sconf->senv->input; -+ int output = sconf->senv->output; -+ -+ _DBG("performing handle cleanup"); -+ for (i = 0; i < NUM_SENV; i++) -+ { -+ if (SENV[i].input > 0 && SENV[i].input != input) { -+ int retval = close(SENV[i].input); -+ if (retval < 0) { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, -+ "close(%d) failed", SENV[i].input); -+ } -+ } -+ if (SENV[i].output > 0 && SENV[i].output != output) { -+ int retval = close(SENV[i].output); -+ if (retval < 0) { -+ ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, -+ "close(%d) failed", SENV[i].output); -+ } -+ } -+ } -+ server_env_cleanup = 0; -+ } -+ -+ return OK; -+ } -+ default: -+ { -+ _DBG("unspecified child type %d in %d, dropping request", -+ CHILD_INFO_TABLE[my_child_num].type, my_child_num); -+ return DECLINED; -+ } -+ } -+ -+ _DBG("THIS POINT SHOULD NOT BE REACHED!",0); -+ return OK; -+} -+ -+static int peruser_status_hook(request_rec *r, int flags) -+{ -+ int x; -+ server_env_t *senv; -+ -+ if (flags & AP_STATUS_SHORT) -+ return OK; -+ -+ ap_rputs("<hr>\n", r); -+ ap_rputs("<h2>peruser status</h2>\n", r); -+ ap_rputs("<table border=\"0\">\n", r); -+ ap_rputs("<tr><td>ID</td><td>PID</td><td>STATUS</td><td>TYPE</td><td>UID</td>" -+ "<td>GID</td><td>CHROOT</td><td>INPUT</td>" -+ "<td>OUTPUT</td><td>SOCK_FD</td>" -+ "<td>TOTAL PROCESSORS</td><td>MAX PROCESSORS</td>" -+ "<td>IDLE PROCESSORS</td><td>MIN FREE PROCESSORS</td></tr>\n", r); -+ for (x = 0; x < NUM_CHILDS; x++) -+ { -+ senv = CHILD_INFO_TABLE[x].senv; -+ ap_rprintf(r, "<tr><td>%3d</td><td>%5d</td><td>%8s</td><td>%12s</td>" -+ "<td>%4d</td><td>%4d</td><td>%25s</td><td>%5d</td>" -+ "<td>%6d</td><td>%7d</td><td>%d</td><td>%d</td>" -+ "<td>%d</td><td>%d</td></tr>\n", -+ CHILD_INFO_TABLE[x].id, -+ CHILD_INFO_TABLE[x].pid, -+ child_status_string(CHILD_INFO_TABLE[x].status), -+ child_type_string(CHILD_INFO_TABLE[x].type), -+ senv == NULL ? -1 : senv->uid, -+ senv == NULL ? -1 : senv->gid, -+ senv == NULL ? NULL : senv->chroot, -+ senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->input, -+ senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->output, -+ CHILD_INFO_TABLE[x].sock_fd, -+ total_processors(x), -+ senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->max_processors, -+ idle_processors(x), -+ senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->min_free_processors -+ ); -+ } -+ ap_rputs("</table>\n", r); -+ -+ if (grace_children > 0) { -+ ap_rputs("<h2>peruser graceful children status</h2>\n", r); -+ ap_rprintf(r, "%d of total %d still living<br />\n", grace_children_alive, grace_children); -+ ap_rputs("<table border=\"0\">\n", r); -+ ap_rputs("<tr><td>ID</td><td>PID</td><td>STATUS</td><td>TYPE</td></tr>\n", r); -+ for (x = 0; x < grace_children; x++) { -+ ap_rprintf(r, "<tr><td>%3d</td><td>%5d</td><td>%8s</td><td>%12s</td></tr>\n", -+ child_grace_info_table[x].id, -+ child_grace_info_table[x].pid, -+ child_status_string(child_grace_info_table[x].status), -+ child_type_string(child_grace_info_table[x].type) -+ ); -+ } -+ ap_rputs("</table>\n", r); -+ } -+ return OK; -+} -+ -+static void peruser_hooks(apr_pool_t *p) -+{ -+ /* The peruser open_logs phase must run before the core's, or stderr -+ * will be redirected to a file, and the messages won't print to the -+ * console. -+ */ -+ static const char *const aszSucc[] = {"core.c", NULL}; -+ -+#ifdef AUX3 -+ (void) set42sig(); -+#endif -+ -+ ap_hook_open_logs(peruser_open_logs, NULL, aszSucc, APR_HOOK_MIDDLE); -+ ap_hook_pre_config(peruser_pre_config, NULL, NULL, APR_HOOK_MIDDLE); -+ ap_hook_post_config(peruser_post_config, NULL, NULL, APR_HOOK_MIDDLE); -+ -+ /* Both of these must be run absolutely first. If this request isn't for -+ * this server then we need to forward it to the proper child. No sense -+ * tying up this server running more post_read request hooks if it is -+ * just going to be forwarded along. The process_connection hook allows -+ * peruser to receive the passed request correctly, by automatically -+ * filling in the core_input_filter's ctx pointer. -+ */ -+ ap_hook_post_read_request(peruser_post_read, NULL, NULL, -+ APR_HOOK_REALLY_FIRST); -+ ap_hook_process_connection(peruser_process_connection, NULL, NULL, -+ APR_HOOK_REALLY_FIRST); -+ -+ APR_OPTIONAL_HOOK(ap, status_hook, peruser_status_hook, NULL, NULL, APR_HOOK_MIDDLE); -+} -+ -+/* we define an Processor w/ specific uid/gid */ -+static const char *cf_Processor(cmd_parms *cmd, void *dummy, -+ const char *user_name, const char *group_name, const char *chroot) -+{ -+ uid_t uid = ap_uname2id(user_name); -+ gid_t gid = ap_gname2id(group_name); -+ -+ _DBG("user=%s:%d group=%s:%d chroot=%s", -+ user_name, uid, group_name, gid, chroot); -+ -+ return child_add(CHILD_TYPE_PROCESSOR, CHILD_STATUS_STANDBY, -+ cmd->pool, uid, gid, chroot); -+} -+ -+/* we define an Multiplexer child w/ specific uid/gid */ -+static const char *cf_Multiplexer(cmd_parms *cmd, void *dummy, -+ const char *user_name, const char *group_name, const char *chroot) -+{ -+ uid_t uid = ap_uname2id(user_name); -+ gid_t gid = ap_gname2id(group_name); -+ -+ _DBG("user=%s:%d group=%s:%d chroot=%s [multiplexer id %d]", -+ user_name, uid, group_name, gid, chroot, NUM_CHILDS); -+ -+ return child_add(CHILD_TYPE_MULTIPLEXER, CHILD_STATUS_STARTING, -+ cmd->pool, uid, gid, chroot); -+} -+ -+static const char* cf_ServerEnvironment(cmd_parms *cmd, void *dummy, -+ const char *user_name, const char *group_name, const char *chroot) -+{ -+ int uid = ap_uname2id(user_name); -+ int gid = ap_gname2id(group_name); -+ peruser_server_conf *sconf = PERUSER_SERVER_CONF(cmd->server->module_config); -+ -+ _DBG("function entered", 0); -+ -+ if (chroot && !ap_is_directory(cmd->pool, chroot)) -+ return apr_psprintf(cmd->pool, "Error: chroot directory [%s] does not exist", chroot); -+ -+ sconf->senv = senv_add(uid, gid, chroot); -+ -+ _DBG("user=%s:%d group=%s:%d chroot=%s numchilds=%d", -+ user_name, uid, group_name, gid, chroot, NUM_CHILDS); -+ -+ return NULL; -+} -+ -+static const char *set_min_free_servers(cmd_parms *cmd, void *dummy, const char *arg) -+{ -+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); -+ if (err != NULL) { -+ return err; -+ } -+ -+ ap_min_free_processors = atoi(arg); -+ if (ap_min_free_processors <= 0) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: detected MinSpareServers set to non-positive."); -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "Resetting to 1 to avoid almost certain Apache failure."); -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "Please read the documentation."); -+ ap_min_free_processors = 1; -+ } -+ -+ return NULL; -+} -+ -+static const char *set_max_clients (cmd_parms *cmd, void *dummy, const char *arg) -+{ -+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); -+ if (err != NULL) { -+ return err; -+ } -+ -+ ap_daemons_limit = atoi(arg); -+ if (ap_daemons_limit > server_limit) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: MaxClients of %d exceeds ServerLimit value " -+ "of %d servers,", ap_daemons_limit, server_limit); -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ " lowering MaxClients to %d. To increase, please " -+ "see the ServerLimit", server_limit); -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ " directive."); -+ ap_daemons_limit = server_limit; -+ } -+ else if (ap_daemons_limit < 1) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: Require MaxClients > 0, setting to 1"); -+ ap_daemons_limit = 1; -+ } -+ return NULL; -+} -+ -+static const char *set_min_processors (cmd_parms *cmd, void *dummy, const char *arg) -+{ -+ peruser_server_conf *sconf; -+ int min_procs; -+ const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); -+ -+ if (err != NULL) { -+ return err; -+ } -+ -+ min_procs = atoi(arg); -+ -+ if (min_procs < 1) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: Require MaxProcessors > 0, setting to 1"); -+ min_procs = 1; -+ } -+ -+ if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) { -+ sconf = PERUSER_SERVER_CONF(cmd->server->module_config); -+ sconf->senv->min_processors = min_procs; -+ } -+ else { -+ ap_min_processors = min_procs; -+ } -+ -+ return NULL; -+} -+ -+static const char *set_min_free_processors (cmd_parms *cmd, void *dummy, const char *arg) -+{ -+ peruser_server_conf *sconf; -+ int min_free_procs; -+ const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); -+ -+ if (err != NULL) { -+ return err; -+ } -+ -+ min_free_procs = atoi(arg); -+ -+ if (min_free_procs < 1) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: Require MinSpareProcessors > 0, setting to 1"); -+ min_free_procs = 1; -+ } -+ -+ if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) { -+ sconf = PERUSER_SERVER_CONF(cmd->server->module_config); -+ sconf->senv->min_free_processors = min_free_procs; -+ } -+ else { -+ ap_min_free_processors = min_free_procs; -+ } -+ -+ return NULL; -+} -+ -+static const char *set_max_processors (cmd_parms *cmd, void *dummy, const char *arg) -+{ -+ peruser_server_conf *sconf; -+ int max_procs; -+ const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); -+ -+ if (err != NULL) { -+ return err; -+ } -+ -+ max_procs = atoi(arg); -+ -+ if (max_procs < 1) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: Require MaxProcessors > 0, setting to 1"); -+ max_procs = 1; -+ } -+ -+ if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) { -+ sconf = PERUSER_SERVER_CONF(cmd->server->module_config); -+ sconf->senv->max_processors = max_procs; -+ } -+ else { -+ ap_max_processors = max_procs; -+ } -+ -+ return NULL; -+} -+ -+static const char *set_server_limit (cmd_parms *cmd, void *dummy, const char *arg) -+{ -+ int tmp_server_limit; -+ -+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); -+ if (err != NULL) { -+ return err; -+ } -+ -+ tmp_server_limit = atoi(arg); -+ /* you cannot change ServerLimit across a restart; ignore -+ * any such attempts -+ */ -+ if (first_server_limit && -+ tmp_server_limit != server_limit) { -+ /* how do we log a message? the error log is a bit bucket at this -+ * point; we'll just have to set a flag so that ap_mpm_run() -+ * logs a warning later -+ */ -+ changed_limit_at_restart = 1; -+ return NULL; -+ } -+ server_limit = tmp_server_limit; -+ -+ if (server_limit > MAX_SERVER_LIMIT) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: ServerLimit of %d exceeds compile time limit " -+ "of %d servers,", server_limit, MAX_SERVER_LIMIT); -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ " lowering ServerLimit to %d.", MAX_SERVER_LIMIT); -+ server_limit = MAX_SERVER_LIMIT; -+ } -+ else if (server_limit < 1) { -+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, -+ "WARNING: Require ServerLimit > 0, setting to 1"); -+ server_limit = 1; -+ } -+ return NULL; -+} -+ -+static const char *set_expire_timeout (cmd_parms *cmd, void *dummy, const char *arg) { -+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); -+ if (err != NULL) { -+ return err; -+ } -+ -+ expire_timeout = atoi(arg); -+ -+ return NULL; -+} -+ -+static const char *set_idle_timeout (cmd_parms *cmd, void *dummy, const char *arg) { -+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); -+ if (err != NULL) { -+ return err; -+ } -+ -+ idle_timeout = atoi(arg); -+ -+ return NULL; -+} -+ -+static const command_rec peruser_cmds[] = { -+UNIX_DAEMON_COMMANDS, -+LISTEN_COMMANDS, -+AP_INIT_TAKE1("MinSpareProcessors", set_min_free_processors, NULL, RSRC_CONF, -+ "Minimum number of idle children, to handle request spikes"), -+AP_INIT_TAKE1("MinSpareServers", set_min_free_servers, NULL, RSRC_CONF, -+ "Minimum number of idle children, to handle request spikes"), -+AP_INIT_TAKE1("MaxClients", set_max_clients, NULL, RSRC_CONF, -+ "Maximum number of children alive at the same time"), -+AP_INIT_TAKE1("MinProcessors", set_min_processors, NULL, RSRC_CONF, -+ "Minimum number of processors per vhost"), -+AP_INIT_TAKE1("MaxProcessors", set_max_processors, NULL, RSRC_CONF, -+ "Maximum number of processors per vhost"), -+AP_INIT_TAKE1("ServerLimit", set_server_limit, NULL, RSRC_CONF, -+ "Maximum value of MaxClients for this run of Apache"), -+AP_INIT_TAKE1("ExpireTimeout", set_expire_timeout, NULL, RSRC_CONF, -+ "Maximum idle time before a child is killed, 0 to disable"), -+AP_INIT_TAKE1("IdleTimeout", set_idle_timeout, NULL, RSRC_CONF, -+ "Maximum time before a child is killed after being idle, 0 to disable"), -+AP_INIT_TAKE23("Multiplexer", cf_Multiplexer, NULL, RSRC_CONF, -+ "Specify an Multiplexer Child configuration."), -+AP_INIT_TAKE23("Processor", cf_Processor, NULL, RSRC_CONF, -+ "Specify a User and Group for a specific child process."), -+AP_INIT_TAKE23("ServerEnvironment", cf_ServerEnvironment, NULL, RSRC_CONF, -+ "Specify the server environment for this virtual host."), -+{ NULL } -+}; -+ -+module AP_MODULE_DECLARE_DATA mpm_peruser_module = { -+ MPM20_MODULE_STUFF, -+ ap_mpm_rewrite_args, /* hook to run before apache parses args */ -+ NULL, /* create per-directory config structure */ -+ NULL, /* merge per-directory config structures */ -+ peruser_create_config, /* create per-server config structure */ -+ NULL, /* merge per-server config structures */ -+ peruser_cmds, /* command apr_table_t */ -+ peruser_hooks, /* register hooks */ -+}; diff --git a/www/apache22-peruser-mpm/pkg-descr b/www/apache22-peruser-mpm/pkg-descr deleted file mode 100644 index ab1f1a7..0000000 --- a/www/apache22-peruser-mpm/pkg-descr +++ /dev/null @@ -1,8 +0,0 @@ -Peruser is an Apache 2 modules based on metuxmpm. The fundamental -concept behind them is to run each apache child process as its own -user and group, each handling its own set of virtual hosts. Peruser -and recent metuxmpm releases can also chroot() apache processes. -The result is a sane and secure web server environment for your -users, without kludges like PHP's safe_mode. - -WWW: http://source.kood.ee/ diff --git a/www/apache22-worker-mpm/Makefile b/www/apache22-worker-mpm/Makefile deleted file mode 100644 index a18d743..0000000 --- a/www/apache22-worker-mpm/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD$ - -MASTERDIR= ${.CURDIR}/../apache22 - -MAINTAINER= apache@FreeBSD.org - -WITH_MPM= worker - -DESCR= ${.CURDIR}/pkg-descr - -PORT_OPTIONS+= CGID -OPTIONS_EXCLUDE= CGI - -.include "${MASTERDIR}/Makefile" diff --git a/www/apache22-worker-mpm/pkg-descr b/www/apache22-worker-mpm/pkg-descr deleted file mode 100644 index 9056131..0000000 --- a/www/apache22-worker-mpm/pkg-descr +++ /dev/null @@ -1,3 +0,0 @@ -Apache 2.2 with the worker MPM enabled. - -WWW: http://httpd.apache.org/ |