From: Ryan Bloom Date: Tue, 5 Feb 2002 01:13:37 +0000 (+0000) Subject: Port the listener bind patch from the Unix MPMs to Windows. This allows X-Git-Tag: 2.0.32~84 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1c8af1bea1b995ee0facda26bad3868d0a640446;p=apache Port the listener bind patch from the Unix MPMs to Windows. This allows ANy windows bind message to be printed to the console if the server was started from the command line. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93244 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index 9ecfcd99b3..bc1085f48c 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -2117,13 +2117,28 @@ static int winnt_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *pt return OK; } +/* This really should be a post_config hook, but the error log is already + * redirected by that point, so we need to do this in the open_logs phase. + */ +static int winnt_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) +{ + pconf = p; + ap_server_conf = s; + + if ((parent_pid == my_pid) || one_process) { + if (ap_setup_listeners(ap_server_conf) < 1) { + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT|APLOG_STARTUP, 0, + NULL, "no listening sockets available, shutting down"); + return DONE; + } + } + return OK; +} + AP_DECLARE(int) ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s ) { static int restart = 0; /* Default is "not a restart" */ - pconf = _pconf; - ap_server_conf = s; - if ((parent_pid != my_pid) || one_process) { /* Child process or in one_process (debug) mode */ ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, ap_server_conf, @@ -2134,9 +2149,6 @@ AP_DECLARE(int) ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s ) if (ap_run_pre_mpm(pconf, SB_SHARED) != OK) { return 1; } - if (ap_setup_listeners(ap_server_conf) < 1) { - return 1; - } } else { /* Set up the scoreboard. */ @@ -2181,12 +2193,6 @@ AP_DECLARE(int) ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s ) return 1; } - /* Parent process */ - if (ap_setup_listeners(ap_server_conf) < 1) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, s, - "no listening sockets available, shutting down"); - return 1; - } if (!set_listeners_noninheritable(pconf)) { return 1; } @@ -2215,9 +2221,16 @@ AP_DECLARE(int) ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s ) static void winnt_hooks(apr_pool_t *p) { + /* The prefork open_logs phase must run before the core's, or stderr + * will be redirected to a file, and the messages won't print to the + * console. + */ + static const char *const aszSucc[] = {"core.c", NULL}; + ap_hook_pre_config(winnt_pre_config, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_post_config(winnt_post_config, NULL, NULL, 0); ap_hook_child_init(winnt_child_init, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_open_logs(winnt_open_logs, NULL, aszSucc, APR_HOOK_MIDDLE); } /*