httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r760864 - in /httpd/httpd/trunk: include/ap_mpm.h include/mpm_common.h server/mpm/event/event.c server/mpm/prefork/prefork.c server/mpm/simple/simple_api.c server/mpm/winnt/mpm_winnt.c server/mpm/worker/worker.c server/mpm_common.c
Date Wed, 01 Apr 2009 11:53:51 GMT
Author: trawick
Date: Wed Apr  1 11:53:50 2009
New Revision: 760864

URL: http://svn.apache.org/viewvc?rev=760864&view=rev
Log:
mpm-query hook: distinguish between DECLINED and APR_ENOTIMPL so that
. ap_mpm_query() can return APR_EGENERAL if called too early (for debugging a module)
. some hypothetical module which implements the mpm-query hook can bypass the MPM
  with APR_ENOTIMPL

Modified:
    httpd/httpd/trunk/include/ap_mpm.h
    httpd/httpd/trunk/include/mpm_common.h
    httpd/httpd/trunk/server/mpm/event/event.c
    httpd/httpd/trunk/server/mpm/prefork/prefork.c
    httpd/httpd/trunk/server/mpm/simple/simple_api.c
    httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c
    httpd/httpd/trunk/server/mpm/worker/worker.c
    httpd/httpd/trunk/server/mpm_common.c

Modified: httpd/httpd/trunk/include/ap_mpm.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mpm.h?rev=760864&r1=760863&r2=760864&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mpm.h (original)
+++ httpd/httpd/trunk/include/ap_mpm.h Wed Apr  1 11:53:50 2009
@@ -147,10 +147,14 @@
 #define AP_MPMQ_HAS_SERF             16  /* MPM can drive serf internally  */
 
 /**
- * Query a property of the current MPM.  
+ * Query a property of the current MPM.
  * @param query_code One of APM_MPMQ_*
  * @param result A location to place the result of the query
- * @return APR_SUCCESS or APR_ENOTIMPL
+ * @return APR_EGENERAL if an mpm-query hook has not been registered;
+ * APR_SUCCESS or APR_ENOTIMPL otherwise
+ * @remark The MPM doesn't register the implementing hook until the
+ * register_hooks hook is called, so modules cannot use ap_mpm_query()
+ * until after that point.
  * @fn int ap_mpm_query(int query_code, int *result)
  */
 AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result);

Modified: httpd/httpd/trunk/include/mpm_common.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/mpm_common.h?rev=760864&r1=760863&r2=760864&view=diff
==============================================================================
--- httpd/httpd/trunk/include/mpm_common.h (original)
+++ httpd/httpd/trunk/include/mpm_common.h Wed Apr  1 11:53:50 2009
@@ -323,8 +323,11 @@
 /* pass control to the MPM */
 AP_DECLARE_HOOK(int, mpm, (apr_pool_t *pconf, apr_pool_t *plog, server_rec *s))
 
-/* implement the mpm query function */
-AP_DECLARE_HOOK(apr_status_t, mpm_query, (int query_code, int *result))
+/* implement the ap_mpm_query() function
+ * The MPM should return OK+APR_ENOTIMPL for any unimplemented query codes;
+ * modules which intercede for specific query codes should DECLINE for others.
+ */
+AP_DECLARE_HOOK(int, mpm_query, (int query_code, int *result, apr_status_t *rv))
 
 /* child specified by index has been killed */
 AP_DECLARE_HOOK(apr_status_t, mpm_note_child_killed, (int childnum))
@@ -333,7 +336,7 @@
 AP_DECLARE_HOOK(apr_status_t, mpm_register_timed_callback,
                 (apr_time_t t, ap_mpm_callback_fn_t *cbfn, void *baton))
 
-/* get MPM name */
+/* get MPM name (e.g., "prefork" or "event") */
 AP_DECLARE_HOOK(const char *,mpm_get_name,(void))
 
 #ifdef __cplusplus

Modified: httpd/httpd/trunk/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=760864&r1=760863&r2=760864&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/event/event.c Wed Apr  1 11:53:50 2009
@@ -349,59 +349,63 @@
     }
 }
 
-static apr_status_t event_query(int query_code, int *result)
+static int event_query(int query_code, int *result, apr_status_t *rv)
 {
+    *rv = APR_SUCCESS;
     switch (query_code) {
     case AP_MPMQ_MAX_DAEMON_USED:
         *result = max_daemons_limit;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_IS_THREADED:
         *result = AP_MPMQ_STATIC;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_IS_FORKED:
         *result = AP_MPMQ_DYNAMIC;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_IS_ASYNC:
         *result = 1;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_HAS_SERF:
         *result = 1;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_HARD_LIMIT_DAEMONS:
         *result = server_limit;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_HARD_LIMIT_THREADS:
         *result = thread_limit;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MAX_THREADS:
         *result = threads_per_child;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MIN_SPARE_DAEMONS:
         *result = 0;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MIN_SPARE_THREADS:
         *result = min_spare_threads;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MAX_SPARE_DAEMONS:
         *result = 0;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MAX_SPARE_THREADS:
         *result = max_spare_threads;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MAX_REQUESTS_DAEMON:
         *result = ap_max_requests_per_child;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MAX_DAEMONS:
         *result = ap_daemons_limit;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MPM_STATE:
         *result = mpm_state;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_GENERATION:
         *result = my_generation;
-        return APR_SUCCESS;
+        break;
+    default:
+        *rv = APR_ENOTIMPL;
+        break;
     }
-    return APR_ENOTIMPL;
+    return OK;
 }
 
 static apr_status_t event_note_child_killed(int childnum)

Modified: httpd/httpd/trunk/server/mpm/prefork/prefork.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/prefork/prefork.c?rev=760864&r1=760863&r2=760864&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/prefork/prefork.c (original)
+++ httpd/httpd/trunk/server/mpm/prefork/prefork.c Wed Apr  1 11:53:50 2009
@@ -242,53 +242,57 @@
 #define SAFE_ACCEPT(stmt) do {stmt;} while(0)
 #endif
 
-static apr_status_t prefork_query(int query_code, int *result)
+static int prefork_query(int query_code, int *result, apr_status_t *rv)
 {
+    *rv = APR_SUCCESS;
     switch(query_code){
     case AP_MPMQ_MAX_DAEMON_USED:
         *result = ap_daemons_limit;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_IS_THREADED:
         *result = AP_MPMQ_NOT_SUPPORTED;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_IS_FORKED:
         *result = AP_MPMQ_DYNAMIC;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_HARD_LIMIT_DAEMONS:
         *result = server_limit;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_HARD_LIMIT_THREADS:
         *result = HARD_THREAD_LIMIT;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MAX_THREADS:
         *result = 0;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MIN_SPARE_DAEMONS:
         *result = ap_daemons_min_free;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MIN_SPARE_THREADS:
         *result = 0;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MAX_SPARE_DAEMONS:
         *result = ap_daemons_max_free;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MAX_SPARE_THREADS:
         *result = 0;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MAX_REQUESTS_DAEMON:
         *result = ap_max_requests_per_child;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MAX_DAEMONS:
         *result = server_limit;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_MPM_STATE:
         *result = mpm_state;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_GENERATION:
         *result = my_generation;
-        return APR_SUCCESS;
+        break;
+    default:
+        *rv = APR_ENOTIMPL;
+        break;
     }
-    return APR_ENOTIMPL;
+    return OK;
 }
 
 static apr_status_t prefork_note_child_killed(int childnum)

Modified: httpd/httpd/trunk/server/mpm/simple/simple_api.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/simple/simple_api.c?rev=760864&r1=760863&r2=760864&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/simple/simple_api.c (original)
+++ httpd/httpd/trunk/server/mpm/simple/simple_api.c Wed Apr  1 11:53:50 2009
@@ -41,71 +41,60 @@
     return simple_main_loop(sc);
 }
 
-static apr_status_t simple_query(int query_code, int *result)
+static int simple_query(int query_code, int *result, apr_status_t *rv)
 {
     simple_core_t *sc = simple_core_get();
 
+    *rv = APR_SUCCESS;
     switch (query_code) {
     case AP_MPMQ_IS_THREADED:
         *result = AP_MPMQ_STATIC;
-        return APR_SUCCESS;
         break;
     case AP_MPMQ_IS_FORKED:
         *result = AP_MPMQ_DYNAMIC;
-        return APR_SUCCESS;
         break;
     case AP_MPMQ_IS_ASYNC:
         *result = 1;
-        return APR_SUCCESS;
         break;
     case AP_MPMQ_MAX_DAEMON_USED:
         *result = sc->procmgr.proc_count;
-        return APR_SUCCESS;
         break;
     case AP_MPMQ_HARD_LIMIT_DAEMONS:
         *result = sc->procmgr.proc_count;
-        return APR_SUCCESS;
         break;
     case AP_MPMQ_HARD_LIMIT_THREADS:
         *result = sc->procmgr.thread_count;
-        return APR_SUCCESS;
         break;
     case AP_MPMQ_MAX_THREADS:
         *result = sc->procmgr.thread_count;
-        return APR_SUCCESS;
         break;
     case AP_MPMQ_MAX_SPARE_DAEMONS:
         *result = sc->procmgr.proc_count;
-        return APR_SUCCESS;
         break;
     case AP_MPMQ_MIN_SPARE_DAEMONS:
         *result = sc->procmgr.proc_count;
-        return APR_SUCCESS;
         break;
     case AP_MPMQ_MIN_SPARE_THREADS:
     case AP_MPMQ_MAX_SPARE_THREADS:
         *result = sc->procmgr.thread_count;
-        return APR_SUCCESS;
         break;
     case AP_MPMQ_MAX_REQUESTS_DAEMON:
         *result = sc->procmgr.max_requests_per_child;
-        return APR_SUCCESS;
         break;
     case AP_MPMQ_MAX_DAEMONS:
         *result = sc->procmgr.proc_count;
-        return APR_SUCCESS;
         break;
     case AP_MPMQ_MPM_STATE:
         *result = sc->mpm_state;
-        return APR_SUCCESS;
+        break;
     case AP_MPMQ_GENERATION:
         *result = 0;
-        return APR_SUCCESS;
+        break;
     default:
+        *rv = APR_ENOTIMPL;
         break;
     }
-
-    return APR_ENOTIMPL;
+    return OK;
 }
 
 static const char *

Modified: httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c?rev=760864&r1=760863&r2=760864&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c (original)
+++ httpd/httpd/trunk/server/mpm/winnt/mpm_winnt.c Wed Apr  1 11:53:50 2009
@@ -893,53 +893,57 @@
  * service after we preflight the config.
  */
 
-static apr_status_t winnt_query(int query_code, int *result)
+static int winnt_query(int query_code, int *result, apr_status_t *rv)
 {
-    switch(query_code){
+    *rv = APR_SUCCESS;
+    switch (query_code) {
         case AP_MPMQ_MAX_DAEMON_USED:
             *result = MAXIMUM_WAIT_OBJECTS;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_IS_THREADED:
             *result = AP_MPMQ_STATIC;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_IS_FORKED:
             *result = AP_MPMQ_NOT_SUPPORTED;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_HARD_LIMIT_DAEMONS:
             *result = HARD_SERVER_LIMIT;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_HARD_LIMIT_THREADS:
             *result = thread_limit;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MAX_THREADS:
             *result = ap_threads_per_child;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MIN_SPARE_DAEMONS:
             *result = 0;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MIN_SPARE_THREADS:
             *result = 0;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MAX_SPARE_DAEMONS:
             *result = 0;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MAX_SPARE_THREADS:
             *result = 0;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MAX_REQUESTS_DAEMON:
             *result = ap_max_requests_per_child;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MAX_DAEMONS:
             *result = 0;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MPM_STATE:
             *result = winnt_mpm_state;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_GENERATION:
             *result = my_generation;
-            return APR_SUCCESS;
+            break;
+        default:
+            *rv = APR_ENOTIMPL;
+            break;
     }
-    return APR_ENOTIMPL;
+    return OK;
 }
 
 static const char *winnt_get_name(void)

Modified: httpd/httpd/trunk/server/mpm/worker/worker.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/worker/worker.c?rev=760864&r1=760863&r2=760864&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/worker/worker.c (original)
+++ httpd/httpd/trunk/server/mpm/worker/worker.c Wed Apr  1 11:53:50 2009
@@ -305,53 +305,57 @@
     }
 }
 
-static apr_status_t worker_query(int query_code, int *result)
+static int worker_query(int query_code, int *result, apr_status_t *rv)
 {
-    switch(query_code){
+    *rv = APR_SUCCESS;
+    switch (query_code) {
         case AP_MPMQ_MAX_DAEMON_USED:
             *result = max_daemons_limit;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_IS_THREADED:
             *result = AP_MPMQ_STATIC;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_IS_FORKED:
             *result = AP_MPMQ_DYNAMIC;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_HARD_LIMIT_DAEMONS:
             *result = server_limit;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_HARD_LIMIT_THREADS:
             *result = thread_limit;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MAX_THREADS:
             *result = threads_per_child;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MIN_SPARE_DAEMONS:
             *result = 0;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MIN_SPARE_THREADS:
             *result = min_spare_threads;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MAX_SPARE_DAEMONS:
             *result = 0;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MAX_SPARE_THREADS:
             *result = max_spare_threads;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MAX_REQUESTS_DAEMON:
             *result = ap_max_requests_per_child;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MAX_DAEMONS:
             *result = ap_daemons_limit;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_MPM_STATE:
             *result = mpm_state;
-            return APR_SUCCESS;
+            break;
         case AP_MPMQ_GENERATION:
             *result = my_generation;
-            return APR_SUCCESS;
+            break;
+        default:
+            *rv = APR_ENOTIMPL;
+            break;
     }
-    return APR_ENOTIMPL;
+    return OK;
 }
 
 static apr_status_t worker_note_child_killed(int childnum)

Modified: httpd/httpd/trunk/server/mpm_common.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm_common.c?rev=760864&r1=760863&r2=760864&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm_common.c (original)
+++ httpd/httpd/trunk/server/mpm_common.c Wed Apr  1 11:53:50 2009
@@ -88,9 +88,9 @@
 AP_IMPLEMENT_HOOK_RUN_FIRST(int, mpm,
                             (apr_pool_t *pconf, apr_pool_t *plog, server_rec *s),
                             (pconf, plog, s), DECLINED)
-AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t, mpm_query,
-                            (int query_code, int *result),
-                            (query_code, result), APR_ENOTIMPL)
+AP_IMPLEMENT_HOOK_RUN_FIRST(int, mpm_query,
+                            (int query_code, int *result, apr_status_t *_rv),
+                            (query_code, result, _rv), DECLINED)
 AP_IMPLEMENT_HOOK_RUN_FIRST(apr_status_t, mpm_note_child_killed,
                             (int childnum),
                             (childnum), APR_ENOTIMPL)
@@ -405,7 +405,13 @@
 
 AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result)
 {
-    return ap_run_mpm_query(query_code, result);
+    apr_status_t rv;
+
+    if (ap_run_mpm_query(query_code, result, &rv) == DECLINED) {
+        rv = APR_EGENERAL;
+    }
+
+    return rv;
 }
 
 AP_DECLARE(apr_status_t) ap_mpm_note_child_killed(int childnum)



Mime
View raw message