From: Jeff Trawick Date: Fri, 17 Apr 2009 16:59:48 +0000 (+0000) Subject: Move logic to decide if an MPM is supported, and whether the MPM is X-Git-Tag: 2.3.3~717 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=413ce35a0e8443dcd3deaeae3f798a451f7739f1;p=thirdparty%2Fapache%2Fhttpd.git Move logic to decide if an MPM is supported, and whether the MPM is threaded, down to the MPM itself. (server/mpm/FOO/config.m4, which runs before the actual MPM selection) server/mpm/config.m4 makes some general platform checks that can be used for MPM decisions, and contains some functions related to MPMs. XXX The check here for whether APR_POLLSET_THREADSAFE is available is a rough approximation and needs to be replaced by a run-time check. Replace the limited per-platform hard-coded MPM selection and the current defaulting to event (whether or not it works) with a selection based on which MPMs work on the platform, as reported by the MPMs themselves. (config2.m4, which runs after the MPMs record whether they are supported) Order of preference: WinNT (mingw32 only) then Event then Worker then Prefork git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@766082 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/configure.in b/configure.in index 3b180d26c7d..b93773bc24f 100644 --- a/configure.in +++ b/configure.in @@ -252,7 +252,6 @@ echo $ac_n "${nl}Applying OS-specific hints for httpd ...${nl}" case $host in *-apple-aux3*) - APR_SETVAR(APACHE_MPM, [prefork]) APR_SETVAR(SINGLE_LISTEN_UNSERIALIZED_ACCEPT, [1]) ;; *-linux-*) @@ -281,11 +280,9 @@ case $host in esac ;; *cygwin*) - APR_SETVAR(APACHE_MPM, [prefork]) APR_SETVAR(SINGLE_LISTEN_UNSERIALIZED_ACCEPT, [1]) ;; *mingw32*) - APR_SETVAR(APACHE_MPM, [winnt]) APR_ADDTO(CPPFLAGS, [-DAP_DECLARE_EXPORT]) APR_SETIFNULL(ac_cv_func_times, [no]) APR_SETIFNULL(ac_cv_func_getpwnam, [no]) diff --git a/server/mpm/config.m4 b/server/mpm/config.m4 index fd58b009b9a..4c4f0b3fefd 100644 --- a/server/mpm/config.m4 +++ b/server/mpm/config.m4 @@ -1,70 +1,78 @@ -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={simple|event|worker|prefork|winnt} - Specify "shared" instead of an MPM name to load MPMs dynamically. -),[ - APACHE_MPM=$withval -],[ - if test "x$APACHE_MPM" = "x"; then - APACHE_MPM=event - fi -]) -AC_MSG_RESULT($APACHE_MPM) +dnl common platform checks needed by MPMs, methods for MPMs to state +dnl their support for the platform, functions to query MPM properties -apache_cv_mpm=$APACHE_MPM +APR_CHECK_APR_DEFINE(APR_HAS_THREADS) -dnl Note that a build with an explicitly loaded MPM must support threaded MPMs. -ap_mpm_is_threaded () -{ - if test "$apache_cv_mpm" = "shared" -o "$apache_cv_mpm" = "worker" -o "$apache_cv_mpm" = "event" -o "$apache_cv_mpm" = "simple" -o "$apache_cv_mpm" = "winnt" ; then - return 0 - else - return 1 - fi -} - -if ap_mpm_is_threaded; then - APR_CHECK_APR_DEFINE(APR_HAS_THREADS) - - if test "x$ac_cv_define_APR_HAS_THREADS" = "xno"; then - AC_MSG_RESULT(The currently selected MPM requires threads which your system seems to lack) - AC_MSG_CHECKING(checking for replacement) - AC_MSG_RESULT(prefork selected) - apache_cv_mpm=prefork - else - case $host in - *-linux-*) +have_threaded_sig_graceful=yes +case $host in + *-linux-*) case `uname -r` in 2.0* ) dnl Threaded MPM's are not supported on Linux 2.0 dnl as on 2.0 the linuxthreads library uses SIGUSR1 dnl and SIGUSR2 internally - echo "Threaded MPM's are not supported on this platform" - AC_MSG_CHECKING(checking for replacement) - AC_MSG_RESULT(prefork selected) - apache_cv_mpm=prefork + have_threaded_sig_graceful=no ;; esac - ;; - esac - fi + ;; +esac + +dnl See if APR supports APR_POLLSET_THREADSAFE. +dnl XXX This hack tests for the underlying functions used by APR when it +dnl XXX supports APR_POLLSET_THREADSAFE. +dnl FIXME with a run-time check for +dnl apr_pollset_create(,,APR_POLLSET_THREADSAFE) == APR_SUCCESS +AC_CHECK_FUNCS(kqueue port_create epoll_create) +if test "$ac_cv_func_kqueue$ac_cv_func_port_create$ac_cv_func_epoll_create" != "nonono"; then + have_threadsafe_pollset=yes +else + have_threadsafe_pollset=no fi -APACHE_FAST_OUTPUT(server/mpm/Makefile) +dnl See if this is a forking platform w.r.t. MPMs +case $host in + *mingw32*) + forking_mpms_supported=no + ;; + *) + forking_mpms_supported=yes + ;; +esac -if test "$apache_cv_mpm" = "shared"; then - MPM_NAME="" - MPM_SUBDIR_NAME="" - MPM_LIB="" -else - MPM_NAME=$apache_cv_mpm - MPM_SUBDIR_NAME=$MPM_NAME - MPM_LIB=server/mpm/$MPM_SUBDIR_NAME/lib${MPM_NAME}.la +dnl APACHE_MPM_SUPPORTED(name, supports-shared, is_threaded) +AC_DEFUN(APACHE_MPM_SUPPORTED,[ + SUPPORTED_MPMS="$SUPPORTED_MPMS $1 " + if test "$3" = "yes"; then + THREADED_MPMS="$THREADED_MPMS $1" + fi +])dnl - MODLIST="$MODLIST mpm_${MPM_NAME}" -fi +dnl APACHE_MPM_ENABLED(name) +AC_DEFUN(APACHE_MPM_ENABLED,[ + ENABLED_MPMS="$ENABLED_MPMS $1 " +])dnl -APACHE_SUBST(MPM_NAME) -APACHE_SUBST(MPM_SUBDIR_NAME) -APACHE_SUBST(MPM_LIB) +ap_mpm_is_supported () +{ + if echo "$SUPPORTED_MPMS" | grep " $1 " >/dev/null; then + return 0 + else + return 1 + fi +} + +ap_mpm_is_threaded () +{ + dnl Special support for --with-mpm=shared + dnl Assume a threaded MPM can be used. + if test "x$MPM_NAME" = "xshared"; then + return 0 + fi + + for mpm in $ENABLED_MPMS; do + if echo "$THREADED_MPMS" | grep " $mpm " >/dev/null; then + return 0 + fi + done + return 1 +} diff --git a/server/mpm/config2.m4 b/server/mpm/config2.m4 new file mode 100644 index 00000000000..798edf9b23b --- /dev/null +++ b/server/mpm/config2.m4 @@ -0,0 +1,55 @@ +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={simple|event|worker|prefork|winnt} + Specify "shared" instead of an MPM name to load MPMs dynamically. +),[ + APACHE_MPM=$withval + AC_MSG_RESULT($withval); +],[ + dnl Order of preference for default MPM: + dnl Windows: WinNT + dnl Everywhere else: event, worker, prefork + if ap_mpm_is_supported "winnt"; then + APACHE_MPM=winnt + AC_MSG_RESULT(winnt) + elif ap_mpm_is_supported "event"; then + APACHE_MPM=event + AC_MSG_RESULT(event) + elif ap_mpm_is_supported "worker"; then + APACHE_MPM=worker + AC_MSG_RESULT(worker - event is not supported) + else + APACHE_MPM=prefork + AC_MSG_RESULT(prefork - event and worker are not supported) + fi +]) + +if test $APACHE_MPM = "shared"; then + : +elif ap_mpm_is_supported $APACHE_MPM; then + : +else + AC_MSG_ERROR([The specified MPM, $APACHE_MPM, is not supported on this platform.]) +fi + +apache_cv_mpm=$APACHE_MPM +APACHE_MPM_ENABLED($APACHE_MPM) + +APACHE_FAST_OUTPUT(server/mpm/Makefile) + +if test "$apache_cv_mpm" = "shared"; then + MPM_NAME="" + MPM_SUBDIR_NAME="" + MPM_LIB="" +else + MPM_NAME=$apache_cv_mpm + MPM_SUBDIR_NAME=$MPM_NAME + MPM_LIB=server/mpm/$MPM_SUBDIR_NAME/lib${MPM_NAME}.la + + MODLIST="$MODLIST mpm_${MPM_NAME}" +fi + +APACHE_SUBST(MPM_NAME) +APACHE_SUBST(MPM_SUBDIR_NAME) +APACHE_SUBST(MPM_LIB) diff --git a/server/mpm/event/config.m4 b/server/mpm/event/config.m4 new file mode 100644 index 00000000000..4b7888e1afb --- /dev/null +++ b/server/mpm/event/config.m4 @@ -0,0 +1,13 @@ +AC_MSG_CHECKING(if event MPM supports this platform) +if test $forking_mpms_supported != yes; then + AC_MSG_RESULT(no - This is not a forking platform) +elif test $ac_cv_define_APR_HAS_THREADS != yes; then + AC_MSG_RESULT(no - APR does not support threads) +elif test $have_threaded_sig_graceful != yes; then + AC_MSG_RESULT(no - SIG_GRACEFUL cannot be used with a threaded MPM) +elif test $have_threadsafe_pollset != yes; then + AC_MSG_RESULT(no - APR_POLLSET_THREADSAFE is not supported) +else + AC_MSG_RESULT(yes) + APACHE_MPM_SUPPORTED(event, yes, yes) +fi diff --git a/server/mpm/prefork/config.m4 b/server/mpm/prefork/config.m4 index 9c189a86429..296f834a694 100644 --- a/server/mpm/prefork/config.m4 +++ b/server/mpm/prefork/config.m4 @@ -1,3 +1,7 @@ -if test "$MPM_NAME" = "prefork" ; then - APACHE_FAST_OUTPUT(server/mpm/$MPM_NAME/Makefile) +AC_MSG_CHECKING(if prefork MPM supports this platform) +if test $forking_mpms_supported != yes; then + AC_MSG_RESULT(no - This is not a forking platform) +else + AC_MSG_RESULT(yes) + APACHE_MPM_SUPPORTED(prefork, yes, no) fi diff --git a/server/mpm/prefork/config3.m4 b/server/mpm/prefork/config3.m4 new file mode 100644 index 00000000000..9c189a86429 --- /dev/null +++ b/server/mpm/prefork/config3.m4 @@ -0,0 +1,3 @@ +if test "$MPM_NAME" = "prefork" ; then + APACHE_FAST_OUTPUT(server/mpm/$MPM_NAME/Makefile) +fi diff --git a/server/mpm/simple/config.m4 b/server/mpm/simple/config.m4 index 4b027a7c639..caeda79f0a8 100644 --- a/server/mpm/simple/config.m4 +++ b/server/mpm/simple/config.m4 @@ -1,3 +1,13 @@ -if test "$MPM_NAME" = "simple" ; then - APACHE_FAST_OUTPUT(server/mpm/$MPM_NAME/Makefile) +AC_MSG_CHECKING(if simple MPM supports this platform) +if test $forking_mpms_supported != yes; then + AC_MSG_RESULT(no - This is not a forking platform) +elif test $ac_cv_define_APR_HAS_THREADS != yes; then + AC_MSG_RESULT(no - APR does not support threads) +elif test $have_threaded_sig_graceful != yes; then + AC_MSG_RESULT(no - SIG_GRACEFUL cannot be used with a threaded MPM) +elif test $have_threadsafe_pollset != yes; then + AC_MSG_RESULT(no - APR_POLLSET_THREADSAFE is not supported) +else + AC_MSG_RESULT(yes) + APACHE_MPM_SUPPORTED(simple, yes, yes) fi diff --git a/server/mpm/simple/config3.m4 b/server/mpm/simple/config3.m4 new file mode 100644 index 00000000000..4b027a7c639 --- /dev/null +++ b/server/mpm/simple/config3.m4 @@ -0,0 +1,3 @@ +if test "$MPM_NAME" = "simple" ; then + APACHE_FAST_OUTPUT(server/mpm/$MPM_NAME/Makefile) +fi diff --git a/server/mpm/winnt/config.m4 b/server/mpm/winnt/config.m4 index 181322b0bba..5c1fd42d04b 100644 --- a/server/mpm/winnt/config.m4 +++ b/server/mpm/winnt/config.m4 @@ -1,3 +1,10 @@ -if test "$MPM_NAME" = "winnt" ; then - APACHE_FAST_OUTPUT(server/mpm/$MPM_NAME/Makefile) -fi +AC_MSG_CHECKING(if WinNT MPM supports this platform) +case $host in + *mingw32*) + AC_MSG_RESULT(yes) + APACHE_MPM_SUPPORTED(winnt, no, yes) + ;; + *) + AC_MSG_RESULT(no) + ;; +esac diff --git a/server/mpm/winnt/config3.m4 b/server/mpm/winnt/config3.m4 new file mode 100644 index 00000000000..181322b0bba --- /dev/null +++ b/server/mpm/winnt/config3.m4 @@ -0,0 +1,3 @@ +if test "$MPM_NAME" = "winnt" ; then + APACHE_FAST_OUTPUT(server/mpm/$MPM_NAME/Makefile) +fi diff --git a/server/mpm/worker/config.m4 b/server/mpm/worker/config.m4 new file mode 100644 index 00000000000..1a500264d12 --- /dev/null +++ b/server/mpm/worker/config.m4 @@ -0,0 +1,11 @@ +AC_MSG_CHECKING(if worker MPM supports this platform) +if test $forking_mpms_supported != yes; then + AC_MSG_RESULT(no - This is not a forking platform) +elif test $ac_cv_define_APR_HAS_THREADS != yes; then + AC_MSG_RESULT(no - APR does not support threads) +elif test $have_threaded_sig_graceful != yes; then + AC_MSG_RESULT(no - SIG_GRACEFUL cannot be used with a threaded MPM) +else + AC_MSG_RESULT(yes) + APACHE_MPM_SUPPORTED(worker, yes, yes) +fi