httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject cvs commit: httpd-2.0/server/mpm/experimental/leader leader.c
Date Wed, 22 May 2002 05:49:34 GMT
brianp      02/05/21 22:49:34

  Modified:    server/mpm/experimental/leader leader.c
  Log:
  Complete the shutdown and restart fixes
  
  Revision  Changes    Path
  1.19      +21 -40    httpd-2.0/server/mpm/experimental/leader/leader.c
  
  Index: leader.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/experimental/leader/leader.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- leader.c	22 May 2002 01:04:59 -0000	1.18
  +++ leader.c	22 May 2002 05:49:34 -0000	1.19
  @@ -388,6 +388,9 @@
       if ((rv = apr_thread_mutex_lock(stack->mutex)) != APR_SUCCESS) {
           return rv;
       }
  +    if (stack->terminated) {
  +        return apr_thread_mutex_unlock(stack->mutex);
  +    }
       stack->terminated = 1;
       while (stack->nelts) {
           worker_wakeup_info *wakeup = stack->stack[--stack->nelts];
  @@ -572,6 +575,16 @@
   
   static void sig_term(int sig)
   {
  +    if (ap_my_pid == parent_pid) {
  +        ap_start_shutdown();
  +    }
  +    else {
  +        signal_threads(ST_GRACEFUL);
  +    }
  +}
  +
  +static void child_sig_term(int sig)
  +{
       ap_start_shutdown();
   }
   
  @@ -940,7 +953,9 @@
                   apr_pool_clear(ptrans);
                   requests_this_child--;
               }
  -            if (ap_mpm_pod_check(pod) == APR_SUCCESS) { /* selected as idle? */
  +            if ((ap_mpm_pod_check(pod) == APR_SUCCESS) ||
  +                (ap_my_generation !=
  +                 ap_scoreboard_image->global->running_generation)) {
                   signal_threads(ST_GRACEFUL);
                   break;
               }
  @@ -960,6 +975,8 @@
       dying = 1;
       ap_scoreboard_image->parent[process_slot].quiescing = 1;
   
  +    worker_stack_term(idle_worker_stack);
  +
       ap_update_child_status_from_indexes(process_slot, thread_slot,
           (dying) ? SERVER_DEAD : SERVER_GRACEFUL, (request_rec *) NULL);
   
  @@ -1224,46 +1241,8 @@
            * (e.g., for MaxRequestsPerChild) it will send us SIGTERM
            */
           unblock_signal(SIGTERM);
  -        apr_signal(SIGTERM, dummy_signal_handler);
  -#if 0
  -        /* Watch for any messages from the parent over the POD */
  -        while (1) {
  -            rv = ap_mpm_pod_check(pod);
  -            if (rv == AP_NORESTART) {
  -                /* see if termination was triggered while we slept */
  -                switch(terminate_mode) {
  -                case ST_GRACEFUL:
  -                    rv = AP_GRACEFUL;
  -                    break;
  -                case ST_UNGRACEFUL:
  -                    rv = AP_RESTART;
  -                    break;
  -                }
  -            }
  -            if (rv == AP_GRACEFUL || rv == AP_RESTART) {
  -                /* make sure the start thread has finished; 
  -                 * signal_threads() and join_workers depend on that
  -                 */
  -                join_start_thread(start_thread_id);
  -                signal_threads(rv == AP_GRACEFUL ? ST_GRACEFUL : ST_UNGRACEFUL);
  -                break;
  -            }
  -        }
  -
  -        if (rv == AP_GRACEFUL) {
  -            /* A terminating signal was received. Now join each of the
  -             * workers to clean them up.
  -             *   If the worker already exited, then the join frees
  -             *   their resources and returns.
  -             *   If the worker hasn't exited, then this blocks until
  -             *   they have (then cleans up).
  -             */
  -            join_workers(threads);
  -        }
  -#else
           join_start_thread(start_thread_id);
           join_workers(threads);
  -#endif /* 0 */
       }
   
       free(threads);
  @@ -1675,7 +1654,9 @@
            * (By "gracefully" we don't mean graceful in the same sense as 
            * "apachectl graceful" where we allow old connections to finish.)
            */
  -        ap_mpm_pod_killpg(pod, ap_daemons_limit);
  +	if (unixd_killpg(getpgrp(), SIGTERM) < 0) {
  +	    ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "killpg SIGTERM");
  +	}
           ap_reclaim_child_processes(1);                /* Start with SIGTERM */
   
           if (!child_fatal) {
  
  
  

Mime
View raw message