httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject cvs commit: httpd-2.0/server/mpm/beos beos.c
Date Thu, 26 Jul 2001 18:24:59 GMT
dreid       01/07/26 11:24:59

  Modified:    server/mpm/beos beos.c
  Log:
  waitpid doesn't seem to be doing what it's supposed to, so in an attempt
  to allow the beos mpm to kill off it's workers and respawn them we'll
  now have them ask for a restart when exiting.  This was suggested by
  Bruno G Albuquerque <bga@bug-br.org.br>.
  
  Submitted by:	Bruno G Albuquerque <bga@bug-br.org.br>
  Reviewed by:	David Reid <dreid@apache.org>
  
  Revision  Changes    Path
  1.58      +21 -6     httpd-2.0/server/mpm/beos/beos.c
  
  Index: beos.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/beos/beos.c,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- beos.c	2001/07/20 10:09:43	1.57
  +++ beos.c	2001/07/26 18:24:58	1.58
  @@ -117,6 +117,8 @@
       apr_pool_t *tpool;
   } proc_info;
   
  +static void check_restart(void *data);
  +
   /*
    * The max child slot ever assigned, preserved across restarts.  Necessary
    * to deal with MaxClients changes across SIGWINCH restarts.  We use this
  @@ -337,7 +339,9 @@
       /* each worker thread is in control of it's own destiny...*/
       int this_worker_should_exit = 0; 
       free(ti);
  -      
  +
  +    on_exit_thread(check_restart, (void*)child_slot);
  +          
       /* block the signals for this thread */
       sigfillset(&sig_mask);
       sigprocmask(SIG_BLOCK, &sig_mask, NULL);
  @@ -462,7 +466,7 @@
       return (0);
   }
   
  -static int make_worker(server_rec *s, int slot)
  +static int make_worker(int slot)
   {
       thread_id tid;
       proc_info *my_info = (proc_info *)malloc(sizeof(proc_info)); /* freed by thread...
*/
  @@ -489,7 +493,7 @@
       tid = spawn_thread(worker_thread, "apache_worker", B_NORMAL_PRIORITY,
           my_info);
       if (tid < B_NO_ERROR) {
  -        ap_log_error(APLOG_MARK, APLOG_ERR, errno, s, 
  +        ap_log_error(APLOG_MARK, APLOG_ERR, errno, NULL, 
               "spawn_thread: Unable to start a new thread");
           /* In case system resources are maxxed out, we don't want
            * Apache running away with the CPU trying to fork over and
  @@ -509,6 +513,16 @@
       return 0;
   }
   
  +static void check_restart(void *data)
  +{
  +    if (!restart_pending && !shutdown_pending) {
  +        int slot = (int)data;
  +        make_worker(slot);
  +        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, NULL, 
  +            "spawning a new worker thread in slot %d", slot);
  +    }
  +}
  +
   /* start up a bunch of children */
   static void startup_threads(int number_to_start)
   {
  @@ -518,7 +532,7 @@
   	if (ap_scoreboard_image->servers[0][i].tid) {
   	    continue;
   	}
  -	if (make_worker(ap_server_conf, i) < 0) {
  +	if (make_worker(i) < 0) {
   	    break;
   	}
   	--number_to_start;
  @@ -567,7 +581,7 @@
   
       if (free_length > 0) {
       	for (i = 0; i < free_length; ++i) {
  -	        make_worker(ap_server_conf, free_slots[i]);
  +	        make_worker(free_slots[i]);
   	    }
   	    /* the next time around we want to spawn twice as many if this
   	     * wasn't good enough, but not if we've just done a graceful
  @@ -590,6 +604,7 @@
       int i;
   
       while (!restart_pending && !shutdown_pending) {
  +
           ap_wait_or_timeout(&status, &pid, pconf);
            
           if (pid.pid >= 0) {
  @@ -611,7 +626,7 @@
                       /* we're still doing a 1-for-1 replacement of dead
                        * children with new children
                        */
  -                    make_worker(ap_server_conf, child_slot);
  +                    make_worker(child_slot);
                       --remaining_threads_to_start;
   		        }
   #if APR_HAS_OTHER_CHILD
  
  
  

Mime
View raw message