]> granicus.if.org Git - apache/commitdiff
This patch allows the prefork MPM to print messages to the console if it
authorRyan Bloom <rbb@apache.org>
Mon, 4 Feb 2002 16:58:54 +0000 (16:58 +0000)
committerRyan Bloom <rbb@apache.org>
Mon, 4 Feb 2002 16:58:54 +0000 (16:58 +0000)
can't open a socket for some reason.

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

server/listen.c
server/main.c
server/mpm/prefork/prefork.c

index 55ce7c1cf8e107e4b98bd1d07c45f2ee591ba3bc..b94f3f10ac0ac993a5dc4e422141ecf04688d037 100644 (file)
@@ -142,7 +142,7 @@ static apr_status_t make_sock(apr_pool_t *p, ap_listen_rec *server)
 #endif
 
     if ((stat = apr_bind(s, server->bind_addr)) != APR_SUCCESS) {
-        ap_log_perror(APLOG_MARK, APLOG_CRIT, stat, p,
+        ap_log_perror(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT, stat, p,
                      "make_sock: could not bind to address %pI", 
                      server->bind_addr);
         apr_socket_close(s);
@@ -150,7 +150,7 @@ static apr_status_t make_sock(apr_pool_t *p, ap_listen_rec *server)
     }
 
     if ((stat = apr_listen(s, ap_listenbacklog)) != APR_SUCCESS) {
-        ap_log_perror(APLOG_MARK, APLOG_ERR, stat, p,
+        ap_log_perror(APLOG_MARK, APLOG_STARTUP|APLOG_ERR, stat, p,
             "make_sock: unable to listen for connections on address %pI", 
                      server->bind_addr);
         apr_socket_close(s);
index 763584e59c7fd3e81480f03dd81446cf8d62e221..d1874be81e9de6eac78c1a5aaf7b836079458c8a 100644 (file)
@@ -446,8 +446,11 @@ int main(int argc, const char * const argv[])
        destroy_and_exit_process(process, 0);
     }
     apr_pool_clear(plog);
+    /* It is assumed that if you are going to fail the open_logs phase, then
+     * you will print out your own message that explains what has gone wrong.
+     * The server doesn't need to do that for you.
+     */
     if ( ap_run_open_logs(pconf, plog, ptemp, server_conf) != OK) {
-        ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR| APLOG_NOERRNO, 0, NULL, "Unable to open logs\n");
         destroy_and_exit_process(process, 1);
     }
     if ( ap_run_post_config(pconf, plog, ptemp, server_conf) != OK) {
index 644f5ec17b6887281ff670012fd290d2c83a3a5e..1af99f9aa6c00cb4d9b36c9d6c0edf1c65fb25e5 100644 (file)
@@ -972,10 +972,7 @@ int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
 {
     int index;
     int remaining_children_to_start;
-    apr_status_t rv;
 
-    pconf = _pconf;
-    ap_server_conf = s;
     first_server_limit = server_limit;
     if (changed_limit_at_restart) {
         ap_log_error(APLOG_MARK, APLOG_WARNING | APLOG_NOERRNO, 0, s,
@@ -984,21 +981,6 @@ int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
         changed_limit_at_restart = 0;
     }
 
-    if ((num_listensocks = ap_setup_listeners(ap_server_conf)) < 1) {
-       /* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
-        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, 0, s,
-                     "no listening sockets available, shutting down");
-       return 1;
-    }
-
-    ap_log_pid(pconf, ap_pid_fname);
-
-    if ((rv = ap_mpm_pod_open(pconf, &pod))) {
-        ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
-               "Could not open pipe-of-death.");
-        return 1;
-    }
-
     SAFE_ACCEPT(accept_mutex_init(pconf));
     if (!is_graceful) {
         if (ap_run_pre_mpm(pconf, SB_SHARED) != OK) {
@@ -1200,6 +1182,33 @@ int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
     return 0;
 }
 
+
+/* 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 prefork_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
+{
+    apr_status_t rv;
+
+    pconf = p;
+    ap_server_conf = s;
+
+    if ((num_listensocks = 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;
+    }
+
+    ap_log_pid(pconf, ap_pid_fname);
+
+    if ((rv = ap_mpm_pod_open(pconf, &pod))) {
+        ap_log_error(APLOG_MARK, APLOG_CRIT|APLOG_STARTUP, rv, NULL,
+               "Could not open pipe-of-death.");
+        return DONE;
+    }
+    return OK;
+}
+
 static int prefork_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
 {
     static int restart_num = 0;
@@ -1251,10 +1260,14 @@ static int prefork_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp
 
 static void prefork_hooks(apr_pool_t *p)
 {
+    static const char *const aszSucc[] = {"core.c", NULL};
+
+
 #ifdef AUX3
     (void) set42sig();
 #endif
 
+    ap_hook_open_logs(prefork_open_logs, NULL, aszSucc, APR_HOOK_MIDDLE);
     ap_hook_pre_config(prefork_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
 }