httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: apache-2.0/src/modules/mpm/prefork prefork.c
Date Wed, 24 May 2000 00:42:01 GMT
rbb         00/05/23 17:42:01

  Modified:    src/include mpm_common.h
               src/main mpm_common.c
               src/modules/mpm/dexter dexter.c
               src/modules/mpm/mpmt_pthread mpmt_pthread.c
               src/modules/mpm/prefork prefork.c
  Log:
  Fix a memory leak with ap_wait_or_timeout.
  
  Revision  Changes    Path
  1.2       +1 -1      apache-2.0/src/include/mpm_common.h
  
  Index: mpm_common.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/mpm_common.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- mpm_common.h	2000/05/19 07:07:39	1.1
  +++ mpm_common.h	2000/05/24 00:41:58	1.2
  @@ -75,7 +75,7 @@
   #endif
   
   void ap_reclaim_child_processes(int terminate);
  -ap_proc_t *ap_wait_or_timeout(ap_wait_t *status, ap_pool_t *p);
  +void ap_wait_or_timeout(ap_wait_t *status, ap_proc_t *ret, ap_pool_t *p);
   
   #ifdef __cplusplus
   }
  
  
  
  1.8       +7 -6      apache-2.0/src/main/mpm_common.c
  
  Index: mpm_common.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/mpm_common.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- mpm_common.c	2000/05/23 23:32:35	1.7
  +++ mpm_common.c	2000/05/24 00:41:59	1.8
  @@ -176,11 +176,10 @@
   #endif
   static int wait_or_timeout_counter;
   
  -ap_proc_t *ap_wait_or_timeout(ap_wait_t *status, ap_pool_t *p)
  +void ap_wait_or_timeout(ap_wait_t *status, ap_proc_t *ret, ap_pool_t *p)
   {
       struct timeval tv;
       ap_status_t rv;
  -    ap_proc_t *ret = ap_pcalloc(p, sizeof(*ret));
   
       ++wait_or_timeout_counter;
       if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
  @@ -191,20 +190,22 @@
       }
       rv = ap_wait_all_procs(ret, status, APR_NOWAIT, p);
       if (ap_canonical_error(rv) == APR_EINTR) {
  -        return NULL;
  +        ret->pid = -1;
  +        return;
       }
       if (rv == APR_CHILD_DONE) {
  -        return ret;
  +        return;
       }
   #ifdef NEED_WAITPID
       if ((ret = reap_children(status)) > 0) {
  -        return ret;
  +        return;
       }
   #endif
       tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 1000000;
       tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 1000000;
       ap_select(0, NULL, NULL, NULL, &tv);
  -    return NULL;
  +    ret->pid = -1;
  +    return;
   }
   
   
  
  
  
  1.85      +7 -7      apache-2.0/src/modules/mpm/dexter/dexter.c
  
  Index: dexter.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/dexter/dexter.c,v
  retrieving revision 1.84
  retrieving revision 1.85
  diff -u -r1.84 -r1.85
  --- dexter.c	2000/05/23 21:27:34	1.84
  +++ dexter.c	2000/05/24 00:42:00	1.85
  @@ -974,19 +974,19 @@
   {
       int child_slot;
       ap_wait_t status;
  -    ap_proc_t *pid;
  +    ap_proc_t pid;
       int i;
   
       while (!restart_pending && !shutdown_pending) {
  -        pid = ap_wait_or_timeout(&status, pconf);
  +        ap_wait_or_timeout(&status, &pid, pconf);
           
  -        if (pid != NULL) {
  -            process_child_status(pid, status);
  +        if (pid.pid != -1) {
  +            process_child_status(&pid, status);
               /* non-fatal death... note that it's gone in the child table and
                * clean out the status table. */
               child_slot = -1;
               for (i = 0; i < ap_max_daemons_limit; ++i) {
  -        	if (ap_child_table[i].pid == pid->pid) {
  +        	if (ap_child_table[i].pid == pid.pid) {
                       int j;
   
                       child_slot = i;
  @@ -1009,7 +1009,7 @@
   		}
   #ifdef APR_HAS_OTHER_CHILD
   	    }
  -	    else if (ap_reap_other_child(pid, status) == 0) {
  +	    else if (ap_reap_other_child(&pid, status) == 0) {
   		/* handled */
   #endif
   	    }
  @@ -1021,7 +1021,7 @@
   		ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, errno, 
                                ap_server_conf,
   			    "long lost child came home! (pid %ld)", 
  -                             (long)pid->pid);
  +                             (long)pid.pid);
   	    }
   	    /* Don't perform idle maintenance when a child dies,
                * only do it when there's a timeout.  Remember only a
  
  
  
  1.77      +7 -8      apache-2.0/src/modules/mpm/mpmt_pthread/mpmt_pthread.c
  
  Index: mpmt_pthread.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- mpmt_pthread.c	2000/05/23 21:27:36	1.76
  +++ mpmt_pthread.c	2000/05/24 00:42:01	1.77
  @@ -1015,17 +1015,16 @@
   {
       int child_slot;
       ap_wait_t status;
  -    ap_proc_t *pid;
  +    ap_proc_t pid;
       int i;
   
       while (!restart_pending && !shutdown_pending) {
  -        /* this is a memory leak, but I'll fix it later. */
  -        pid = ap_wait_or_timeout(&status, pconf);
  +        ap_wait_or_timeout(&status, &pid, pconf);
           
  -        if (pid != NULL) {
  -            process_child_status(pid, status);
  +        if (pid.pid != -1) {
  +            process_child_status(&pid, status);
               /* non-fatal death... note that it's gone in the scoreboard. */
  -            child_slot = find_child_by_pid(pid);
  +            child_slot = find_child_by_pid(&pid);
               if (child_slot >= 0) {
                   ap_mpmt_pthread_force_reset_connection_status(child_slot);
                   for (i = 0; i < ap_threads_per_child; i++)
  @@ -1041,7 +1040,7 @@
   		}
   #ifdef APR_HAS_OTHER_CHILD
   	    }
  -	    else if (ap_reap_other_child(pid, status) == 0) {
  +	    else if (ap_reap_other_child(&pid, status) == 0) {
   		/* handled */
   #endif
   	    }
  @@ -1052,7 +1051,7 @@
   		ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0,
   		             ap_server_conf,
   		             "long lost child came home! (pid %ld)",
  -		             (long)pid->pid);
  +		             (long)pid.pid);
   	    }
   	    /* Don't perform idle maintenance when a child dies,
                * only do it when there's a timeout.  Remember only a
  
  
  
  1.90      +8 -6      apache-2.0/src/modules/mpm/prefork/prefork.c
  
  Index: prefork.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/prefork/prefork.c,v
  retrieving revision 1.89
  retrieving revision 1.90
  diff -u -r1.89 -r1.90
  --- prefork.c	2000/05/23 21:04:02	1.89
  +++ prefork.c	2000/05/24 00:42:01	1.90
  @@ -1956,17 +1956,19 @@
   	int child_slot;
   	ap_wait_t status;
           /* this is a memory leak, but I'll fix it later. */
  -	ap_proc_t *pid = ap_wait_or_timeout(&status, pconf);
  +	ap_proc_t pid;
   
  +        ap_wait_or_timeout(&status, &pid, pconf);
  +
   	/* XXX: if it takes longer than 1 second for all our children
   	 * to start up and get into IDLE state then we may spawn an
   	 * extra child
   	 */
  -	if (pid != NULL) {
  -	    process_child_status(pid, status);
  +	if (pid.pid != -1) {
  +	    process_child_status(&pid, status);
   	    /* non-fatal death... note that it's gone in the scoreboard. */
   	    ap_sync_scoreboard_image();
  -	    child_slot = find_child_by_pid(pid);
  +	    child_slot = find_child_by_pid(&pid);
   	    if (child_slot >= 0) {
                   ap_prefork_force_reset_connection_status(child_slot);
   		(void) ap_update_child_status(child_slot, SERVER_DEAD,
  @@ -1981,7 +1983,7 @@
   		}
   #ifdef APR_HAS_OTHER_CHILD
   	    }
  -	    else if (ap_reap_other_child(pid, status) == 0) {
  +	    else if (ap_reap_other_child(&pid, status) == 0) {
   		/* handled */
   #endif
   	    }
  @@ -1992,7 +1994,7 @@
   		    */
   		ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 
                               0, ap_server_conf,
  -			    "long lost child came home! (pid %d)", pid->pid);
  +			    "long lost child came home! (pid %d)", pid.pid);
   	    }
   	    /* Don't perform idle maintenance when a child dies,
   		* only do it when there's a timeout.  Remember only a
  
  
  

Mime
View raw message