]> granicus.if.org Git - apache/commitdiff
Move the "GracefulShutdownTimeout" directive into mpm_common, for re-use
authorColm MacCarthaigh <colm@apache.org>
Fri, 26 Aug 2005 17:43:24 +0000 (17:43 +0000)
committerColm MacCarthaigh <colm@apache.org>
Fri, 26 Aug 2005 17:43:24 +0000 (17:43 +0000)
with other MPM's.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@240296 13f79535-47bb-0310-9956-ffa450edef68

include/mpm_common.h
server/main.c
server/mpm/prefork/mpm.h
server/mpm/prefork/prefork.c
server/mpm_common.c

index 478810d0522892adf733029ffd629256e8456e0e..91fd0bd4c70cc0146bb1511cf9e1c2b555da4750 100644 (file)
@@ -287,6 +287,16 @@ const char *ap_mpm_set_coredumpdir(cmd_parms *cmd, void *dummy,
                                    const char *arg);
 #endif
 
+/**
+ * Set the timeout period for a graceful shutdown.
+ */
+#ifdef AP_MPM_WANT_SET_GRACEFUL_SHUTDOWN
+extern int ap_graceful_shutdown_timeout;
+const char *ap_mpm_set_graceful_shutdown(cmd_parms *cmd, void *dummy,
+                                         const char *arg);
+#endif
+
+
 #ifdef AP_MPM_WANT_SIGNAL_SERVER
 int ap_signal_server(int *, apr_pool_t *);
 void ap_mpm_rewrite_args(process_rec *);
index c73a315d29c854a41ba31c52ad632e425763c14d..980858192151bc527ab565aa9fca7eca03cfb3c6 100644 (file)
@@ -318,7 +318,7 @@ static void usage(process_rec *process)
                  pad);
 #endif
 #ifdef AP_MPM_WANT_SIGNAL_SERVER
-#ifdef AP_MPM_SUPPORTS_GRACEFUL_STOP
+#ifdef AP_MPM_WANT_SET_GRACEFUL_SHUTDOWN
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
                  "       %s [-k start|restart|graceful|graceful-stop|stop]",
                  pad);
@@ -326,7 +326,7 @@ static void usage(process_rec *process)
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
                  "       %s [-k start|restart|graceful|stop]",
                  pad);
-#endif /* AP_MPM_SUPPORTS_GRACEFUL_STOP */
+#endif /* AP_MPM_WANT_SET_GRACEFUL_SHUTDOWN */
 #endif
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
                  "       %s [-v] [-V] [-h] [-l] [-L] [-t] [-S]", pad);
index b9ab6ebc56e49ae01be01018d678d11ce68ea8e1..cead8b96835269c192f51c2b61c10ab6039c2328 100644 (file)
@@ -38,8 +38,8 @@
 #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_SUPPORTS_GRACEFUL_STOP
 
 #define AP_MPM_USES_POD 1
 #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
index 66067ab822860b6469962a5be8f66505031dc9be..94d15497aa1a27e1f69ce500d51a1bee4067127a 100644 (file)
@@ -96,7 +96,6 @@ 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 graceful_shutdown_timeout = 0;
 static int server_limit = DEFAULT_SERVER_LIMIT;
 static int first_server_limit;
 static int changed_limit_at_restart;
@@ -1122,7 +1121,7 @@ int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
         int status;
         int child_slot;
         apr_proc_t pid;
-        apr_time_t cutoff;
+        apr_time_t cutoff = 0;
 
         /* Stop listening */
         ap_close_listeners();
@@ -1168,9 +1167,9 @@ int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
         ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
            "caught " AP_SIG_GRACEFUL_STOP_STRING ", shutting down gracefully");
 
-        if (graceful_shutdown_timeout) {
+        if (ap_graceful_shutdown_timeout) {
             cutoff = apr_time_now() + 
-                     apr_time_from_sec(graceful_shutdown_timeout);
+                     apr_time_from_sec(ap_graceful_shutdown_timeout);
         }
 
         /* Don't really exit until each child has finished */
@@ -1198,7 +1197,7 @@ int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
                 }
             }
         } while (!shutdown_pending && active_children &&
-                 (!graceful_shutdown_timeout || apr_time_now() < cutoff));
+                 (!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
@@ -1473,16 +1472,6 @@ static const char *set_server_limit (cmd_parms *cmd, void *dummy, const char *ar
     return NULL;
 }
 
-static const char *set_graceful_shutdown(cmd_parms *cmd, void *dummy, const char *arg) 
-{
-    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
-    if (err != NULL) {
-        return err;
-    }
-    graceful_shutdown_timeout = atoi(arg);
-    return NULL;
-}
-
 static const command_rec prefork_cmds[] = {
 UNIX_DAEMON_COMMANDS,
 LISTEN_COMMANDS,
@@ -1496,9 +1485,9 @@ 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_TAKE1("GracefulShutdownTimeout", set_graceful_shutdown, NULL, RSRC_CONF,
-              "Time in seconds to wait for child processes to complete " 
-              "transactions during shutdown"),
+AP_INIT_TAKE1("GracefulShutdownTimeout", ap_mpm_set_graceful_shutdown, NULL, 
+              RSRC_CONF, "Time in seconds to wait for child processes to " 
+              "complete transactions during shutdown"),
 { NULL }
 };
 
index e8a8cb44a4f1f77c1924978c3e0116c6fc637012..52aebd478a8b3ccd87f55cd95886428f50c11749 100644 (file)
@@ -760,6 +760,21 @@ const char *ap_mpm_set_coredumpdir(cmd_parms *cmd, void *dummy,
 }
 #endif
 
+#ifdef AP_MPM_WANT_SET_GRACEFUL_SHUTDOWN
+int ap_graceful_shutdown_timeout = 0;
+
+const char * ap_mpm_set_graceful_shutdown(cmd_parms *cmd, void *dummy,
+                                          const char *arg)
+{
+    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+    if (err != NULL) {
+        return err;
+    }
+    ap_graceful_shutdown_timeout = atoi(arg);
+    return NULL;
+}
+#endif
+
 #ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH
 apr_lockmech_e ap_accept_lock_mech = APR_LOCK_DEFAULT;
 
@@ -923,7 +938,7 @@ int ap_signal_server(int *exit_status, apr_pool_t *pconf)
     }
     
     if (!strcmp(dash_k_arg, "graceful-stop")) {
-#ifdef AP_MPM_SUPPORTS_GRACEFUL_STOP
+#ifdef AP_MPM_WANT_SET_GRACEFUL_SHUTDOWN
         if (!running) {
             printf("%s\n", status);
         }