httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aa...@apache.org
Subject cvs commit: httpd-2.0/server/mpm/worker worker.c
Date Thu, 14 Feb 2002 02:48:19 GMT
aaron       02/02/13 18:48:19

  Modified:    server/mpm/worker worker.c
  Log:
  Retain signal handling in the worker MPM for the one_process case
  (httpd with -DDEBUG, -X, or -DONE_PROCESS).
  
  Fix -X, -DNO_DETACH, -DONE_PROCESS, etc. flags.
  
  Tested on solaris w/ start/stop, restart, graceful, and with the
  above debugging flags.
  
  Revision  Changes    Path
  1.76      +63 -20    httpd-2.0/server/mpm/worker/worker.c
  
  Index: worker.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/worker/worker.c,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- worker.c	13 Feb 2002 04:49:55 -0000	1.75
  +++ worker.c	14 Feb 2002 02:48:19 -0000	1.76
  @@ -680,6 +680,12 @@
               apr_pool_tag(ptrans, "transaction");
               rv = lr->accept_func(&csd, lr, ptrans);
   
  +            /* If we were interrupted for whatever reason, just start
  +             * the main loop over again. (The worker MPM still uses
  +             * signals in the one_process case.) */
  +            if (APR_STATUS_IS_EINTR(rv)) {
  +                continue;
  +            }
               if (rv == APR_EGENERAL) {
                   /* E[NM]FILE, ENOMEM, etc */
                   resource_shortage = 1;
  @@ -770,6 +776,16 @@
       return NULL;
   }
   
  +static int check_signal(int signum)
  +{
  +    switch (signum) {
  +    case SIGTERM:
  +    case SIGINT:
  +        return 1;
  +    }
  +    return 0;
  +}
  +
   static void * APR_THREAD_FUNC start_threads(apr_thread_t *thd, void *dummy)
   {
       thread_starter *ts = dummy;
  @@ -951,22 +967,21 @@
           clean_child_exit(APEXIT_CHILDFATAL);
       }
   
  -    /* Watch for any messages from the parent over the POD */
  -    while (1) {
  -        rv = ap_mpm_pod_check(pod);
  -        if (rv == AP_GRACEFUL || rv == AP_RESTART) {
  -            signal_workers();
  -            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).
  +    /* If we are only running in one_process mode, we will want to
  +     * still handle signals. */
  +    if (one_process) {
  +        /* Set up a signal handler for this thread. */
  +        apr_signal_thread(check_signal);
  +        signal_workers(); /* helps us terminate a little more quickly when
  +                           * the dispatch of the signal thread
  +                           * beats the Pipe of Death and the browsers
  +                           */
  +        /* 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).
            */
           apr_thread_join(&rv, start_thread_id);
           for (i = 0; i < ap_threads_per_child; i++) {
  @@ -975,6 +990,32 @@
               }
           }
       }
  +    else { /* !one_process */
  +        /* Watch for any messages from the parent over the POD */
  +        while (1) {
  +            rv = ap_mpm_pod_check(pod);
  +            if (rv == AP_GRACEFUL || rv == AP_RESTART) {
  +                signal_workers();
  +                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).
  +             */
  +            apr_thread_join(&rv, start_thread_id);
  +            for (i = 0; i < ap_threads_per_child; i++) {
  +                if (threads[i]) { /* if we ever created this thread */
  +                    apr_thread_join(&rv, threads[i]);
  +                }
  +            }
  +        }
  +    }
   
       free(threads);
   
  @@ -1453,10 +1494,12 @@
           return DONE;
       }
   
  -    if ((rv = ap_mpm_pod_open(pconf, &pod))) {
  -        ap_log_error(APLOG_MARK, APLOG_CRIT|APLOG_STARTUP, rv, NULL,
  -                "Could not open pipe-of-death.");
  -        return DONE;
  +    if (!one_process) {
  +        if ((rv = ap_mpm_pod_open(pconf, &pod))) {
  +            ap_log_error(APLOG_MARK, APLOG_CRIT|APLOG_STARTUP, rv, NULL,
  +                    "Could not open pipe-of-death.");
  +            return DONE;
  +        }
       }
       return OK;
   }
  
  
  

Mime
View raw message