]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Fix MaxClients in the Worker MPM, so that it specifies the maximum
authorRyan Bloom <rbb@apache.org>
Mon, 24 Sep 2001 06:42:12 +0000 (06:42 +0000)
committerRyan Bloom <rbb@apache.org>
Mon, 24 Sep 2001 06:42:12 +0000 (06:42 +0000)
number of clients that can connect at the same time, instead of
specifying the maximum number of child processes.
Submitted by: Aaron Bannert <aaron@clove.org>

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

CHANGES
server/mpm/worker/worker.c

diff --git a/CHANGES b/CHANGES
index 538fcece0ddae98663ce7bd5042a28d89bb5cfdf..43e10c34e3705ce514368084b4bb4d2e85fd3324 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,10 @@
 Changes with Apache 2.0.26-dev
 
+  *) Fix MaxClients in the Worker MPM, so that it specifies the maximum
+     number of clients that can connect at the same time, instead of
+     specifying the maximum number of child processes.
+     [Aaron Bannert <aaron@clove.org>]
+
   *) Switch proc_pthread AcceptMutex configuration directive to pthread to 
      be consistent with 1.3.  [Justin Erenkrantz]
 
index e2acea5e7e3e7a5e0fffb83b786ac40b3baf34d3..2cd810d5d8d68804bf9907d0a095b013a3118635 100644 (file)
@@ -1422,6 +1422,44 @@ static void worker_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *p
 {
     static int restart_num = 0;
     int no_detach, debug;
+    ap_directive_t *pdir;
+    ap_directive_t *max_clients = NULL;
+
+    /* make sure that "ThreadsPerChild" gets set before "MaxClients" */
+    for (pdir = ap_conftree; pdir != NULL; pdir = pdir->next) {
+        if (strncasecmp(pdir->directive, "ThreadsPerChild", 15) == 0) {
+            if (!max_clients) {
+                break; /* we're in the clear, got ThreadsPerChild first */
+            }
+            else {
+                /* now to swap the data */
+                ap_directive_t temp;
+
+                temp.directive = pdir->directive;
+                temp.args = pdir->args;
+                /* Make sure you don't change 'next', or you may get loops! */
+                /* XXX: first_child, parent, and data can never be set
+                 * for these directives, right? -aaron */
+                temp.filename = pdir->filename;
+                temp.line_num = pdir->line_num;
+
+                pdir->directive = max_clients->directive;
+                pdir->args = max_clients->args;
+                pdir->filename = max_clients->filename;
+                pdir->line_num = max_clients->line_num;
+                
+                max_clients->directive = temp.directive;
+                max_clients->args = temp.args;
+                max_clients->filename = temp.filename;
+                max_clients->line_num = temp.line_num;
+                break;
+            }
+        }
+        else if (!max_clients
+                && strncasecmp(pdir->directive, "MaxClients", 10) == 0) {
+            max_clients = pdir;
+        }
+    }
 
     debug = ap_exists_config_define("DEBUG");
 
@@ -1515,21 +1553,52 @@ static const char *set_max_spare_threads(cmd_parms *cmd, void *dummy,
 static const char *set_server_limit (cmd_parms *cmd, void *dummy,
                                     const char *arg) 
 {
+    int max_clients;
     const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
     if (err != NULL) {
         return err;
     }
 
-    ap_daemons_limit = atoi(arg);
+    /* It is ok to use ap_threads_per_child here because we are
+     * sure that it gets set before MaxClients in the pre_config stage. */
+    max_clients = atoi(arg);
+    if (max_clients < ap_threads_per_child) {
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    "WARNING: MaxClients (%d) must be at least as large",
+                    max_clients);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    " large as ThreadsPerChild (%d). Automatically",
+                    ap_threads_per_child);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    " increasing MaxClients to %d.",
+                    ap_threads_per_child);
+       max_clients = ap_threads_per_child;
+    }
+    ap_daemons_limit = max_clients / ap_threads_per_child;
+    if ((max_clients > 0) && (max_clients % ap_threads_per_child)) {
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    "WARNING: MaxClients (%d) is not an integer multiple",
+                    max_clients);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    " of ThreadsPerChild (%d), lowering MaxClients to %d",
+                    ap_threads_per_child,
+                    ap_daemons_limit * ap_threads_per_child);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    " for a maximum of %d child processes,",
+                    ap_daemons_limit);
+    }
     if (ap_daemons_limit > HARD_SERVER_LIMIT) {
        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
-                    "WARNING: MaxClients of %d exceeds compile time limit "
-                    "of %d servers,", ap_daemons_limit, HARD_SERVER_LIMIT);
+                    "WARNING: MaxClients of %d would require %d servers,",
+                    max_clients, ap_daemons_limit);
+       ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
+                    " and would exceed the compile time limit of %d.",
+                    HARD_SERVER_LIMIT);
        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
-                    " lowering MaxClients to %d.  To increase, please "
-                    "see the", HARD_SERVER_LIMIT);
+                    " Automatically lowering MaxClients to %d.  To increase,",
+                    HARD_SERVER_LIMIT);
        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
-                    " HARD_SERVER_LIMIT define in %s.",
+                    " please see the HARD_SERVER_LIMIT define in %s.",
                     AP_MPM_HARD_LIMITS_FILE);
        ap_daemons_limit = HARD_SERVER_LIMIT;
     }