httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grega...@apache.org
Subject cvs commit: httpd-2.0/server mpm_common.c
Date Mon, 10 Dec 2001 20:10:05 GMT
gregames    01/12/10 12:10:05

  Modified:    server   mpm_common.c
  Log:
  fix a problem with graceful restart.  If you look at daedalus early in the
  morning, you will usually see lots ( >50 ) of old generation processes
  happily serving requests with yesterday's config.  Late in the afternoon, they
  are usually gone due to MaxRequestsPerChild and perform_idle_server_maintenance.
  
  ap_mpm_pod_signal can time out during connect(), causing it to exit with an
  error.  If it was called by ap_mpm_pod_killpg during graceful restart,
  ap_mpm_pod_killpg will exit immediately.  This can cause us to not write
  enough characters to the pod to kill off all the old generation children.
  
  This fix decouples the loop which writes to the pod from the loop which
  generates dummy connect()s.  The connect()s aren't as important as
  writing to the pod when there is a steady stream of inbound connections.
  
  also, close the socket and destroy the temporary pool if the connect()
  fails.
  
  Revision  Changes    Path
  1.74      +34 -7     httpd-2.0/server/mpm_common.c
  
  Index: mpm_common.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm_common.c,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- mpm_common.c	2001/12/04 01:04:17	1.73
  +++ mpm_common.c	2001/12/10 20:10:05	1.74
  @@ -410,13 +410,11 @@
       return rv;
   }
   
  -AP_DECLARE(apr_status_t) ap_mpm_pod_signal(ap_pod_t *pod)
  +static apr_status_t pod_signal_internal(ap_pod_t *pod)
   {
  -    apr_socket_t *sock;
       apr_status_t rv;
       char char_of_death = '!';
       apr_size_t one = 1;
  -    apr_pool_t *p;
   
       do {
           rv = apr_file_write(pod->pod_out, &char_of_death, &one);
  @@ -424,9 +422,22 @@
       if (rv != APR_SUCCESS) {
           ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf,
                        "write pipe_of_death");
  -        return rv;
       }
  +    return rv;
  +}
  +
  +/* This function connects to the server, then immediately closes the connection.
  + * This permits the MPM to skip the poll when there is only one listening
  + * socket, because it provides a alternate way to unblock an accept() when
  + * the pod is used.
  + */
   
  +static apr_status_t dummy_connection(ap_pod_t *pod)
  +{
  +    apr_status_t rv;
  +    apr_socket_t *sock;
  +    apr_pool_t *p;
  +    
       /* create a temporary pool for the socket.  pconf stays around too long */
       rv = apr_pool_create(&p, pod->p);
       if (rv != APR_SUCCESS) {
  @@ -466,12 +477,23 @@
   	
           ap_log_error(APLOG_MARK, log_level, rv, ap_server_conf,
                        "connect to listener");
  -        return rv;
       }
  +
       apr_socket_close(sock);
       apr_pool_destroy(p);
  +
  +    return rv;
  +}
  +
  +AP_DECLARE(apr_status_t) ap_mpm_pod_signal(ap_pod_t *pod)
  +{
  +    apr_status_t rv;
   
  -    return APR_SUCCESS;
  +    rv = pod_signal_internal(pod);
  +    if (rv != APR_SUCCESS) {
  +        return rv;
  +    }
  +    return dummy_connection(pod);
   }
   
   void ap_mpm_pod_killpg(ap_pod_t *pod, int num)
  @@ -480,7 +502,12 @@
       apr_status_t rv = APR_SUCCESS;
   
       for (i = 0; i < num && rv == APR_SUCCESS; i++) {
  -        rv = ap_mpm_pod_signal(pod);
  +        rv = pod_signal_internal(pod);
  +    }
  +    if (rv == APR_SUCCESS) {
  +        for (i = 0; i < num && rv == APR_SUCCESS; i++) {
  +             rv = dummy_connection(pod);
  +        }
       }
   }
   #endif /* #ifdef AP_MPM_USES_POD */
  
  
  

Mime
View raw message