You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@apache.org on 2002/02/04 17:58:54 UTC

cvs commit: httpd-2.0/server/mpm/prefork prefork.c

rbb         02/02/04 08:58:54

  Modified:    server   listen.c main.c
               server/mpm/prefork prefork.c
  Log:
  This patch allows the prefork MPM to print messages to the console if it
  can't open a socket for some reason.
  
  Revision  Changes    Path
  1.69      +2 -2      httpd-2.0/server/listen.c
  
  Index: listen.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/listen.c,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- listen.c	30 Jan 2002 12:32:07 -0000	1.68
  +++ listen.c	4 Feb 2002 16:58:54 -0000	1.69
  @@ -142,7 +142,7 @@
   #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 @@
       }
   
       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);
  
  
  
  1.117     +4 -1      httpd-2.0/server/main.c
  
  Index: main.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/main.c,v
  retrieving revision 1.116
  retrieving revision 1.117
  diff -u -r1.116 -r1.117
  --- main.c	28 Jan 2002 23:49:39 -0000	1.116
  +++ main.c	4 Feb 2002 16:58:54 -0000	1.117
  @@ -446,8 +446,11 @@
   	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) {
  
  
  
  1.238     +31 -18    httpd-2.0/server/mpm/prefork/prefork.c
  
  Index: prefork.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/prefork/prefork.c,v
  retrieving revision 1.237
  retrieving revision 1.238
  diff -u -r1.237 -r1.238
  --- prefork.c	1 Feb 2002 22:16:31 -0000	1.237
  +++ prefork.c	4 Feb 2002 16:58:54 -0000	1.238
  @@ -972,10 +972,7 @@
   {
       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 @@
           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 @@
       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 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);
   }