httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: httpd-2.0/server/mpm/worker worker.c
Date Sat, 27 Dec 2003 13:18:57 GMT
trawick     2003/12/27 05:18:57

  Modified:    .        Tag: APACHE_2_0_BRANCH CHANGES STATUS
               include  Tag: APACHE_2_0_BRANCH ap_mpm.h
               server/mpm/experimental/leader Tag: APACHE_2_0_BRANCH
                        leader.c
               server/mpm/experimental/threadpool Tag: APACHE_2_0_BRANCH
                        threadpool.c
               server/mpm/netware Tag: APACHE_2_0_BRANCH mpm_netware.c
               server/mpm/prefork Tag: APACHE_2_0_BRANCH prefork.c
               server/mpm/worker Tag: APACHE_2_0_BRANCH worker.c
  Log:
  Add AP_MPMQ_MPM_STATE function code for ap_mpm_query.
  
  (not currently supported for Win32, BeOS, or OS/2 MPMs)
  
  Submitted by:	Jeff Trawick, Brad Nicholes
  Reviewed by:	stoddard, jerenkrantz
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.988.2.208 +4 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.988.2.207
  retrieving revision 1.988.2.208
  diff -u -r1.988.2.207 -r1.988.2.208
  --- CHANGES	27 Dec 2003 12:00:42 -0000	1.988.2.207
  +++ CHANGES	27 Dec 2003 13:18:55 -0000	1.988.2.208
  @@ -1,5 +1,9 @@
   Changes with Apache 2.0.49
   
  +  *) Add AP_MPMQ_MPM_STATE function code for ap_mpm_query. (Not yet
  +     supported for BeOS, OS/2, or Win32 MPMs.)  [Jeff Trawick,
  +     Brad Nicholes]
  +
     *) Add mod_status hook to allow modules to add to the mod_status
        report.  [Joe Orton]
   
  
  
  
  1.751.2.612 +3 -11     httpd-2.0/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/STATUS,v
  retrieving revision 1.751.2.611
  retrieving revision 1.751.2.612
  diff -u -r1.751.2.611 -r1.751.2.612
  --- STATUS	27 Dec 2003 12:11:37 -0000	1.751.2.611
  +++ STATUS	27 Dec 2003 13:18:56 -0000	1.751.2.612
  @@ -162,18 +162,10 @@
         modules/metadata/mod_expires.c r1.45
         +1: ken, stoddard, rederpj
   
  -    * PREREQ for a couple of fixes (mod_cgid daemon restart, stranded
  -      piped logger processes) - ap_mpm_query(AP_MPMQ_MPM_STATE)
  +    * PREREQ for another fix (stranded piped logger processes) - 
  +      ap_mpm_query(AP_MPMQ_MPM_STATE)
         No updates are available at present for the BeOS or OS/2 MPMs,
         but that is not a showstopper for the other changes.
  -
  -        include/ap_mpm.h r1.36
  -        server/mpm/prefork/prefork.c r1.284
  -        server/mpm/worker/worker.c r1.142,r1.143
  -        server/mpm/experimental/leader/leader.c r1.35
  -        server/mpm/experimental/threadpool/threadpool.c r1.23
  -        server/mpm/netware/mpm_netware.c r1.78
  -      +1: trawick, stoddard, jerenkrantz
   
           server/mpm/winnt/mpm_winnt.c r1.303
           server/mpm/winnt/mpm_winnt.h r1.44
  
  
  
  No                   revision
  No                   revision
  1.33.2.2  +6 -1      httpd-2.0/include/ap_mpm.h
  
  Index: ap_mpm.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/ap_mpm.h,v
  retrieving revision 1.33.2.1
  retrieving revision 1.33.2.2
  diff -u -r1.33.2.1 -r1.33.2.2
  --- ap_mpm.h	3 Feb 2003 17:31:29 -0000	1.33.2.1
  +++ ap_mpm.h	27 Dec 2003 13:18:56 -0000	1.33.2.2
  @@ -160,6 +160,11 @@
                                         /* an MPM is using a dynamic #  */
                                         /* threads or daemons.          */
   
  +/* Values returned for AP_MPMQ_MPM_STATE */
  +#define AP_MPMQ_STARTING              0
  +#define AP_MPMQ_RUNNING               1
  +#define AP_MPMQ_STOPPING              2
  +
   #define AP_MPMQ_MAX_DAEMON_USED       1  /* Max # of daemons used so far */
   #define AP_MPMQ_IS_THREADED           2  /* MPM can do threading         */
   #define AP_MPMQ_IS_FORKED             3  /* MPM can do forking           */
  @@ -172,7 +177,7 @@
   #define AP_MPMQ_MAX_SPARE_THREADS    10  /* Max # of spare threads       */
   #define AP_MPMQ_MAX_REQUESTS_DAEMON  11  /* Max # of requests per daemon */
   #define AP_MPMQ_MAX_DAEMONS          12  /* Max # of daemons by config   */
  -
  +#define AP_MPMQ_MPM_STATE            13  /* starting, running, stopping  */
   
   /**
    * Query a property of the current MPM.  
  
  
  
  No                   revision
  No                   revision
  1.26.2.4  +25 -2     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.26.2.3
  retrieving revision 1.26.2.4
  diff -u -r1.26.2.3 -r1.26.2.4
  --- leader.c	5 Sep 2003 21:26:56 -0000	1.26.2.3
  +++ leader.c	27 Dec 2003 13:18:56 -0000	1.26.2.4
  @@ -166,6 +166,7 @@
   static int requests_this_child;
   static int num_listensocks = 0;
   static int resource_shortage = 0;
  +static int mpm_state = AP_MPMQ_STARTING;
   
   typedef struct worker_wakeup_info worker_wakeup_info;
   
  @@ -400,6 +401,7 @@
           return;
       }
       terminate_mode = mode;
  +    mpm_state = AP_MPMQ_STOPPING;
       workers_may_exit = 1;
   
       worker_stack_term(idle_worker_stack);
  @@ -444,6 +446,9 @@
           case AP_MPMQ_MAX_DAEMONS:
               *result = ap_daemons_limit;
               return APR_SUCCESS;
  +        case AP_MPMQ_MPM_STATE:
  +            *result = mpm_state;
  +            return APR_SUCCESS;
       }
       return APR_ENOTIMPL;
   }
  @@ -452,6 +457,7 @@
   static void clean_child_exit(int code) __attribute__ ((noreturn));
   static void clean_child_exit(int code)
   {
  +    mpm_state = AP_MPMQ_STOPPING;
       if (pchild) {
           apr_pool_destroy(pchild);
       }
  @@ -523,6 +529,7 @@
   
   static void ap_start_shutdown(void)
   {
  +    mpm_state = AP_MPMQ_STOPPING;
       if (shutdown_pending == 1) {
           /* Um, is this _probably_ not an error, if the user has
            * tried to do a shutdown twice quickly, so we won't
  @@ -536,7 +543,7 @@
   /* do a graceful restart if graceful == 1 */
   static void ap_start_restart(int graceful)
   {
  -
  +    mpm_state = AP_MPMQ_STOPPING;
       if (restart_pending == 1) {
           /* Probably not an error - don't bother reporting it */
           return;
  @@ -1104,6 +1111,10 @@
       apr_threadattr_t *thread_attr;
       apr_thread_t *start_thread_id;
   
  +    mpm_state = AP_MPMQ_STARTING; /* for benefit of any hooks that run as this
  +                                  * child initializes
  +                                  */
  +
       ap_my_pid = getpid();
       apr_pool_create(&pchild, pconf);
   
  @@ -1180,6 +1191,8 @@
           clean_child_exit(APEXIT_CHILDFATAL);
       }
   
  +    mpm_state = AP_MPMQ_RUNNING;
  +
       /* If we are only running in one_process mode, we will want to
        * still handle signals. */
       if (one_process) {
  @@ -1551,6 +1564,7 @@
       if (rv != APR_SUCCESS) {
           ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
                        "Couldn't create accept lock");
  +        mpm_state = AP_MPMQ_STOPPING;
           return 1;
       }
   
  @@ -1565,12 +1579,14 @@
               ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
                            "Couldn't set permissions on cross-process lock; "
                            "check User and Group directives");
  +            mpm_state = AP_MPMQ_STOPPING;
               return 1;
           }
       }
   
       if (!is_graceful) {
           if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
  +            mpm_state = AP_MPMQ_STOPPING;
               return 1;
           }
           /* fix the generation number in the global score; we just got a new,
  @@ -1618,8 +1634,10 @@
   		apr_proc_mutex_defname());
   #endif
       restart_pending = shutdown_pending = 0;
  +    mpm_state = AP_MPMQ_RUNNING;
   
       server_main_loop(remaining_children_to_start);
  +    mpm_state = AP_MPMQ_STOPPING;
   
       if (shutdown_pending) {
           /* Time to gracefully shut down:
  @@ -1725,6 +1743,8 @@
       ap_directive_t *max_clients = NULL;
       apr_status_t rv;
   
  +    mpm_state = AP_MPMQ_STARTING;
  +
       /* make sure that "ThreadsPerChild" gets set before "MaxClients" */
       for (pdir = ap_conftree; pdir != NULL; pdir = pdir->next) {
           if (strncasecmp(pdir->directive, "ThreadsPerChild", 15) == 0) {
  @@ -1819,7 +1839,10 @@
       one_process = 0;
   
       ap_hook_open_logs(leader_open_logs, NULL, aszSucc, APR_HOOK_MIDDLE);
  -    ap_hook_pre_config(leader_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
  +    /* we need to set the MPM state before other pre-config hooks use MPM query
  +     * to retrieve it, so register as REALLY_FIRST
  +     */
  +    ap_hook_pre_config(leader_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST);
   }
   
   static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy,
  
  
  
  No                   revision
  No                   revision
  1.14.2.5  +24 -2     httpd-2.0/server/mpm/experimental/threadpool/threadpool.c
  
  Index: threadpool.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/experimental/threadpool/threadpool.c,v
  retrieving revision 1.14.2.4
  retrieving revision 1.14.2.5
  diff -u -r1.14.2.4 -r1.14.2.5
  --- threadpool.c	5 Sep 2003 21:26:57 -0000	1.14.2.4
  +++ threadpool.c	27 Dec 2003 13:18:56 -0000	1.14.2.5
  @@ -173,6 +173,7 @@
   static int requests_this_child;
   static int num_listensocks = 0;
   static int resource_shortage = 0;
  +static int mpm_state = AP_MPMQ_STARTING;
   
   /* The structure used to pass unique initialization info to each thread */
   typedef struct {
  @@ -466,6 +467,7 @@
           return;
       }
       terminate_mode = mode;
  +    mpm_state = AP_MPMQ_STOPPING;
   
       /* in case we weren't called from the listener thread, wake up the
        * listener thread
  @@ -521,6 +523,9 @@
           case AP_MPMQ_MAX_DAEMONS:
               *result = ap_daemons_limit;
               return APR_SUCCESS;
  +        case AP_MPMQ_MPM_STATE:
  +            *result = mpm_state;
  +            return APR_SUCCESS;
       }
       return APR_ENOTIMPL;
   }
  @@ -529,6 +534,7 @@
   static void clean_child_exit(int code) __attribute__ ((noreturn));
   static void clean_child_exit(int code)
   {
  +    mpm_state = AP_MPMQ_STOPPING;
       if (pchild) {
           apr_pool_destroy(pchild);
       }
  @@ -599,6 +605,7 @@
   
   static void ap_start_shutdown(void)
   {
  +    mpm_state = AP_MPMQ_STOPPING;
       if (shutdown_pending == 1) {
           /* Um, is this _probably_ not an error, if the user has
            * tried to do a shutdown twice quickly, so we won't
  @@ -612,7 +619,7 @@
   /* do a graceful restart if graceful == 1 */
   static void ap_start_restart(int graceful)
   {
  -
  +    mpm_state = AP_MPMQ_STOPPING;
       if (restart_pending == 1) {
           /* Probably not an error - don't bother reporting it */
           return;
  @@ -1319,6 +1326,9 @@
       apr_threadattr_t *thread_attr;
       apr_thread_t *start_thread_id;
   
  +    mpm_state = AP_MPMQ_STARTING; /* for benefit of any hooks that run as this
  +                                   * child initializes
  +                                   */
       ap_my_pid = getpid();
       apr_pool_create(&pchild, pconf);
   
  @@ -1396,6 +1406,8 @@
           clean_child_exit(APEXIT_CHILDFATAL);
       }
   
  +    mpm_state = AP_MPMQ_RUNNING;
  +    
       /* If we are only running in one_process mode, we will want to
        * still handle signals. */
       if (one_process) {
  @@ -1800,6 +1812,7 @@
       if (rv != APR_SUCCESS) {
           ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
                        "Couldn't create accept lock");
  +        mpm_state = AP_MPMQ_STOPPING;
           return 1;
       }
   
  @@ -1814,12 +1827,14 @@
               ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
                            "Couldn't set permissions on cross-process lock; "
                            "check User and Group directives");
  +            mpm_state = AP_MPMQ_STOPPING;
               return 1;
           }
       }
   
       if (!is_graceful) {
           if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
  +            mpm_state = AP_MPMQ_STOPPING;
               return 1;
           }
           /* fix the generation number in the global score; we just got a new,
  @@ -1867,8 +1882,10 @@
   		apr_proc_mutex_defname());
   #endif
       restart_pending = shutdown_pending = 0;
  +    mpm_state = AP_MPMQ_RUNNING;
   
       server_main_loop(remaining_children_to_start);
  +    mpm_state = AP_MPMQ_STOPPING;
   
       if (shutdown_pending) {
           /* Time to gracefully shut down:
  @@ -1979,6 +1996,8 @@
       ap_directive_t *max_clients = NULL;
       apr_status_t rv;
   
  +    mpm_state = AP_MPMQ_STARTING;
  +    
       /* make sure that "ThreadsPerChild" gets set before "MaxClients" */
       for (pdir = ap_conftree; pdir != NULL; pdir = pdir->next) {
           if (strncasecmp(pdir->directive, "ThreadsPerChild", 15) == 0) {
  @@ -2073,7 +2092,10 @@
       one_process = 0;
   
       ap_hook_open_logs(worker_open_logs, NULL, aszSucc, APR_HOOK_MIDDLE);
  -    ap_hook_pre_config(worker_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
  +    /* we need to set the MPM state before other pre-config hooks use MPM query
  +     * to retrieve it, so register as REALLY_FIRST
  +     */
  +    ap_hook_pre_config(worker_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST);
   }
   
   static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy,
  
  
  
  No                   revision
  No                   revision
  1.62.2.14 +8 -0      httpd-2.0/server/mpm/netware/mpm_netware.c
  
  Index: mpm_netware.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/netware/mpm_netware.c,v
  retrieving revision 1.62.2.13
  retrieving revision 1.62.2.14
  diff -u -r1.62.2.13 -r1.62.2.14
  --- mpm_netware.c	4 Dec 2003 21:25:41 -0000	1.62.2.13
  +++ mpm_netware.c	27 Dec 2003 13:18:56 -0000	1.62.2.14
  @@ -154,6 +154,7 @@
   static int ap_threads_min_free=0;
   static int ap_threads_max_free=0;
   static int ap_threads_limit=0;
  +static int mpm_state = AP_MPMQ_STARTING;
   
   /*
    * The max child slot ever assigned, preserved across restarts.  Necessary
  @@ -268,6 +269,9 @@
           case AP_MPMQ_MAX_DAEMONS:
               *result = 1;
               return APR_SUCCESS;
  +        case AP_MPMQ_MPM_STATE:
  +            *result = mpm_state;
  +            return APR_SUCCESS;
       }
       return APR_ENOTIMPL;
   }
  @@ -946,6 +950,7 @@
   #endif
       show_server_data();
   
  +    mpm_state = AP_MPMQ_RUNNING;
       while (!restart_pending && !shutdown_pending) {
           perform_idle_server_maintenance(pconf);
           if (show_settings)
  @@ -953,6 +958,7 @@
           apr_thread_yield();
           apr_sleep(SCOREBOARD_MAINTENANCE_INTERVAL);
       }
  +    mpm_state = AP_MPMQ_STOPPING;
   
   
       /* Shutdown the listen sockets so that we don't get stuck in a blocking call. 
  @@ -997,6 +1003,8 @@
   {
       int debug;
       char *addrname = NULL;
  +
  +    mpm_state = AP_MPMQ_STARTING;
   
       debug = ap_exists_config_define("DEBUG");
   
  
  
  
  No                   revision
  No                   revision
  1.272.2.5 +26 -2     httpd-2.0/server/mpm/prefork/prefork.c
  
  Index: prefork.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/prefork/prefork.c,v
  retrieving revision 1.272.2.4
  retrieving revision 1.272.2.5
  diff -u -r1.272.2.4 -r1.272.2.5
  --- prefork.c	27 Dec 2003 06:15:48 -0000	1.272.2.4
  +++ prefork.c	27 Dec 2003 13:18:56 -0000	1.272.2.5
  @@ -141,7 +141,7 @@
   static int server_limit = DEFAULT_SERVER_LIMIT;
   static int first_server_limit;
   static int changed_limit_at_restart;
  -
  +static int mpm_state = AP_MPMQ_STARTING;
   static ap_pod_t *pod;
   
   /*
  @@ -229,6 +229,8 @@
   static void clean_child_exit(int code) __attribute__ ((noreturn));
   static void clean_child_exit(int code)
   {
  +    mpm_state = AP_MPMQ_STOPPING;
  +
       if (pchild) {
   	apr_pool_destroy(pchild);
       }
  @@ -326,6 +328,9 @@
           case AP_MPMQ_MAX_DAEMONS:
               *result = server_limit;
               return APR_SUCCESS;
  +        case AP_MPMQ_MPM_STATE:
  +            *result = mpm_state;
  +            return APR_SUCCESS;
       }
       return APR_ENOTIMPL;
   }
  @@ -550,6 +555,10 @@
       apr_status_t rv;
       apr_bucket_alloc_t *bucket_alloc;
   
  +    mpm_state = AP_MPMQ_STARTING; /* for benefit of any hooks that run as this
  +                                  * child initializes
  +                                  */
  +    
       my_child_num = child_num_arg;
       ap_my_pid = getpid();
       csd = NULL;
  @@ -601,6 +610,8 @@
           pollset[i].reqevents = APR_POLLIN;
       }
   
  +    mpm_state = AP_MPMQ_RUNNING;
  +    
       bucket_alloc = apr_bucket_alloc_create(pchild);
   
       while (!die_now) {
  @@ -969,6 +980,7 @@
       if (rv != APR_SUCCESS) {
           ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
                        "Couldn't create accept lock");
  +        mpm_state = AP_MPMQ_STOPPING;
           return 1;
       }
   
  @@ -983,12 +995,14 @@
               ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
                            "Couldn't set permissions on cross-process lock; "
                            "check User and Group directives");
  +            mpm_state = AP_MPMQ_STOPPING;
               return 1;
           }
       }
   
       if (!is_graceful) {
           if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
  +            mpm_state = AP_MPMQ_STOPPING;
               return 1;
           }
           /* fix the generation number in the global score; we just got a new,
  @@ -1041,6 +1055,8 @@
   #endif
       restart_pending = shutdown_pending = 0;
   
  +    mpm_state = AP_MPMQ_RUNNING;
  +    
       while (!restart_pending && !shutdown_pending) {
   	int child_slot;
           apr_exit_why_e exitwhy;
  @@ -1057,6 +1073,7 @@
   	if (pid.pid != -1) {
               processed_status = ap_process_child_status(&pid, exitwhy, status);
               if (processed_status == APEXIT_CHILDFATAL) {
  +                mpm_state = AP_MPMQ_STOPPING;
                   return 1;
               }
   
  @@ -1123,6 +1140,8 @@
   #endif /*TPF */
       }
   
  +    mpm_state = AP_MPMQ_STOPPING;
  +
       if (shutdown_pending) {
   	/* Time to gracefully shut down:
   	 * Kill child processes, tell them to call child_exit, etc...
  @@ -1223,6 +1242,8 @@
       int no_detach, debug, foreground;
       apr_status_t rv;
   
  +    mpm_state = AP_MPMQ_STARTING;
  +
       debug = ap_exists_config_define("DEBUG");
   
       if (debug) {
  @@ -1285,7 +1306,10 @@
   #endif
   
       ap_hook_open_logs(prefork_open_logs, NULL, aszSucc, APR_HOOK_MIDDLE);
  -    ap_hook_pre_config(prefork_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
  +    /* we need to set the MPM state before other pre-config hooks use MPM query
  +     * to retrieve it, so register as REALLY_FIRST
  +     */
  +    ap_hook_pre_config(prefork_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST);
   }
   
   static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, const char *arg) 
  
  
  
  No                   revision
  No                   revision
  1.133.2.5 +26 -4     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.133.2.4
  retrieving revision 1.133.2.5
  diff -u -r1.133.2.4 -r1.133.2.5
  --- worker.c	5 Sep 2003 21:26:57 -0000	1.133.2.4
  +++ worker.c	27 Dec 2003 13:18:57 -0000	1.133.2.5
  @@ -175,6 +175,7 @@
   static int resource_shortage = 0;
   static fd_queue_t *worker_queue;
   static fd_queue_info_t *worker_queue_info;
  +static int mpm_state = AP_MPMQ_STARTING;
   
   /* The structure used to pass unique initialization info to each thread */
   typedef struct {
  @@ -303,6 +304,7 @@
           return;
       }
       terminate_mode = mode;
  +    mpm_state = AP_MPMQ_STOPPING;
   
       /* in case we weren't called from the listener thread, wake up the
        * listener thread
  @@ -360,6 +362,9 @@
           case AP_MPMQ_MAX_DAEMONS:
               *result = ap_daemons_limit;
               return APR_SUCCESS;
  +        case AP_MPMQ_MPM_STATE:
  +            *result = mpm_state;
  +            return APR_SUCCESS;
       }
       return APR_ENOTIMPL;
   }
  @@ -368,6 +373,7 @@
   static void clean_child_exit(int code) __attribute__ ((noreturn));
   static void clean_child_exit(int code)
   {
  +    mpm_state = AP_MPMQ_STOPPING;
       if (pchild) {
           apr_pool_destroy(pchild);
       }
  @@ -438,6 +444,7 @@
   
   static void ap_start_shutdown(void)
   {
  +    mpm_state = AP_MPMQ_STOPPING;
       if (shutdown_pending == 1) {
           /* Um, is this _probably_ not an error, if the user has
            * tried to do a shutdown twice quickly, so we won't
  @@ -451,7 +458,7 @@
   /* do a graceful restart if graceful == 1 */
   static void ap_start_restart(int graceful)
   {
  -
  +    mpm_state = AP_MPMQ_STOPPING;
       if (restart_pending == 1) {
           /* Probably not an error - don't bother reporting it */
           return;
  @@ -765,7 +772,7 @@
                           continue;
                       }
   
  -                    /* apr_poll() will only return errors in catastrophic
  +                    /* apr_pollset_poll() will only return errors in catastrophic
                        * circumstances. Let's try exiting gracefully, for now. */
                       ap_log_error(APLOG_MARK, APLOG_ERR, ret, (const server_rec *)
                                    ap_server_conf, "apr_poll: (listen)");
  @@ -1190,6 +1197,9 @@
       apr_threadattr_t *thread_attr;
       apr_thread_t *start_thread_id;
   
  +    mpm_state = AP_MPMQ_STARTING; /* for benefit of any hooks that run as this
  +                                   * child initializes
  +                                   */
       ap_my_pid = getpid();
       apr_pool_create(&pchild, pconf);
   
  @@ -1267,6 +1277,8 @@
           clean_child_exit(APEXIT_CHILDFATAL);
       }
   
  +    mpm_state = AP_MPMQ_RUNNING;
  +
       /* If we are only running in one_process mode, we will want to
        * still handle signals. */
       if (one_process) {
  @@ -1669,6 +1681,7 @@
       if (rv != APR_SUCCESS) {
           ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
                        "Couldn't create accept lock");
  +        mpm_state = AP_MPMQ_STOPPING;
           return 1;
       }
   
  @@ -1683,12 +1696,14 @@
               ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
                            "Couldn't set permissions on cross-process lock; "
                            "check User and Group directives");
  +            mpm_state = AP_MPMQ_STOPPING;
               return 1;
           }
       }
   
       if (!is_graceful) {
           if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
  +            mpm_state = AP_MPMQ_STOPPING;
               return 1;
           }
           /* fix the generation number in the global score; we just got a new,
  @@ -1736,8 +1751,10 @@
   		apr_proc_mutex_defname());
   #endif
       restart_pending = shutdown_pending = 0;
  -
  +    mpm_state = AP_MPMQ_RUNNING;
  +    
       server_main_loop(remaining_children_to_start);
  +    mpm_state = AP_MPMQ_STOPPING;
   
       if (shutdown_pending) {
           /* Time to gracefully shut down:
  @@ -1841,6 +1858,8 @@
       ap_directive_t *max_clients = NULL;
       apr_status_t rv;
   
  +    mpm_state = AP_MPMQ_STARTING;
  +
       /* make sure that "ThreadsPerChild" gets set before "MaxClients" */
       for (pdir = ap_conftree; pdir != NULL; pdir = pdir->next) {
           if (strncasecmp(pdir->directive, "ThreadsPerChild", 15) == 0) {
  @@ -1935,7 +1954,10 @@
       one_process = 0;
   
       ap_hook_open_logs(worker_open_logs, NULL, aszSucc, APR_HOOK_MIDDLE);
  -    ap_hook_pre_config(worker_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
  +    /* we need to set the MPM state before other pre-config hooks use MPM query
  +     * to retrieve it, so register as REALLY_FIRST
  +     */
  +    ap_hook_pre_config(worker_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST);
   }
   
   static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy,
  
  
  

Mime
View raw message