You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2009/04/17 18:59:48 UTC

svn commit: r766082 - in /httpd/httpd/trunk: ./ server/mpm/ server/mpm/event/ server/mpm/prefork/ server/mpm/simple/ server/mpm/winnt/ server/mpm/worker/

Author: trawick
Date: Fri Apr 17 16:59:48 2009
New Revision: 766082

URL: http://svn.apache.org/viewvc?rev=766082&view=rev
Log:
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


Added:
    httpd/httpd/trunk/server/mpm/config2.m4
    httpd/httpd/trunk/server/mpm/event/config.m4
    httpd/httpd/trunk/server/mpm/prefork/config3.m4
    httpd/httpd/trunk/server/mpm/simple/config3.m4
    httpd/httpd/trunk/server/mpm/winnt/config3.m4
    httpd/httpd/trunk/server/mpm/worker/config.m4
Modified:
    httpd/httpd/trunk/configure.in
    httpd/httpd/trunk/server/mpm/config.m4
    httpd/httpd/trunk/server/mpm/prefork/config.m4
    httpd/httpd/trunk/server/mpm/simple/config.m4
    httpd/httpd/trunk/server/mpm/winnt/config.m4

Modified: httpd/httpd/trunk/configure.in
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/configure.in?rev=766082&r1=766081&r2=766082&view=diff
==============================================================================
--- httpd/httpd/trunk/configure.in (original)
+++ httpd/httpd/trunk/configure.in Fri Apr 17 16:59:48 2009
@@ -252,7 +252,6 @@
 
 case $host in
   *-apple-aux3*)
-      APR_SETVAR(APACHE_MPM, [prefork])
       APR_SETVAR(SINGLE_LISTEN_UNSERIALIZED_ACCEPT, [1])
       ;;
   *-linux-*)
@@ -281,11 +280,9 @@
       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])

Modified: httpd/httpd/trunk/server/mpm/config.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/config.m4?rev=766082&r1=766081&r2=766082&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/config.m4 (original)
+++ httpd/httpd/trunk/server/mpm/config.m4 Fri Apr 17 16:59:48 2009
@@ -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
+
+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
 
-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_ENABLED(name)
+AC_DEFUN(APACHE_MPM_ENABLED,[
+    ENABLED_MPMS="$ENABLED_MPMS $1 "
+])dnl
 
-  MODLIST="$MODLIST mpm_${MPM_NAME}"
-fi
+ap_mpm_is_supported ()
+{
+    if echo "$SUPPORTED_MPMS" | grep " $1 " >/dev/null; then
+        return 0
+    else
+        return 1
+    fi
+}
 
-APACHE_SUBST(MPM_NAME)
-APACHE_SUBST(MPM_SUBDIR_NAME)
-APACHE_SUBST(MPM_LIB)
+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
+}

Added: httpd/httpd/trunk/server/mpm/config2.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/config2.m4?rev=766082&view=auto
==============================================================================
--- httpd/httpd/trunk/server/mpm/config2.m4 (added)
+++ httpd/httpd/trunk/server/mpm/config2.m4 Fri Apr 17 16:59:48 2009
@@ -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)

Added: httpd/httpd/trunk/server/mpm/event/config.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/config.m4?rev=766082&view=auto
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/config.m4 (added)
+++ httpd/httpd/trunk/server/mpm/event/config.m4 Fri Apr 17 16:59:48 2009
@@ -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

Modified: httpd/httpd/trunk/server/mpm/prefork/config.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/prefork/config.m4?rev=766082&r1=766081&r2=766082&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/prefork/config.m4 (original)
+++ httpd/httpd/trunk/server/mpm/prefork/config.m4 Fri Apr 17 16:59:48 2009
@@ -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

Added: httpd/httpd/trunk/server/mpm/prefork/config3.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/prefork/config3.m4?rev=766082&view=auto
==============================================================================
--- httpd/httpd/trunk/server/mpm/prefork/config3.m4 (added)
+++ httpd/httpd/trunk/server/mpm/prefork/config3.m4 Fri Apr 17 16:59:48 2009
@@ -0,0 +1,3 @@
+if test "$MPM_NAME" = "prefork" ; then
+    APACHE_FAST_OUTPUT(server/mpm/$MPM_NAME/Makefile)
+fi

Modified: httpd/httpd/trunk/server/mpm/simple/config.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/simple/config.m4?rev=766082&r1=766081&r2=766082&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/simple/config.m4 (original)
+++ httpd/httpd/trunk/server/mpm/simple/config.m4 Fri Apr 17 16:59:48 2009
@@ -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

Added: httpd/httpd/trunk/server/mpm/simple/config3.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/simple/config3.m4?rev=766082&view=auto
==============================================================================
--- httpd/httpd/trunk/server/mpm/simple/config3.m4 (added)
+++ httpd/httpd/trunk/server/mpm/simple/config3.m4 Fri Apr 17 16:59:48 2009
@@ -0,0 +1,3 @@
+if test "$MPM_NAME" = "simple" ; then
+    APACHE_FAST_OUTPUT(server/mpm/$MPM_NAME/Makefile)
+fi

Modified: httpd/httpd/trunk/server/mpm/winnt/config.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/winnt/config.m4?rev=766082&r1=766081&r2=766082&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/winnt/config.m4 (original)
+++ httpd/httpd/trunk/server/mpm/winnt/config.m4 Fri Apr 17 16:59:48 2009
@@ -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

Added: httpd/httpd/trunk/server/mpm/winnt/config3.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/winnt/config3.m4?rev=766082&view=auto
==============================================================================
--- httpd/httpd/trunk/server/mpm/winnt/config3.m4 (added)
+++ httpd/httpd/trunk/server/mpm/winnt/config3.m4 Fri Apr 17 16:59:48 2009
@@ -0,0 +1,3 @@
+if test "$MPM_NAME" = "winnt" ; then
+    APACHE_FAST_OUTPUT(server/mpm/$MPM_NAME/Makefile)
+fi

Added: httpd/httpd/trunk/server/mpm/worker/config.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/worker/config.m4?rev=766082&view=auto
==============================================================================
--- httpd/httpd/trunk/server/mpm/worker/config.m4 (added)
+++ httpd/httpd/trunk/server/mpm/worker/config.m4 Fri Apr 17 16:59:48 2009
@@ -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