manoj       99/08/03 16:36:44

  Modified:    mpm/src/modules/mpm/dexter dexter.c
               mpm/src/modules/mpm/mpmt_pthread mpmt_pthread.c
  Log:
  Fix a couple of potential graceful restart bugs noted by Dean: EINTR was
  never dealt with in the code to write to the pipe of death, and in
  pathological cases where the number of processes is greater than
  PIPE_BUF, we could end up only killing some processes.
  
  Revision  Changes    Path
  1.15      +12 -3     apache-2.0/mpm/src/modules/mpm/dexter/dexter.c
  
  Index: dexter.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/dexter/dexter.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -d -u -r1.14 -r1.15
  --- dexter.c  1999/08/03 20:41:36     1.14
  +++ dexter.c  1999/08/03 23:36:41     1.15
  @@ -1404,7 +1404,7 @@
       }
   
       if (is_graceful) {
  -     int i;
  +     int i, bytes_to_write;
           char char_of_death = '!';
   
        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf,
  @@ -1420,8 +1420,17 @@
            } 
        }
        /* give the children the signal to die */
  -        if (write(pipe_of_death[1], &char_of_death, num_daemons) == -1) {
  -            ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, "write 
pipe_of_death");
  +        /* XXX - This while loop logic should be made into a utility 
function */
  +        bytes_to_write = num_daemons;
  +        while (bytes_to_write > 0) {
  +            i = write(pipe_of_death[1], &char_of_death, bytes_to_write);
  +            if (i == -1) {
  +                if (errno == EINTR) continue;
  +                ap_log_error(APLOG_MARK, APLOG_ERR, server_conf,
  +                             "write pipe_of_death");
  +                break;
  +            }
  +            bytes_to_write -= i;
           }
       }
       else {
  
  
  
  1.21      +12 -3     
apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c
  
  Index: mpmt_pthread.c
  ===================================================================
  RCS file: 
/home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -d -u -r1.20 -r1.21
  --- mpmt_pthread.c    1999/08/03 20:41:37     1.20
  +++ mpmt_pthread.c    1999/08/03 23:36:43     1.21
  @@ -1463,7 +1463,7 @@
       update_scoreboard_global();
   
       if (is_graceful) {
  -     int i, j;
  +     int i, j, bytes_to_write;
           char char_of_death = '!';
   
        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf,
  @@ -1472,8 +1472,17 @@
           /* give the children the signal to die. Sending more bytes than
            * children is okay, because the pipe is recreated for every
            * generation */
  -        if (write(pipe_of_death[1], &char_of_death, ap_daemons_limit) == -1) 
{
  -            ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "write 
pipe_of_death");
  +        /* XXX - This while loop logic should be made into a utility 
function */
  +        bytes_to_write = ap_daemons_limit;
  +        while (bytes_to_write > 0) {
  +            i = write(pipe_of_death[1], &char_of_death, bytes_to_write);
  +            if (i == -1) {
  +                if (errno == EINTR) continue;
  +                ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf,
  +                             "write pipe_of_death");
  +                break;
  +            }
  +            bytes_to_write -= i;
           }
   
        /* This is mostly for debugging... so that we know what is still
  
  
  

Reply via email to