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 Wed, 18 Jul 2001 21:16:40 GMT
gregames    01/07/18 14:16:40

  Modified:    include  mpm_common.h
               server   mpm_common.c
  Log:
  fix memory leak of apr_sockaddr_t and apr_socket_t in ap_mpm_pod_signal,
  called by perform_idle_server_maintenance.
  
  allocate & init one apr_sockaddr_t for the dummy connect at pod open time.
  use a temporary subpool for the apr_socket_t
  
  Revision  Changes    Path
  1.22      +1 -0      httpd-2.0/include/mpm_common.h
  
  Index: mpm_common.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/mpm_common.h,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- mpm_common.h	2001/06/07 00:09:15	1.21
  +++ mpm_common.h	2001/07/18 21:16:40	1.22
  @@ -172,6 +172,7 @@
       apr_file_t *pod_in;
       apr_file_t *pod_out;
       apr_pool_t *p;
  +    apr_sockaddr_t *sa;
   };
   
   /**
  
  
  
  1.59      +18 -5     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.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- mpm_common.c	2001/07/18 20:28:59	1.58
  +++ mpm_common.c	2001/07/18 21:16:40	1.59
  @@ -347,9 +347,15 @@
   
       *pod = apr_palloc(p, sizeof(**pod));
       rv = apr_file_pipe_create(&((*pod)->pod_in), &((*pod)->pod_out), p);
  +    if (rv != APR_SUCCESS) {
  +        return rv;
  +    }
       apr_file_pipe_timeout_set((*pod)->pod_in, 0);
       (*pod)->p = p;
  -    return rv;
  +    
  +    apr_sockaddr_info_get(&(*pod)->sa, "127.0.0.1", APR_UNSPEC, ap_listeners->bind_addr->port,
0, p);
  +
  +    return APR_SUCCESS;
   }
   
   AP_DECLARE(apr_status_t) ap_mpm_pod_check(ap_pod_t *pod)
  @@ -388,10 +394,10 @@
   AP_DECLARE(apr_status_t) ap_mpm_pod_signal(ap_pod_t *pod)
   {
       apr_socket_t *sock;
  -    apr_sockaddr_t *sa;
       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);
  @@ -401,9 +407,14 @@
                        "write pipe_of_death");
           return rv;
       }
  +
  +    /* create a temporary pool for the socket.  pconf stays around too long */
  +    rv = apr_pool_create(&p, pod->p);
  +    if (rv != APR_SUCCESS) {
  +        return rv;
  +    }
       
  -    apr_sockaddr_info_get(&sa, "127.0.0.1", APR_UNSPEC, ap_listeners->bind_addr->port,
0, pod->p);
  -    rv = apr_socket_create(&sock, sa->family, SOCK_STREAM, pod->p);
  +    rv = apr_socket_create(&sock, pod->sa->family, SOCK_STREAM, p);
       if (rv != APR_SUCCESS) {
           ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf,
                        "get socket to connect to listener");
  @@ -421,7 +432,8 @@
                        "set timeout on socket to connect to listener");
           return rv;
       }
  -    rv = apr_connect(sock, sa);    
  +    
  +    rv = apr_connect(sock, pod->sa);    
       if (rv != APR_SUCCESS) {
           int log_level = APLOG_WARNING;
   
  @@ -438,6 +450,7 @@
           return rv;
       }
       apr_socket_close(sock);
  +    apr_pool_destroy(p);
   
       return APR_SUCCESS;
   }
  
  
  

Mime
View raw message