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 Fri, 12 Mar 2004 01:39:54 GMT
dreid       2004/03/11 17:39:54

  Modified:    server/mpm/beos beos.c
  Log:
  Better handling of ONE_PROCESS.
  Fix restarts and shutdowns so we no longer segfault.
  
  Revision  Changes    Path
  1.109     +24 -14    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.108
  retrieving revision 1.109
  diff -u -r1.108 -r1.109
  --- beos.c	10 Mar 2004 22:38:46 -0000	1.108
  +++ beos.c	12 Mar 2004 01:39:54 -0000	1.109
  @@ -135,11 +135,17 @@
   int raise_sigstop_flags;
   #endif
   
  -/* a clean exit from a child with proper cleanup */
  -static void clean_child_exit(int code)
  +/* When a worker thread gets to the end of it's life it dies with an
  + * exit value of the code supplied to this function. The thread has
  + * already had check_restart() registered to be called when dying, so
  + * we don't concern ourselves with restarting at all here. We do however
  + * mark the scoreboard slot as belonging to a dead server.
  + */
  +static void clean_child_exit(int code, int slot)
   {
  -	mpm_state = AP_MPMQ_STOPPING;
  -    exit(code);
  +    (void) ap_update_child_status_from_indexes(0, slot, SERVER_DEAD, 
  +                                               (request_rec*)NULL);
  +    exit_thread(code);
   }
   
   
  @@ -405,7 +411,7 @@
   /* This is the thread that actually does all the work. */
   static int32 worker_thread(void *dummy)
   {
  -    int worker_slot = *(int *)dummy;
  +    int worker_slot = (int)dummy;
       apr_allocator_t *allocator;
       apr_bucket_alloc_t *bucket_alloc;
       apr_status_t rv = APR_EINIT;
  @@ -433,9 +439,13 @@
   
       on_exit_thread(check_restart, (void*)worker_slot);
             
  -    /* block the signals for this thread */
  -    sigfillset(&sig_mask);
  -    sigprocmask(SIG_BLOCK, &sig_mask, NULL);
  +    /* block the signals for this thread only if we're not running as a
  +     * single process.
  +     */
  +    if (!one_process) {
  +        sigfillset(&sig_mask);
  +        sigprocmask(SIG_BLOCK, &sig_mask, NULL);
  +    }
   
       /* Each worker thread is fully in control of it's destinay and so
        * to allow each thread to handle the lifetime of it's own resources
  @@ -496,7 +506,7 @@
   
           if ((ap_max_requests_per_child > 0 
                && requests_this_child++ >= ap_max_requests_per_child))
  -            clean_child_exit(0);
  +            clean_child_exit(0, worker_slot);
   
           (void) ap_update_child_status(sbh, SERVER_READY, (request_rec *) NULL);
           
  @@ -519,7 +529,7 @@
                   }
                   ap_log_error(APLOG_MARK, APLOG_ERR, rv,
                                ap_server_conf, "apr_pollset_poll: (listen)");
  -    	        clean_child_exit(1);
  +    	        clean_child_exit(1, worker_slot);
               }
               /* We can always use pdesc[0], but sockets at position N
                * could end up completely starved of attention in a very
  @@ -570,7 +580,7 @@
   
           if (rv == APR_EGENERAL) {
               /* resource shortage or should-not-occur occured */
  -            clean_child_exit(1);
  +            clean_child_exit(1, worker_slot);
           } else if (rv != APR_SUCCESS)
               continue;
   
  @@ -598,7 +608,7 @@
      	apr_pool_destroy(ptrans);
       apr_pool_destroy(pworker);
       	
  -    clean_child_exit(0);
  +    clean_child_exit(0, worker_slot);
   }
   
   static int make_worker(int slot)
  @@ -618,7 +628,7 @@
       }
   
       tid = spawn_thread(worker_thread, "apache_worker", B_NORMAL_PRIORITY,
  -                       (void *)&slot);
  +                       (void *)slot);
       if (tid < B_NO_ERROR) {
           ap_log_error(APLOG_MARK, APLOG_ERR, errno, NULL, 
               "spawn_thread: Unable to start a new thread");
  @@ -961,7 +971,7 @@
           tell_workers_to_exit();
           snooze(1000000);
       } else {
  -        worker_thread((void*)NULL);
  +        worker_thread((void*)0);
       }
           
       /* close the UDP socket we've been using... */
  
  
  

Mime
View raw message