httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grega...@apache.org
Subject cvs commit: httpd-2.0/server/mpm/threaded threaded.c
Date Sat, 28 Jul 2001 23:39:07 GMT
gregames    01/07/28 16:39:07

  Modified:    .        CHANGES
               include  scoreboard.h
               server/mpm/threaded threaded.c
  Log:
  Fix a problem where the threaded MPM stalls after restarts or segfaults.
  
  Also prevent multiple active processes from using the same scoreboard slot.
  
  Revision  Changes    Path
  1.262     +4 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.261
  retrieving revision 1.262
  diff -u -r1.261 -r1.262
  --- CHANGES	2001/07/28 15:28:26	1.261
  +++ CHANGES	2001/07/28 23:39:06	1.262
  @@ -5,6 +5,10 @@
        Transitional specifications.  [William Rowe]
   
   Changes with Apache 2.0.22
  +  
  +  *) Fix a problem where the threaded MPM stalls after restarts or
  +     segfaults.  Also prevent multiple active processes from using
  +     the same scoreboard slot.  [Greg Ames]
   
     *) Apache/Win32 now fills in the service description with Apache's
        server version string, including loaded and advertised modules.
  
  
  
  1.29      +3 -0      httpd-2.0/include/scoreboard.h
  
  Index: scoreboard.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/scoreboard.h,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- scoreboard.h	2001/07/26 15:53:15	1.28
  +++ scoreboard.h	2001/07/28 23:39:07	1.29
  @@ -178,6 +178,9 @@
       pid_t pid;
       ap_generation_t generation;	/* generation of this child */
       ap_scoreboard_e sb_type;
  +    int quiescing;          /* the process whose pid is stored above is
  +                             * going down gracefully
  +                             */
   };
   
   typedef struct {
  
  
  
  1.51      +23 -3     httpd-2.0/server/mpm/threaded/threaded.c
  
  Index: threaded.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/threaded/threaded.c,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- threaded.c	2001/07/26 18:11:53	1.50
  +++ threaded.c	2001/07/28 23:39:07	1.51
  @@ -648,8 +648,15 @@
       apr_pool_destroy(tpool);
       ap_update_child_status(process_slot, thread_slot, (dying) ? SERVER_DEAD : SERVER_GRACEFUL,
           (request_rec *) NULL);
  -    dying = 1;
       apr_lock_acquire(worker_thread_count_mutex);
  +    if (!dying) {
  +        /* this is the first thread to exit */
  +        if (ap_my_pid == ap_scoreboard_image->parent[process_slot].pid) {
  +            /* tell the parent that it may use this scoreboard slot */
  +            ap_scoreboard_image->parent[process_slot].quiescing = 1;
  +        }   
  +        dying = 1;
  +    }
       worker_thread_count--;
       if (worker_thread_count == 0) {
           /* All the threads have exited, now finish the shutdown process
  @@ -900,6 +907,7 @@
           clean_child_exit(0);
       }
       /* else */
  +    ap_scoreboard_image->parent[slot].quiescing = 0;
       ap_scoreboard_image->parent[slot].pid = pid;
       return 0;
   }
  @@ -961,6 +969,7 @@
       int i, j;
       int idle_thread_count;
       worker_score *ws;
  +    process_score *ps;
       int free_length;
       int free_slots[MAX_SPAWN_RATE];
       int last_non_dead;
  @@ -985,6 +994,7 @@
   
   	if (i >= ap_max_daemons_limit && free_length == idle_spawn_rate)
   	    break;
  +        ps = &ap_scoreboard_image->parent[i];
   	for (j = 0; j < ap_threads_per_child; j++) {
               ws = &ap_scoreboard_image->servers[i][j];
   	    status = ws->status;
  @@ -998,11 +1008,19 @@
   	     * So we hopefully won't need to fork more if we count it.
   	     * This depends on the ordering of SERVER_READY and SERVER_STARTING.
   	     */
  -	    if (status <= SERVER_READY && status != SERVER_DEAD) {
  +	    if (status <= SERVER_READY && status != SERVER_DEAD &&
  +                    ps->generation == ap_my_generation && 
  +                 /* XXX the following shouldn't be necessary if we clean up 
  +                  *     properly after seg faults, but we're not yet    GLA 
  +                  */     
  +                    ps->pid != 0) {
   	        ++idle_thread_count;
   	    }
   	}
  -	if (any_dead_threads && free_length < idle_spawn_rate) {
  +        /* XXX any_dead_threads may not be needed any more GLA */
  +        if (any_dead_threads && free_length < idle_spawn_rate 
  +                && (!ps->pid               /* no process in the slot */
  +                    || ps->quiescing)) {   /* or at least one is going away */
   	    free_slots[free_length] = i;
   	    ++free_length;
   	}
  @@ -1083,6 +1101,8 @@
                   for (i = 0; i < ap_threads_per_child; i++)
                       ap_update_child_status(child_slot, i, SERVER_DEAD, (request_rec *)
NULL);
                   
  +                ap_scoreboard_image->parent[child_slot].pid = 0;
  +                ap_scoreboard_image->parent[child_slot].quiescing = 0;
   		if (remaining_children_to_start
   		    && child_slot < ap_daemons_limit) {
   		    /* we're still doing a 1-for-1 replacement of dead
  
  
  

Mime
View raw message