Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 92730 invoked from network); 10 Nov 2005 15:21:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 10 Nov 2005 15:21:26 -0000 Received: (qmail 63834 invoked by uid 500); 10 Nov 2005 15:20:40 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 63680 invoked by uid 500); 10 Nov 2005 15:20:37 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 63340 invoked by uid 99); 10 Nov 2005 15:20:29 -0000 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 10 Nov 2005 07:20:13 -0800 Received: (qmail 91830 invoked by uid 65534); 10 Nov 2005 15:19:51 -0000 Message-ID: <20051110151951.91829.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r332306 [9/14] - in /httpd/httpd/trunk: modules/aaa/ modules/arch/netware/ modules/arch/win32/ modules/cache/ modules/dav/fs/ modules/dav/lock/ modules/dav/main/ modules/debug/ modules/echo/ modules/experimental/ modules/filters/ modules/ge... Date: Thu, 10 Nov 2005 15:13:26 -0000 To: cvs@httpd.apache.org From: jim@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: httpd/httpd/trunk/server/mpm/experimental/leader/leader.c URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/server/mpm/experimental/leader/leader.c?rev=332306&r1=332305&r2=332306&view=diff ============================================================================== --- httpd/httpd/trunk/server/mpm/experimental/leader/leader.c (original) +++ httpd/httpd/trunk/server/mpm/experimental/leader/leader.c Thu Nov 10 07:11:44 2005 @@ -33,7 +33,7 @@ #include #endif #if APR_HAVE_SYS_WAIT_H -#include +#include #endif #ifdef HAVE_SYS_PROCESSOR_H #include /* for bindprocessor() */ @@ -43,19 +43,19 @@ #error The Leader/Follower MPM requires APR threads, but they are unavailable. #endif -#define CORE_PRIVATE - +#define CORE_PRIVATE + #include "ap_config.h" -#include "httpd.h" -#include "http_main.h" -#include "http_log.h" -#include "http_config.h" /* for read_config */ -#include "http_core.h" /* for get_remote_host */ +#include "httpd.h" +#include "http_main.h" +#include "http_log.h" +#include "http_config.h" /* for read_config */ +#include "http_core.h" /* for get_remote_host */ #include "http_connection.h" #include "ap_mpm.h" #include "mpm_common.h" #include "ap_listen.h" -#include "scoreboard.h" +#include "scoreboard.h" #include "mpm_default.h" #include "apr_poll.h" @@ -94,7 +94,7 @@ * the overhead. */ #ifndef DEFAULT_THREAD_LIMIT -#define DEFAULT_THREAD_LIMIT 64 +#define DEFAULT_THREAD_LIMIT 64 #endif /* Admin can't tune ThreadLimit beyond MAX_THREAD_LIMIT. We want @@ -136,7 +136,7 @@ } proc_info; -/* Structure used to pass information to the thread responsible for +/* Structure used to pass information to the thread responsible for * creating the rest of the threads. */ typedef struct { @@ -149,8 +149,8 @@ /* * The max child slot ever assigned, preserved across restarts. Necessary - * to deal with MaxClients changes across AP_SIG_GRACEFUL restarts. We - * use this value to optimize routines that have to scan the entire + * to deal with MaxClients changes across AP_SIG_GRACEFUL restarts. We + * use this value to optimize routines that have to scan the entire * scoreboard. */ int ap_max_daemons_limit = -1; @@ -183,7 +183,7 @@ static apr_pool_t *pconf; /* Pool for config stuff */ static apr_pool_t *pchild; /* Pool for httpd child stuff */ -static pid_t ap_my_pid; /* Linux getpid() doesn't work except in main +static pid_t ap_my_pid; /* Linux getpid() doesn't work except in main thread. Use this instead */ static pid_t parent_pid; @@ -228,7 +228,7 @@ } -/* Structure used to hold a stack of idle worker threads +/* Structure used to hold a stack of idle worker threads */ typedef struct { /* 'state' consists of several fields concatenated into a @@ -282,7 +282,7 @@ else { return apr_thread_cond_wait(wakeup->cond, wakeup->mutex); } - } + } } static apr_status_t worker_stack_awaken_next(worker_stack *stack) @@ -389,7 +389,7 @@ case AP_MPMQ_MIN_SPARE_DAEMONS: *result = 0; return APR_SUCCESS; - case AP_MPMQ_MIN_SPARE_THREADS: + case AP_MPMQ_MIN_SPARE_THREADS: *result = min_spare_threads; return APR_SUCCESS; case AP_MPMQ_MAX_SPARE_DAEMONS: @@ -411,7 +411,7 @@ return APR_ENOTIMPL; } -/* a clean exit from a child with proper cleanup */ +/* a clean exit from a child with proper cleanup */ static void clean_child_exit(int code) __attribute__ ((noreturn)); static void clean_child_exit(int code) { @@ -441,8 +441,8 @@ /* * ap_start_shutdown() and ap_start_restart(), below, are a first stab at - * functions to initiate shutdown or restart without relying on signals. - * Previously this was initiated in sig_term() and restart() signal handlers, + * functions to initiate shutdown or restart without relying on signals. + * Previously this was initiated in sig_term() and restart() signal handlers, * but we want to be able to start a shutdown/restart from other sources -- * e.g. on Win32, from the service manager. Now the service manager can * call ap_start_shutdown() or ap_start_restart() as appropiate. Note that @@ -514,42 +514,42 @@ sa.sa_handler = sig_term; if (sigaction(SIGTERM, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGTERM)"); #ifdef SIGINT if (sigaction(SIGINT, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGINT)"); #endif #ifdef SIGXCPU sa.sa_handler = SIG_DFL; if (sigaction(SIGXCPU, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGXCPU)"); #endif #ifdef SIGXFSZ sa.sa_handler = SIG_DFL; if (sigaction(SIGXFSZ, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGXFSZ)"); #endif #ifdef SIGPIPE sa.sa_handler = SIG_IGN; if (sigaction(SIGPIPE, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGPIPE)"); #endif - /* we want to ignore HUPs and AP_SIG_GRACEFUL while we're busy + /* we want to ignore HUPs and AP_SIG_GRACEFUL while we're busy * processing one */ sigaddset(&sa.sa_mask, SIGHUP); sigaddset(&sa.sa_mask, AP_SIG_GRACEFUL); sa.sa_handler = restart; if (sigaction(SIGHUP, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGHUP)"); if (sigaction(AP_SIG_GRACEFUL, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(" AP_SIG_GRACEFUL_STRING ")"); #else if (!one_process) { @@ -621,16 +621,16 @@ else { /* wow! if you're executing this code, you may have set a record. * either this child process has served over 2 billion requests, or - * you're running a threaded 2.0 on a 16 bit machine. + * you're running a threaded 2.0 on a 16 bit machine. * * I'll buy pizza and beers at Apachecon for the first person to do * the former without cheating (dorking with INT_MAX, or running with - * uncommitted performance patches, for example). + * uncommitted performance patches, for example). * * for the latter case, you probably deserve a beer too. Greg Ames */ - - requests_this_child = INT_MAX; /* keep going */ + + requests_this_child = INT_MAX; /* keep going */ } } @@ -688,7 +688,7 @@ /* ### check the status */ (void) apr_pollset_add(pollset, &pfd); } - + /* TODO: Switch to a system where threads reuse the results from earlier poll calls - manoj */ is_listener = 0; @@ -725,7 +725,7 @@ if (workers_may_exit) { break; } - if (ap_scoreboard_image->parent[process_slot].generation != + if (ap_scoreboard_image->parent[process_slot].generation != ap_scoreboard_image->global->running_generation) { level = APLOG_DEBUG; /* common to get these at restart time */ } @@ -802,7 +802,7 @@ if (workers_may_exit) { break; } - if (ap_scoreboard_image->parent[process_slot].generation != + if (ap_scoreboard_image->parent[process_slot].generation != ap_scoreboard_image->global->running_generation) { level = APLOG_DEBUG; /* common to get these at restart time */ } @@ -918,14 +918,14 @@ my_info->pid = my_child_num; my_info->tid = i; my_info->sd = 0; - + /* We are creating threads right now */ ap_update_child_status_from_indexes(my_child_num, i, SERVER_STARTING, NULL); /* We let each thread update its own scoreboard entry. This is * done because it lets us deal with tid better. */ - rv = apr_thread_create(&threads[i], thread_attr, + rv = apr_thread_create(&threads[i], thread_attr, worker_thread, my_info, pchild); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf, @@ -954,15 +954,15 @@ prev_threads_created = threads_created; } } - - /* What state should this child_main process be listed as in the + + /* What state should this child_main process be listed as in the * scoreboard...? - * ap_update_child_status_from_indexes(my_child_num, i, SERVER_STARTING, + * ap_update_child_status_from_indexes(my_child_num, i, SERVER_STARTING, * (request_rec *) NULL); - * + * * This state should be listed separately in the scoreboard, in some kind - * of process_status, not mixed in with the worker threads' status. - * "life_status" is almost right, but it's in the worker's structure, and + * of process_status, not mixed in with the worker threads' status. + * "life_status" is almost right, but it's in the worker's structure, and * the name could be clearer. gla */ apr_thread_exit(thd, APR_SUCCESS); @@ -991,8 +991,8 @@ { apr_status_t rv, thread_rv; - start_thread_may_exit = 1; /* tell it to give up in case it is still - * trying to take over slots from a + start_thread_may_exit = 1; /* tell it to give up in case it is still + * trying to take over slots from a * previous generation */ rv = apr_thread_join(&thread_rv, start_thread_id); @@ -1056,13 +1056,13 @@ /* coding a value of zero means infinity */ requests_this_child = INT_MAX; } - + /* Setup worker threads */ - /* clear the storage; we may not create all our threads immediately, + /* clear the storage; we may not create all our threads immediately, * and we want a 0 entry to indicate a thread which was not created */ - threads = (apr_thread_t **)calloc(1, + threads = (apr_thread_t **)calloc(1, sizeof(apr_thread_t *) * ap_threads_per_child); if (threads == NULL) { ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf, @@ -1102,7 +1102,7 @@ if (one_process) { /* Block until we get a terminating signal. */ apr_signal_thread(check_signal); - /* make sure the start thread has finished; signal_threads() + /* make sure the start thread has finished; signal_threads() * and join_workers() depend on that */ /* XXX join_start_thread() won't be awakened if one of our @@ -1138,7 +1138,7 @@ clean_child_exit(resource_shortage ? APEXIT_CHILDSICK : 0); } -static int make_child(server_rec *s, int slot) +static int make_child(server_rec *s, int slot) { int pid; @@ -1153,7 +1153,7 @@ } if ((pid = fork()) == -1) { - ap_log_error(APLOG_MARK, APLOG_ERR, errno, s, + ap_log_error(APLOG_MARK, APLOG_ERR, errno, s, "fork: Unable to fork new process"); /* fork didn't succeed. Fix the scoreboard or else @@ -1177,7 +1177,7 @@ int status = bindprocessor(BINDPROCESS, (int)getpid(), PROCESSOR_CLASS_ANY); if (status != OK) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "processor unbind failed %d", status); #endif @@ -1258,7 +1258,7 @@ status = ws->status; /* XXX any_dying_threads is probably no longer needed GLA */ - any_dying_threads = any_dying_threads || + any_dying_threads = any_dying_threads || (status == SERVER_GRACEFUL); any_dead_threads = any_dead_threads || (status == SERVER_DEAD); all_dead_threads = all_dead_threads && @@ -1274,19 +1274,19 @@ if (status <= SERVER_READY && status != SERVER_DEAD && !ps->quiescing && ps->generation == ap_my_generation && - /* XXX the following shouldn't be necessary if we clean up - * properly after seg faults, but we're not yet GLA - */ + /* XXX the following shouldn't be necessary if we clean up + * properly after seg faults, but we're not yet GLA + */ ps->pid != 0) { ++idle_thread_count; } } - if (any_dead_threads && totally_free_length < idle_spawn_rate + if (any_dead_threads && totally_free_length < idle_spawn_rate && (!ps->pid /* no process in the slot */ || ps->quiescing)) { /* or at least one is going away */ if (all_dead_threads) { /* great! we prefer these, because the new process can - * start more threads sooner. So prioritize this slot + * start more threads sooner. So prioritize this slot * by putting it ahead of any slots with active threads. * * first, make room by moving a slot that's potentially still @@ -1320,9 +1320,9 @@ if (free_length == 0) { /* only report this condition once */ static int reported = 0; - + if (!reported) { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, + ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, "server reached MaxClients setting, consider" " raising the MaxClients setting"); @@ -1335,7 +1335,7 @@ free_length = idle_spawn_rate; } if (idle_spawn_rate >= 8) { - ap_log_error(APLOG_MARK, APLOG_INFO, 0, + ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf, "server seems busy, (you may need " "to increase StartServers, ThreadsPerChild " @@ -1373,7 +1373,7 @@ while (!restart_pending && !shutdown_pending) { ap_wait_or_timeout(&exitwhy, &status, &pid, pconf); - + if (pid.pid != -1) { processed_status = ap_process_child_status(&pid, exitwhy, status); if (processed_status == APEXIT_CHILDFATAL) { @@ -1385,9 +1385,9 @@ child_slot = find_child_by_pid(&pid); if (child_slot >= 0) { for (i = 0; i < ap_threads_per_child; i++) - ap_update_child_status_from_indexes(child_slot, i, SERVER_DEAD, + ap_update_child_status_from_indexes(child_slot, i, SERVER_DEAD, (request_rec *) NULL); - + ap_scoreboard_image->parent[child_slot].pid = 0; ap_scoreboard_image->parent[child_slot].quiescing = 0; if (processed_status == APEXIT_CHILDSICK) { @@ -1458,13 +1458,13 @@ "ignored during restart"); changed_limit_at_restart = 0; } - + /* Initialize cross-process accept lock */ ap_lock_fname = apr_psprintf(_pconf, "%s.%" APR_PID_T_FMT, ap_server_root_relative(_pconf, ap_lock_fname), ap_my_pid); - rv = apr_proc_mutex_create(&accept_mutex, ap_lock_fname, + rv = apr_proc_mutex_create(&accept_mutex, ap_lock_fname, ap_accept_lock_mech, _pconf); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, @@ -1474,7 +1474,7 @@ } #if APR_USE_SYSVSEM_SERIALIZE - if (ap_accept_lock_mech == APR_LOCK_DEFAULT || + if (ap_accept_lock_mech == APR_LOCK_DEFAULT || ap_accept_lock_mech == APR_LOCK_SYSVSEM) { #else if (ap_accept_lock_mech == APR_LOCK_SYSVSEM) { @@ -1547,7 +1547,7 @@ if (shutdown_pending) { /* Time to gracefully shut down: * Kill child processes, tell them to call child_exit, etc... - * (By "gracefully" we don't mean graceful in the same sense as + * (By "gracefully" we don't mean graceful in the same sense as * "apachectl graceful" where we allow old connections to finish.) */ if (unixd_killpg(getpgrp(), SIGTERM) < 0) { @@ -1564,7 +1564,7 @@ ap_server_conf, "removed PID file %s (pid=%ld)", pidfile, (long)getpid()); - + ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, "caught SIGTERM, shutting down"); } @@ -1585,21 +1585,21 @@ */ ++ap_my_generation; ap_scoreboard_image->global->running_generation = ap_my_generation; - + if (is_graceful) { ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, AP_SIG_GRACEFUL_STRING " received. Doing graceful restart"); /* wake up the children...time to die. But we'll have more soon */ ap_mpm_pod_killpg(pod, ap_daemons_limit); - + /* This is mostly for debugging... so that we know what is still * gracefully dealing with existing request. */ - + } else { - /* Kill 'em all. Since the child acts the same on the parents SIGTERM + /* Kill 'em all. Since the child acts the same on the parents SIGTERM * and a SIGHUP, we may as well use the same signal, because some user * pthreads are stealing signals from us left and right. */ @@ -1639,7 +1639,7 @@ return OK; } -static int leader_pre_config(apr_pool_t *pconf, apr_pool_t *plog, +static int leader_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp) { static int restart_num = 0; @@ -1672,7 +1672,7 @@ 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; @@ -1751,7 +1751,7 @@ } static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, - const char *arg) + const char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { @@ -1772,15 +1772,15 @@ min_spare_threads = atoi(arg); if (min_spare_threads <= 0) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: detected MinSpareThreads set to non-positive."); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Resetting to 1 to avoid almost certain Apache failure."); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Please read the documentation."); min_spare_threads = 1; } - + return NULL; } @@ -1797,7 +1797,7 @@ } static const char *set_max_clients (cmd_parms *cmd, void *dummy, - const char *arg) + const char *arg) { int max_clients; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); @@ -1809,47 +1809,47 @@ * 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, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: MaxClients (%d) must be at least as large", max_clients); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " large as ThreadsPerChild (%d). Automatically", ap_threads_per_child); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 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, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: MaxClients (%d) is not an integer multiple", max_clients); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 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, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " for a maximum of %d child processes,", ap_daemons_limit); - max_clients = ap_daemons_limit * ap_threads_per_child; + max_clients = ap_daemons_limit * ap_threads_per_child; } if (ap_daemons_limit > server_limit) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: MaxClients of %d would require %d servers,", max_clients, ap_daemons_limit); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " and would exceed the ServerLimit value of %d.", server_limit); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " Automatically lowering MaxClients to %d. To increase,", server_limit * ap_threads_per_child); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " please see the ServerLimit directive."); ap_daemons_limit = server_limit; - } + } else if (ap_daemons_limit < 1) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: Require MaxClients > 0, setting to 1"); ap_daemons_limit = 1; } @@ -1857,7 +1857,7 @@ } static const char *set_threads_per_child (cmd_parms *cmd, void *dummy, - const char *arg) + const char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { @@ -1866,29 +1866,29 @@ ap_threads_per_child = atoi(arg); if (ap_threads_per_child > thread_limit) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: ThreadsPerChild of %d exceeds ThreadLimit " "value of %d", ap_threads_per_child, thread_limit); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "threads, lowering ThreadsPerChild to %d. To increase, please" " see the", thread_limit); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " ThreadLimit directive."); ap_threads_per_child = thread_limit; } else if (ap_threads_per_child < 1) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: Require ThreadsPerChild > 0, setting to 1"); ap_threads_per_child = 1; } return NULL; } -static const char *set_server_limit (cmd_parms *cmd, void *dummy, const char *arg) +static const char *set_server_limit (cmd_parms *cmd, void *dummy, const char *arg) { int tmp_server_limit; - + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { return err; @@ -1908,27 +1908,27 @@ return NULL; } server_limit = tmp_server_limit; - + if (server_limit > MAX_SERVER_LIMIT) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: ServerLimit of %d exceeds compile time limit " "of %d servers,", server_limit, MAX_SERVER_LIMIT); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " lowering ServerLimit to %d.", MAX_SERVER_LIMIT); server_limit = MAX_SERVER_LIMIT; - } + } else if (server_limit < 1) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: Require ServerLimit > 0, setting to 1"); server_limit = 1; } return NULL; } -static const char *set_thread_limit (cmd_parms *cmd, void *dummy, const char *arg) +static const char *set_thread_limit (cmd_parms *cmd, void *dummy, const char *arg) { int tmp_thread_limit; - + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { return err; @@ -1948,17 +1948,17 @@ return NULL; } thread_limit = tmp_thread_limit; - + if (thread_limit > MAX_THREAD_LIMIT) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: ThreadLimit of %d exceeds compile time limit " "of %d servers,", thread_limit, MAX_THREAD_LIMIT); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " lowering ThreadLimit to %d.", MAX_THREAD_LIMIT); thread_limit = MAX_THREAD_LIMIT; - } + } else if (thread_limit < 1) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: Require ThreadLimit > 0, setting to 1"); thread_limit = 1; } Modified: httpd/httpd/trunk/server/mpm/experimental/perchild/perchild.c URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/server/mpm/experimental/perchild/perchild.c?rev=332306&r1=332305&r2=332306&view=diff ============================================================================== --- httpd/httpd/trunk/server/mpm/experimental/perchild/perchild.c (original) +++ httpd/httpd/trunk/server/mpm/experimental/perchild/perchild.c Thu Nov 10 07:11:44 2005 @@ -33,16 +33,16 @@ #if !APR_HAS_THREADS #error The perchild MPM requires APR threads, but they are unavailable. -#endif +#endif + +#define CORE_PRIVATE -#define CORE_PRIVATE - #include "ap_config.h" -#include "httpd.h" -#include "http_main.h" -#include "http_log.h" -#include "http_config.h" /* for read_config */ -#include "http_core.h" /* for get_remote_host */ +#include "httpd.h" +#include "http_main.h" +#include "http_log.h" +#include "http_config.h" /* for read_config */ +#include "http_core.h" /* for get_remote_host */ #include "http_protocol.h" #include "http_connection.h" #include "ap_mpm.h" @@ -87,7 +87,7 @@ * the overhead. */ #ifndef DEFAULT_THREAD_LIMIT -#define DEFAULT_THREAD_LIMIT 64 +#define DEFAULT_THREAD_LIMIT 64 #endif /* Admin can't tune ThreadLimit beyond MAX_THREAD_LIMIT. We want @@ -95,7 +95,7 @@ */ #ifndef MAX_THREAD_LIMIT #define MAX_THREAD_LIMIT 20000 -#endif +#endif /* Limit on the total --- clients will be locked out if more servers than * this are needed. It is intended solely to keep the server from crashing @@ -109,7 +109,7 @@ * the overhead. */ #ifndef DEFAULT_SERVER_LIMIT -#define DEFAULT_SERVER_LIMIT 8 +#define DEFAULT_SERVER_LIMIT 8 #endif /* Admin can't tune ServerLimit beyond MAX_SERVER_LIMIT. We want @@ -166,8 +166,8 @@ /* * The max child slot ever assigned, preserved across restarts. Necessary - * to deal with NumServers changes across AP_SIG_GRACEFUL restarts. We - * use this value to optimize routines that have to scan the entire child + * to deal with NumServers changes across AP_SIG_GRACEFUL restarts. We + * use this value to optimize routines that have to scan the entire child * table. * * XXX - It might not be worth keeping this code in. There aren't very @@ -209,7 +209,7 @@ static apr_thread_mutex_t *thread_pool_parent_mutex; static int child_num; -static unsigned int my_pid; /* Linux getpid() doesn't work except in +static unsigned int my_pid; /* Linux getpid() doesn't work except in main thread. Use this instead */ /* Keep track of the number of worker threads currently active */ static int worker_thread_count; @@ -254,7 +254,7 @@ case AP_MPMQ_MIN_SPARE_DAEMONS: *result = 0; return APR_SUCCESS; - case AP_MPMQ_MIN_SPARE_THREADS: + case AP_MPMQ_MIN_SPARE_THREADS: *result = min_spare_threads; return APR_SUCCESS; case AP_MPMQ_MAX_SPARE_DAEMONS: @@ -265,7 +265,7 @@ return APR_SUCCESS; case AP_MPMQ_MAX_REQUESTS_DAEMON: *result = ap_max_requests_per_child; - return APR_SUCCESS; + return APR_SUCCESS; case AP_MPMQ_MAX_DAEMONS: *result = num_daemons; return APR_SUCCESS; @@ -296,14 +296,14 @@ static int volatile restart_pending; static int volatile is_graceful; static int volatile child_fatal; -/* we don't currently track ap_my_generation, but mod_status +/* we don't currently track ap_my_generation, but mod_status * references it so it must be defined */ ap_generation_t volatile ap_my_generation=0; /* * ap_start_shutdown() and ap_start_restart(), below, are a first stab at - * functions to initiate shutdown or restart without relying on signals. - * Previously this was initiated in sig_term() and restart() signal handlers, + * functions to initiate shutdown or restart without relying on signals. + * Previously this was initiated in sig_term() and restart() signal handlers, * but we want to be able to start a shutdown/restart from other sources -- * e.g. on Win32, from the service manager. Now the service manager can * call ap_start_shutdown() or ap_start_restart() as appropiate. Note that @@ -399,7 +399,7 @@ "sigaction(SIGPIPE)"); #endif - /* we want to ignore HUPs and AP_SIG_GRACEFUL while we're busy + /* we want to ignore HUPs and AP_SIG_GRACEFUL while we're busy * processing one */ sigaddset(&sa.sa_mask, SIGHUP); sigaddset(&sa.sa_mask, AP_SIG_GRACEFUL); @@ -466,7 +466,7 @@ } ap_create_sb_handle(&sbh, p, conn_id / thread_limit, thread_num); - current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id, + current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id, sbh, bucket_alloc); if (current_conn) { ap_process_connection(current_conn, sock); @@ -495,7 +495,7 @@ } return DECLINED; } - + static void *worker_thread(apr_thread_t *, void *); @@ -526,7 +526,7 @@ } else { static int reported = 0; - + if (!reported) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, @@ -652,7 +652,7 @@ apr_thread_mutex_unlock(thread_pool_parent_mutex); apr_pool_create(&ptrans, tpool); - (void) ap_update_child_status_from_indexes(child_num, thread_num, + (void) ap_update_child_status_from_indexes(child_num, thread_num, SERVER_STARTING, (request_rec *) NULL); @@ -685,7 +685,7 @@ thread_just_started = 0; } - (void) ap_update_child_status_from_indexes(child_num, thread_num, + (void) ap_update_child_status_from_indexes(child_num, thread_num, SERVER_READY, (request_rec *) NULL); @@ -764,7 +764,7 @@ } else { thread_socket_table[thread_num] = AP_PERCHILD_THISCHILD; - } + } requests_this_child--; } else { @@ -891,7 +891,7 @@ return 1; } return 0; -} +} typedef struct perchild_header { char *headers; @@ -906,7 +906,7 @@ static int perchild_header_field(perchild_header *h, const char *fieldname, const char *fieldval) { - apr_pstrcat(h->p, h->headers, fieldname, ": ", fieldval, CRLF, NULL); + apr_pstrcat(h->p, h->headers, fieldname, ": ", fieldval, CRLF, NULL); return 1; } @@ -917,7 +917,7 @@ apr_status_t rv; apr_socket_t *sock = NULL; ap_listen_rec *lr; - + my_pid = getpid(); ap_fatal_signal_child_setup(ap_server_conf); child_num = child_num_arg; @@ -938,7 +938,7 @@ /*stuff to do before we switch id's, so we have permissions.*/ - rv = SAFE_ACCEPT(apr_proc_mutex_child_init(&process_accept_mutex, + rv = SAFE_ACCEPT(apr_proc_mutex_child_init(&process_accept_mutex, ap_lock_fname, pchild)); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, @@ -957,7 +957,7 @@ apr_setup_signal_thread(); requests_this_child = ap_max_requests_per_child; - + /* Setup worker threads */ @@ -971,9 +971,9 @@ worker_thread_free_ids[i] = i; } apr_pool_create(&thread_pool_parent, pchild); - apr_thread_mutex_create(&thread_pool_parent_mutex, + apr_thread_mutex_create(&thread_pool_parent_mutex, APR_THREAD_MUTEX_DEFAULT, pchild); - apr_thread_mutex_create(&idle_thread_count_mutex, + apr_thread_mutex_create(&idle_thread_count_mutex, APR_THREAD_MUTEX_DEFAULT, pchild); apr_thread_mutex_create(&worker_thread_count_mutex, APR_THREAD_MUTEX_DEFAULT, pchild); @@ -1035,7 +1035,7 @@ int status = bindprocessor(BINDPROCESS, (int)getpid(), PROCESSOR_CLASS_ANY); if (status != OK) { - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "processor unbind failed %d", status); } #endif @@ -1094,7 +1094,7 @@ /* initialize the free_list */ free_length = 0; - + for (i = 0; i < num_daemons; ++i) { if (ap_child_table[i].pid == 0) { if (free_length < spawn_rate) { @@ -1141,7 +1141,7 @@ while (!restart_pending && !shutdown_pending) { ap_wait_or_timeout(&exitwhy, &status, &pid, pconf); - + if (pid.pid != -1) { if (ap_process_child_status(&pid, exitwhy, status) == APEXIT_CHILDFATAL) { @@ -1163,7 +1163,7 @@ ap_update_child_status_from_indexes(child_slot, i, SERVER_DEAD, (request_rec *) NULL); - + if (remaining_children_to_start && child_slot < num_daemons) { /* we're still doing a 1-for-1 replacement of dead @@ -1184,9 +1184,9 @@ * child table. Somehow we don't know about this * child. */ - ap_log_error(APLOG_MARK, APLOG_WARNING, 0, + ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf, - "long lost child came home! (pid %ld)", + "long lost child came home! (pid %ld)", (long)pid.pid); } /* Don't perform idle maintenance when a child dies, @@ -1237,7 +1237,7 @@ ap_server_conf = s; - if ((ap_accept_lock_mech == APR_LOCK_SYSVSEM) || + if ((ap_accept_lock_mech == APR_LOCK_SYSVSEM) || (ap_accept_lock_mech == APR_LOCK_POSIXSEM)) { ap_log_error(APLOG_MARK, APLOG_WARNING, 0, s, "Server configured for an accept lock mechanism that " @@ -1295,8 +1295,8 @@ /* If we're doing a graceful_restart then we're going to see a lot * of children exiting immediately when we get into the main loop - * below (because we just sent them AP_SIG_GRACEFUL). This happens - * pretty rapidly... and for each one that exits we'll start a new one + * below (because we just sent them AP_SIG_GRACEFUL). This happens + * pretty rapidly... and for each one that exits we'll start a new one * until we reach at least daemons_min_free. But we may be permitted to * start more than that, so we'll just keep track of how many we're * supposed to start up without the 1 second penalty between each fork. @@ -1347,7 +1347,7 @@ "removed PID file %s (pid=%ld)", pidfile, (long)getpid()); } - + ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, "caught SIGTERM, shutting down"); } @@ -1372,11 +1372,11 @@ /* This is mostly for debugging... so that we know what is still * gracefully dealing with existing request. */ - + for (i = 0; i < num_daemons; ++i) { if (ap_child_table[i].pid) { ap_child_table[i].status = SERVER_DYING; - } + } } /* give the children the signal to die */ for (i = 0; i < num_daemons;) { @@ -1390,7 +1390,7 @@ } } else { - /* Kill 'em all. Since the child acts the same on the parents SIGTERM + /* Kill 'em all. Since the child acts the same on the parents SIGTERM * and a SIGHUP, we may as well use the same signal, because some user * pthreads are stealing signals from us left and right. */ @@ -1479,7 +1479,7 @@ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, "apr_proc_detach failed"); return HTTP_INTERNAL_SERVER_ERROR; - } + } } my_pid = getpid(); @@ -1551,10 +1551,10 @@ perchild_header h; apr_bucket *sockbuck; perchild_server_conf *sconf = (perchild_server_conf *) - ap_get_module_config(r->server->module_config, + ap_get_module_config(r->server->module_config, &mpm_perchild_module); - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, "passing request to another child. Vhost: %s, child %d %d", apr_table_get(r->headers_in, "Host"), child_num, sconf->output); ap_get_brigade(r->connection->input_filters, bb, AP_MODE_EXHAUSTIVE, APR_NONBLOCK_READ, @@ -1566,13 +1566,13 @@ break; } } - + if (!sockbuck) { } - sockbb = apr_brigade_split(bb, sockbuck); + sockbb = apr_brigade_split(bb, sockbuck); if (apr_brigade_flatten(bb, request_body, &l) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, "Unable to flatten brigade, declining request"); return DECLINED; } @@ -1580,10 +1580,10 @@ apr_os_sock_get(&sfd, thesock); h.p = r->pool; - h.headers = apr_pstrcat(h.p, r->the_request, CRLF, "Host: ", r->hostname, + h.headers = apr_pstrcat(h.p, r->the_request, CRLF, "Host: ", r->hostname, CRLF, NULL); apr_table_do((int (*) (void *, const char *, const char *)) - perchild_header_field, (void *) &h, r->headers_in, NULL); + perchild_header_field, (void *) &h, r->headers_in, NULL); h.headers = apr_pstrcat(h.p, h.headers, CRLF, NULL); iov[0].iov_base = h.headers; @@ -1606,17 +1606,17 @@ msg.msg_control = cmsg; msg.msg_controllen = cmsg->cmsg_len; - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, "Writing message to %d, passing sd: %d", sconf->output, sfd); if ((rv = sendmsg(sconf->output, &msg, 0)) == -1) { apr_pool_destroy(r->pool); - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, "Writing message failed %d %d", rv, errno); return -1; } - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, "Writing message succeeded %d", rv); apr_pool_destroy(r->pool); @@ -1644,7 +1644,7 @@ &mpm_perchild_module); if (sconf->input == -1) { - sconf->fullsockname = apr_pstrcat(sr->process->pool, + sconf->fullsockname = apr_pstrcat(sr->process->pool, sconf->sockname, ".DEFAULT", NULL); if (def_sd[0] == -1) { if (!make_perchild_socket(sconf->fullsockname, def_sd)) { @@ -1678,36 +1678,36 @@ { int thread_num = r->connection->id % thread_limit; perchild_server_conf *sconf = (perchild_server_conf *) - ap_get_module_config(r->server->module_config, + ap_get_module_config(r->server->module_config, &mpm_perchild_module); if (thread_socket_table[thread_num] != AP_PERCHILD_THISCHILD) { apr_socket_t *csd = NULL; - apr_os_sock_put(&csd, &thread_socket_table[thread_num], + apr_os_sock_put(&csd, &thread_socket_table[thread_num], r->connection->pool); ap_sock_disable_nagle(csd); ap_set_module_config(r->connection->conn_config, &core_module, csd); return OK; } else { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, "Determining if request should be passed. " - "Child Num: %d, SD: %d, sd from table: %d, hostname from server: %s", child_num, - sconf->input, child_info_table[child_num].input, + "Child Num: %d, SD: %d, sd from table: %d, hostname from server: %s", child_num, + sconf->input, child_info_table[child_num].input, r->server->server_hostname); /* sconf is the server config for this vhost, so if our socket * is not the same that was set in the config, then the request * needs to be passed to another child. */ if (sconf->input != child_info_table[child_num].input) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, "Passing request."); if (pass_request(r) == -1) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, "Could not pass request to proper " "child, request will not be honored."); } - longjmp(jmpbuffers[thread_num], 1); + longjmp(jmpbuffers[thread_num], 1); } return OK; } @@ -1724,10 +1724,10 @@ one_process = 0; ap_hook_open_logs(perchild_open_logs, NULL, aszSucc, APR_HOOK_MIDDLE); - ap_hook_pre_config(perchild_pre_config, NULL, NULL, APR_HOOK_MIDDLE); - ap_hook_post_config(perchild_post_config, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_pre_config(perchild_pre_config, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_post_config(perchild_post_config, NULL, NULL, APR_HOOK_MIDDLE); - /* Both of these must be run absolutely first. If this request isn't for + /* Both of these must be run absolutely first. If this request isn't for * this server then we need to forward it to the proper child. No sense * tying up this server running more post_read request hooks if it is * just going to be forwarded along. The process_connection hook allows @@ -1736,12 +1736,12 @@ */ ap_hook_post_read_request(perchild_post_read, NULL, NULL, APR_HOOK_REALLY_FIRST); - ap_hook_process_connection(perchild_process_connection, NULL, NULL, + ap_hook_process_connection(perchild_process_connection, NULL, NULL, APR_HOOK_REALLY_FIRST); } static const char *set_num_daemons(cmd_parms *cmd, void *dummy, - const char *arg) + const char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { @@ -1750,18 +1750,18 @@ num_daemons = atoi(arg); if (num_daemons > server_limit) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: NumServers of %d exceeds ServerLimit value " "of %d servers,", num_daemons, server_limit); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " lowering NumServers to %d. To increase, please " "see the", server_limit); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " ServerLimit directive."); num_daemons = server_limit; - } + } else if (num_daemons < 1) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: Require NumServers > 0, setting to 1"); num_daemons = 1; } @@ -1769,7 +1769,7 @@ } static const char *set_threads_to_start(cmd_parms *cmd, void *dummy, - const char *arg) + const char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { @@ -1778,18 +1778,18 @@ threads_to_start = atoi(arg); if (threads_to_start > thread_limit) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: StartThreads of %d exceeds ThreadLimit value" " of %d threads,", threads_to_start, thread_limit); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " lowering StartThreads to %d. To increase, please" " see the", thread_limit); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " ThreadLimit directive."); } else if (threads_to_start < 1) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: Require StartThreads > 0, setting to 1"); threads_to_start = 1; } @@ -1806,15 +1806,15 @@ min_spare_threads = atoi(arg); if (min_spare_threads <= 0) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: detected MinSpareThreads set to non-positive."); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Resetting to 1 to avoid almost certain Apache failure."); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Please read the documentation."); min_spare_threads = 1; } - + return NULL; } @@ -1828,9 +1828,9 @@ max_spare_threads = atoi(arg); if (max_spare_threads >= thread_limit) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: detected MinSpareThreads set higher than"); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "ThreadLimit. Resetting to %d", thread_limit); max_spare_threads = thread_limit; } @@ -1846,9 +1846,9 @@ max_threads = atoi(arg); if (max_threads > thread_limit) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: detected MaxThreadsPerChild set higher than"); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "ThreadLimit. Resetting to %d", thread_limit); max_threads = thread_limit; } @@ -1860,16 +1860,16 @@ { int i; int max_this_time = atoi(num) + curr_child_num; - + for (i = curr_child_num; i < max_this_time; i++, curr_child_num++) { if (i > num_daemons) { return "Trying to use more child ID's than NumServers. Increase " "NumServers in your config file."; } - + child_info_table[i].uid = ap_uname2id(u); - child_info_table[i].gid = ap_gname2id(g); + child_info_table[i].gid = ap_gname2id(g); #ifndef BIG_SECURITY_HOLE if (child_info_table[i].uid == 0 || child_info_table[i].gid == 0) { @@ -1890,7 +1890,7 @@ const char *errstr; int socks[2]; perchild_server_conf *sconf = (perchild_server_conf *) - ap_get_module_config(cmd->server->module_config, + ap_get_module_config(cmd->server->module_config, &mpm_perchild_module); sconf->fullsockname = apr_pstrcat(cmd->pool, sconf->sockname, ".", uid, @@ -1900,7 +1900,7 @@ return errstr; } - sconf->input = socks[0]; + sconf->input = socks[0]; sconf->output = socks[1]; for (i = 0; i < num_daemons; i++) { @@ -1908,10 +1908,10 @@ child_info_table[i].input = sconf->input; child_info_table[i].output = sconf->output; matching++; - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, cmd->server, + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, cmd->server, "filling out child_info_table; UID: %d, GID: %d, " - "SD: %d %d, OUTPUT: %d %d, Child Num: %d", - child_info_table[i].uid, child_info_table[i].gid, + "SD: %d %d, OUTPUT: %d %d, Child Num: %d", + child_info_table[i].uid, child_info_table[i].gid, sconf->input, child_info_table[i].input, sconf->output, child_info_table[i].output, i); } @@ -1923,10 +1923,10 @@ return NULL; } -static const char *set_server_limit (cmd_parms *cmd, void *dummy, const char *arg) +static const char *set_server_limit (cmd_parms *cmd, void *dummy, const char *arg) { int tmp_server_limit; - + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { return err; @@ -1946,27 +1946,27 @@ return NULL; } server_limit = tmp_server_limit; - + if (server_limit > MAX_SERVER_LIMIT) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: ServerLimit of %d exceeds compile time limit " "of %d servers,", server_limit, MAX_SERVER_LIMIT); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " lowering ServerLimit to %d.", MAX_SERVER_LIMIT); server_limit = MAX_SERVER_LIMIT; - } + } else if (server_limit < 1) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: Require ServerLimit > 0, setting to 1"); server_limit = 1; } return NULL; } -static const char *set_thread_limit (cmd_parms *cmd, void *dummy, const char *arg) +static const char *set_thread_limit (cmd_parms *cmd, void *dummy, const char *arg) { int tmp_thread_limit; - + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { return err; @@ -1986,17 +1986,17 @@ return NULL; } thread_limit = tmp_thread_limit; - + if (thread_limit > MAX_THREAD_LIMIT) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: ThreadLimit of %d exceeds compile time limit " "of %d servers,", thread_limit, MAX_THREAD_LIMIT); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " lowering ThreadLimit to %d.", MAX_THREAD_LIMIT); thread_limit = MAX_THREAD_LIMIT; - } + } else if (thread_limit < 1) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: Require ThreadLimit > 0, setting to 1"); thread_limit = 1; } Modified: httpd/httpd/trunk/server/mpm/experimental/threadpool/pod.c URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/server/mpm/experimental/threadpool/pod.c?rev=332306&r1=332305&r2=332306&view=diff ============================================================================== --- httpd/httpd/trunk/server/mpm/experimental/threadpool/pod.c (original) +++ httpd/httpd/trunk/server/mpm/experimental/threadpool/pod.c Thu Nov 10 07:11:44 2005 @@ -33,7 +33,7 @@ apr_file_pipe_timeout_set((*pod)->pod_in, 0); */ (*pod)->p = p; - + return APR_SUCCESS; } Modified: httpd/httpd/trunk/server/mpm/experimental/threadpool/threadpool.c URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/server/mpm/experimental/threadpool/threadpool.c?rev=332306&r1=332305&r2=332306&view=diff ============================================================================== --- httpd/httpd/trunk/server/mpm/experimental/threadpool/threadpool.c (original) +++ httpd/httpd/trunk/server/mpm/experimental/threadpool/threadpool.c Thu Nov 10 07:11:44 2005 @@ -41,7 +41,7 @@ #include #endif #if APR_HAVE_SYS_WAIT_H -#include +#include #endif #ifdef HAVE_SYS_PROCESSOR_H #include /* for bindprocessor() */ @@ -51,20 +51,20 @@ #error The Worker MPM requires APR threads, but they are unavailable. #endif -#define CORE_PRIVATE - +#define CORE_PRIVATE + #include "ap_config.h" -#include "httpd.h" -#include "http_main.h" -#include "http_log.h" -#include "http_config.h" /* for read_config */ -#include "http_core.h" /* for get_remote_host */ +#include "httpd.h" +#include "http_main.h" +#include "http_log.h" +#include "http_config.h" /* for read_config */ +#include "http_core.h" /* for get_remote_host */ #include "http_connection.h" #include "ap_mpm.h" #include "pod.h" #include "mpm_common.h" #include "ap_listen.h" -#include "scoreboard.h" +#include "scoreboard.h" #include "mpm_default.h" #include @@ -100,7 +100,7 @@ * the overhead. */ #ifndef DEFAULT_THREAD_LIMIT -#define DEFAULT_THREAD_LIMIT 64 +#define DEFAULT_THREAD_LIMIT 64 #endif /* Admin can't tune ThreadLimit beyond MAX_THREAD_LIMIT. We want @@ -140,7 +140,7 @@ int sd; } proc_info; -/* Structure used to pass information to the thread responsible for +/* Structure used to pass information to the thread responsible for * creating the rest of the threads. */ typedef struct { @@ -154,8 +154,8 @@ /* * The max child slot ever assigned, preserved across restarts. Necessary - * to deal with MaxClients changes across AP_SIG_GRACEFUL restarts. We - * use this value to optimize routines that have to scan the entire + * to deal with MaxClients changes across AP_SIG_GRACEFUL restarts. We + * use this value to optimize routines that have to scan the entire * scoreboard. */ int ap_max_daemons_limit = -1; @@ -188,7 +188,7 @@ static apr_pool_t *pconf; /* Pool for config stuff */ static apr_pool_t *pchild; /* Pool for httpd child stuff */ -static pid_t ap_my_pid; /* Linux getpid() doesn't work except in main +static pid_t ap_my_pid; /* Linux getpid() doesn't work except in main thread. Use this instead */ static pid_t parent_pid; static apr_os_thread_t *listener_os_thread; @@ -206,9 +206,9 @@ #define SAFE_ACCEPT(stmt) (stmt) #endif -/* The LISTENER_SIGNAL signal will be sent from the main thread to the - * listener thread to wake it up for graceful termination (what a child - * process from an old generation does when the admin does "apachectl +/* The LISTENER_SIGNAL signal will be sent from the main thread to the + * listener thread to wake it up for graceful termination (what a child + * process from an old generation does when the admin does "apachectl * graceful"). This signal will be blocked in all threads of a child * process except for the listener thread. */ @@ -232,7 +232,7 @@ apr_thread_mutex_t *mutex; } worker_wakeup_info; -/* Structure used to hold a stack of idle worker threads +/* Structure used to hold a stack of idle worker threads */ typedef struct { apr_thread_mutex_t *mutex; @@ -270,7 +270,7 @@ apr_status_t rv; wakeup->state = WORKER_IDLE; - + if ((rv = apr_thread_mutex_lock(stack->mutex)) != APR_SUCCESS) { return rv; } @@ -395,7 +395,7 @@ } if (!listener_os_thread) { /* XXX there is an obscure path that this doesn't handle perfectly: - * right after listener thread is created but before + * right after listener thread is created but before * listener_os_thread is set, the first worker thread hits an * error and starts graceful termination */ @@ -403,7 +403,7 @@ } /* * we should just be able to "kill(ap_my_pid, LISTENER_SIGNAL)" on all - * platforms and wake up the listener thread since it is the only thread + * platforms and wake up the listener thread since it is the only thread * with SIGHUP unblocked, but that doesn't work on Linux */ #ifdef HAVE_PTHREAD_KILL @@ -466,7 +466,7 @@ case AP_MPMQ_MIN_SPARE_DAEMONS: *result = 0; return APR_SUCCESS; - case AP_MPMQ_MIN_SPARE_THREADS: + case AP_MPMQ_MIN_SPARE_THREADS: *result = min_spare_threads; return APR_SUCCESS; case AP_MPMQ_MAX_SPARE_DAEMONS: @@ -488,7 +488,7 @@ return APR_ENOTIMPL; } -/* a clean exit from a child with proper cleanup */ +/* a clean exit from a child with proper cleanup */ static void clean_child_exit(int code) __attribute__ ((noreturn)); static void clean_child_exit(int code) { @@ -517,8 +517,8 @@ /* * ap_start_shutdown() and ap_start_restart(), below, are a first stab at - * functions to initiate shutdown or restart without relying on signals. - * Previously this was initiated in sig_term() and restart() signal handlers, + * functions to initiate shutdown or restart without relying on signals. + * Previously this was initiated in sig_term() and restart() signal handlers, * but we want to be able to start a shutdown/restart from other sources -- * e.g. on Win32, from the service manager. Now the service manager can * call ap_start_shutdown() or ap_start_restart() as appropiate. Note that @@ -585,42 +585,42 @@ sa.sa_handler = sig_term; if (sigaction(SIGTERM, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGTERM)"); #ifdef SIGINT if (sigaction(SIGINT, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGINT)"); #endif #ifdef SIGXCPU sa.sa_handler = SIG_DFL; if (sigaction(SIGXCPU, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGXCPU)"); #endif #ifdef SIGXFSZ sa.sa_handler = SIG_DFL; if (sigaction(SIGXFSZ, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGXFSZ)"); #endif #ifdef SIGPIPE sa.sa_handler = SIG_IGN; if (sigaction(SIGPIPE, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGPIPE)"); #endif - /* we want to ignore HUPs and AP_SIG_GRACEFUL while we're busy + /* we want to ignore HUPs and AP_SIG_GRACEFUL while we're busy * processing one */ sigaddset(&sa.sa_mask, SIGHUP); sigaddset(&sa.sa_mask, AP_SIG_GRACEFUL); sa.sa_handler = restart; if (sigaction(SIGHUP, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGHUP)"); if (sigaction(AP_SIG_GRACEFUL, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(" AP_SIG_GRACEFUL_STRING ")"); #else if (!one_process) { @@ -695,16 +695,16 @@ else { /* wow! if you're executing this code, you may have set a record. * either this child process has served over 2 billion requests, or - * you're running a threaded 2.0 on a 16 bit machine. + * you're running a threaded 2.0 on a 16 bit machine. * * I'll buy pizza and beers at Apachecon for the first person to do * the former without cheating (dorking with INT_MAX, or running with - * uncommitted performance patches, for example). + * uncommitted performance patches, for example). * * for the latter case, you probably deserve a beer too. Greg Ames */ - - requests_this_child = INT_MAX; /* keep going */ + + requests_this_child = INT_MAX; /* keep going */ } } @@ -794,7 +794,7 @@ if (listener_may_exit) { break; } - if (ap_scoreboard_image->parent[process_slot].generation != + if (ap_scoreboard_image->parent[process_slot].generation != ap_scoreboard_image->global->running_generation) { level = APLOG_DEBUG; /* common to get these at restart time */ } @@ -871,7 +871,7 @@ if (listener_may_exit) { break; } - if (ap_scoreboard_image->parent[process_slot].generation != + if (ap_scoreboard_image->parent[process_slot].generation != ap_scoreboard_image->global->running_generation) { level = APLOG_DEBUG; /* common to get these at restart time */ } @@ -1091,14 +1091,14 @@ my_info->pid = my_child_num; my_info->tid = i; my_info->sd = 0; - + /* We are creating threads right now */ ap_update_child_status_from_indexes(my_child_num, i, SERVER_STARTING, NULL); /* We let each thread update its own scoreboard entry. This is * done because it lets us deal with tid better. */ - rv = apr_thread_create(&threads[i], thread_attr, + rv = apr_thread_create(&threads[i], thread_attr, worker_thread, my_info, pchild); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf, @@ -1133,15 +1133,15 @@ prev_threads_created = threads_created; } } - - /* What state should this child_main process be listed as in the + + /* What state should this child_main process be listed as in the * scoreboard...? - * ap_update_child_status_from_indexes(my_child_num, i, SERVER_STARTING, + * ap_update_child_status_from_indexes(my_child_num, i, SERVER_STARTING, * (request_rec *) NULL); - * + * * This state should be listed separately in the scoreboard, in some kind - * of process_status, not mixed in with the worker threads' status. - * "life_status" is almost right, but it's in the worker's structure, and + * of process_status, not mixed in with the worker threads' status. + * "life_status" is almost right, but it's in the worker's structure, and * the name could be clearer. gla */ apr_thread_exit(thd, APR_SUCCESS); @@ -1165,7 +1165,7 @@ */ iter = 0; - while (iter < 10 && + while (iter < 10 && #ifdef HAVE_PTHREAD_KILL pthread_kill(*listener_os_thread, 0) #else @@ -1189,7 +1189,7 @@ } } } - + for (i = 0; i < ap_threads_per_child; i++) { if (threads[i]) { /* if we ever created this thread */ rv = apr_thread_join(&thread_rv, threads[i]); @@ -1207,8 +1207,8 @@ { apr_status_t rv, thread_rv; - start_thread_may_exit = 1; /* tell it to give up in case it is still - * trying to take over slots from a + start_thread_may_exit = 1; /* tell it to give up in case it is still + * trying to take over slots from a * previous generation */ rv = apr_thread_join(&thread_rv, start_thread_id); @@ -1271,13 +1271,13 @@ /* coding a value of zero means infinity */ requests_this_child = INT_MAX; } - + /* Setup worker threads */ - /* clear the storage; we may not create all our threads immediately, + /* clear the storage; we may not create all our threads immediately, * and we want a 0 entry to indicate a thread which was not created */ - threads = (apr_thread_t **)calloc(1, + threads = (apr_thread_t **)calloc(1, sizeof(apr_thread_t *) * ap_threads_per_child); if (threads == NULL) { ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf, @@ -1312,13 +1312,13 @@ } mpm_state = AP_MPMQ_RUNNING; - + /* If we are only running in one_process mode, we will want to * still handle signals. */ if (one_process) { /* Block until we get a terminating signal. */ apr_signal_thread(check_signal); - /* make sure the start thread has finished; signal_threads() + /* make sure the start thread has finished; signal_threads() * and join_workers() depend on that */ /* XXX join_start_thread() won't be awakened if one of our @@ -1361,7 +1361,7 @@ } } if (rv == AP_GRACEFUL || rv == AP_RESTART) { - /* make sure the start thread has finished; + /* make sure the start thread has finished; * signal_threads() and join_workers depend on that */ join_start_thread(start_thread_id); @@ -1387,7 +1387,7 @@ clean_child_exit(resource_shortage ? APEXIT_CHILDSICK : 0); } -static int make_child(server_rec *s, int slot) +static int make_child(server_rec *s, int slot) { int pid; @@ -1402,7 +1402,7 @@ } if ((pid = fork()) == -1) { - ap_log_error(APLOG_MARK, APLOG_ERR, errno, s, + ap_log_error(APLOG_MARK, APLOG_ERR, errno, s, "fork: Unable to fork new process"); /* fork didn't succeed. Fix the scoreboard or else @@ -1426,7 +1426,7 @@ int status = bindprocessor(BINDPROCESS, (int)getpid(), PROCESSOR_CLASS_ANY); if (status != OK) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, + ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "processor unbind failed %d", status); #endif @@ -1507,7 +1507,7 @@ status = ws->status; /* XXX any_dying_threads is probably no longer needed GLA */ - any_dying_threads = any_dying_threads || + any_dying_threads = any_dying_threads || (status == SERVER_GRACEFUL); any_dead_threads = any_dead_threads || (status == SERVER_DEAD); all_dead_threads = all_dead_threads && @@ -1523,19 +1523,19 @@ if (status <= SERVER_READY && status != SERVER_DEAD && !ps->quiescing && ps->generation == ap_my_generation && - /* XXX the following shouldn't be necessary if we clean up - * properly after seg faults, but we're not yet GLA - */ + /* XXX the following shouldn't be necessary if we clean up + * properly after seg faults, but we're not yet GLA + */ ps->pid != 0) { ++idle_thread_count; } } - if (any_dead_threads && totally_free_length < idle_spawn_rate + if (any_dead_threads && totally_free_length < idle_spawn_rate && (!ps->pid /* no process in the slot */ || ps->quiescing)) { /* or at least one is going away */ if (all_dead_threads) { /* great! we prefer these, because the new process can - * start more threads sooner. So prioritize this slot + * start more threads sooner. So prioritize this slot * by putting it ahead of any slots with active threads. * * first, make room by moving a slot that's potentially still @@ -1569,9 +1569,9 @@ if (free_length == 0) { /* only report this condition once */ static int reported = 0; - + if (!reported) { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, + ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, "server reached MaxClients setting, consider" " raising the MaxClients setting"); @@ -1584,7 +1584,7 @@ free_length = idle_spawn_rate; } if (idle_spawn_rate >= 8) { - ap_log_error(APLOG_MARK, APLOG_INFO, 0, + ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf, "server seems busy, (you may need " "to increase StartServers, ThreadsPerChild " @@ -1622,7 +1622,7 @@ while (!restart_pending && !shutdown_pending) { ap_wait_or_timeout(&exitwhy, &status, &pid, pconf); - + if (pid.pid != -1) { processed_status = ap_process_child_status(&pid, exitwhy, status); if (processed_status == APEXIT_CHILDFATAL) { @@ -1634,9 +1634,9 @@ child_slot = find_child_by_pid(&pid); if (child_slot >= 0) { for (i = 0; i < ap_threads_per_child; i++) - ap_update_child_status_from_indexes(child_slot, i, SERVER_DEAD, + ap_update_child_status_from_indexes(child_slot, i, SERVER_DEAD, (request_rec *) NULL); - + ap_scoreboard_image->parent[child_slot].pid = 0; ap_scoreboard_image->parent[child_slot].quiescing = 0; if (processed_status == APEXIT_CHILDSICK) { @@ -1707,13 +1707,13 @@ "ignored during restart"); changed_limit_at_restart = 0; } - + /* Initialize cross-process accept lock */ ap_lock_fname = apr_psprintf(_pconf, "%s.%" APR_PID_T_FMT, ap_server_root_relative(_pconf, ap_lock_fname), ap_my_pid); - rv = apr_proc_mutex_create(&accept_mutex, ap_lock_fname, + rv = apr_proc_mutex_create(&accept_mutex, ap_lock_fname, ap_accept_lock_mech, _pconf); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, @@ -1723,7 +1723,7 @@ } #if APR_USE_SYSVSEM_SERIALIZE - if (ap_accept_lock_mech == APR_LOCK_DEFAULT || + if (ap_accept_lock_mech == APR_LOCK_DEFAULT || ap_accept_lock_mech == APR_LOCK_SYSVSEM) { #else if (ap_accept_lock_mech == APR_LOCK_SYSVSEM) { @@ -1796,7 +1796,7 @@ if (shutdown_pending) { /* Time to gracefully shut down: * Kill child processes, tell them to call child_exit, etc... - * (By "gracefully" we don't mean graceful in the same sense as + * (By "gracefully" we don't mean graceful in the same sense as * "apachectl graceful" where we allow old connections to finish.) */ ap_mpm_pod_killpg(pod, ap_daemons_limit, FALSE); @@ -1811,7 +1811,7 @@ ap_server_conf, "removed PID file %s (pid=%ld)", pidfile, (long)getpid()); - + ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, "caught SIGTERM, shutting down"); } @@ -1832,21 +1832,21 @@ */ ++ap_my_generation; ap_scoreboard_image->global->running_generation = ap_my_generation; - + if (is_graceful) { ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, AP_SIG_GRACEFUL_STRING " received. Doing graceful restart"); /* wake up the children...time to die. But we'll have more soon */ ap_mpm_pod_killpg(pod, ap_daemons_limit, TRUE); - + /* This is mostly for debugging... so that we know what is still * gracefully dealing with existing request. */ - + } else { - /* Kill 'em all. Since the child acts the same on the parents SIGTERM + /* Kill 'em all. Since the child acts the same on the parents SIGTERM * and a SIGHUP, we may as well use the same signal, because some user * pthreads are stealing signals from us left and right. */ @@ -1893,7 +1893,7 @@ return OK; } -static int worker_pre_config(apr_pool_t *pconf, apr_pool_t *plog, +static int worker_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp) { static int restart_num = 0; @@ -1903,7 +1903,7 @@ apr_status_t rv; mpm_state = AP_MPMQ_STARTING; - + /* make sure that "ThreadsPerChild" gets set before "MaxClients" */ for (pdir = ap_conftree; pdir != NULL; pdir = pdir->next) { if (strncasecmp(pdir->directive, "ThreadsPerChild", 15) == 0) { @@ -1926,7 +1926,7 @@ 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; @@ -2005,7 +2005,7 @@ } static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, - const char *arg) + const char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { @@ -2026,15 +2026,15 @@ min_spare_threads = atoi(arg); if (min_spare_threads <= 0) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: detected MinSpareThreads set to non-positive."); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Resetting to 1 to avoid almost certain Apache failure."); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Please read the documentation."); min_spare_threads = 1; } - + return NULL; } @@ -2051,7 +2051,7 @@ } static const char *set_max_clients (cmd_parms *cmd, void *dummy, - const char *arg) + const char *arg) { int max_clients; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); @@ -2063,47 +2063,47 @@ * 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, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: MaxClients (%d) must be at least as large", max_clients); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " large as ThreadsPerChild (%d). Automatically", ap_threads_per_child); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 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, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: MaxClients (%d) is not an integer multiple", max_clients); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 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, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " for a maximum of %d child processes,", ap_daemons_limit); - max_clients = ap_daemons_limit * ap_threads_per_child; + max_clients = ap_daemons_limit * ap_threads_per_child; } if (ap_daemons_limit > server_limit) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: MaxClients of %d would require %d servers,", max_clients, ap_daemons_limit); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " and would exceed the ServerLimit value of %d.", server_limit); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " Automatically lowering MaxClients to %d. To increase,", server_limit * ap_threads_per_child); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " please see the ServerLimit directive."); ap_daemons_limit = server_limit; - } + } else if (ap_daemons_limit < 1) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: Require MaxClients > 0, setting to 1"); ap_daemons_limit = 1; } @@ -2111,7 +2111,7 @@ } static const char *set_threads_per_child (cmd_parms *cmd, void *dummy, - const char *arg) + const char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { @@ -2120,29 +2120,29 @@ ap_threads_per_child = atoi(arg); if (ap_threads_per_child > thread_limit) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: ThreadsPerChild of %d exceeds ThreadLimit " "value of %d", ap_threads_per_child, thread_limit); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "threads, lowering ThreadsPerChild to %d. To increase, please" " see the", thread_limit); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " ThreadLimit directive."); ap_threads_per_child = thread_limit; } else if (ap_threads_per_child < 1) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: Require ThreadsPerChild > 0, setting to 1"); ap_threads_per_child = 1; } return NULL; } -static const char *set_server_limit (cmd_parms *cmd, void *dummy, const char *arg) +static const char *set_server_limit (cmd_parms *cmd, void *dummy, const char *arg) { int tmp_server_limit; - + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { return err; @@ -2162,27 +2162,27 @@ return NULL; } server_limit = tmp_server_limit; - + if (server_limit > MAX_SERVER_LIMIT) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: ServerLimit of %d exceeds compile time limit " "of %d servers,", server_limit, MAX_SERVER_LIMIT); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " lowering ServerLimit to %d.", MAX_SERVER_LIMIT); server_limit = MAX_SERVER_LIMIT; - } + } else if (server_limit < 1) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: Require ServerLimit > 0, setting to 1"); server_limit = 1; } return NULL; } -static const char *set_thread_limit (cmd_parms *cmd, void *dummy, const char *arg) +static const char *set_thread_limit (cmd_parms *cmd, void *dummy, const char *arg) { int tmp_thread_limit; - + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { return err; @@ -2202,17 +2202,17 @@ return NULL; } thread_limit = tmp_thread_limit; - + if (thread_limit > MAX_THREAD_LIMIT) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: ThreadLimit of %d exceeds compile time limit " "of %d servers,", thread_limit, MAX_THREAD_LIMIT); - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, " lowering ThreadLimit to %d.", MAX_THREAD_LIMIT); thread_limit = MAX_THREAD_LIMIT; - } + } else if (thread_limit < 1) { - ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, + ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "WARNING: Require ThreadLimit > 0, setting to 1"); thread_limit = 1; }