httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/threadproc/unix proc.c
Date Thu, 04 May 2000 00:27:54 GMT
rbb         00/05/03 17:27:53

  Modified:    src/lib/apr/include apr_thread_proc.h
               src/lib/apr/misc/unix otherchild.c
               src/lib/apr/threadproc/unix proc.c
  Log:
  Add a new function to APR, ap_wait_all_procs.  This waits for any current
  child process to die, and then returns that child's information.
  
  Revision  Changes    Path
  1.28      +33 -2     apache-2.0/src/lib/apr/include/apr_thread_proc.h
  
  Index: apr_thread_proc.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_thread_proc.h,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- apr_thread_proc.h	2000/05/01 21:22:46	1.27
  +++ apr_thread_proc.h	2000/05/04 00:27:49	1.28
  @@ -574,8 +574,29 @@
    */
   ap_status_t ap_wait_proc(ap_proc_t *proc, ap_wait_how_e waithow);
   
  +
   /*
   
  +=head1 ap_status_t ap_wait_all_procs(ap_proc_t **proc, ap_wait_how waithow, ap_pool_t *p)

  +
  +B<Wait for any current child process to die and return information about that child.>
  +
  +    arg 1) Pointer to NULL on entry, will be filled out with child's 
  +           information 
  +    arg 2) How should we wait.  One of:
  +              APR_WAIT   -- block until the child process dies.
  +              APR_NOWAIT -- return immediately regardless of if the 
  +                            child is dead or not.
  +    arg 3) Pool to allocate child information out of.
  +
  +=cut
  + */
  +
  +ap_status_t ap_wait_all_proc(ap_proc_t **proc, ap_wait_how_e waithow, 
  +                             ap_pool_t *p);
  +
  +/*
  +
   =head1 ap_status_t ap_detach(ap_proc_t **new, ap_pool_t *cont)
   
   B<Detach the process from the controlling terminal.>
  @@ -590,7 +611,7 @@
   #if APR_HAS_OTHER_CHILD
   /*
   
  -=head1 void ap_register_other_child(ap_proc_t *pid, void (*maintenance) (int reason, void
*data, int status), void *data, int write_fd, ap_pool_t *p)
  +=head1 void ap_register_other_child(ap_proc_t *pid, void (*maintenance) (int reason, void
*data, int status), void *data, ap_file_t *write_fd, ap_pool_t *p)
   
   B<Register an other_child -- a child which must be kept track of so that the program
knows when it has dies or disappeared.>
   
  @@ -609,7 +630,7 @@
    */
   void ap_register_other_child(ap_proc_t *pid, 
                                void (*maintenance) (int reason, void *, int status),
  -                             void *data, int write_fd, ap_pool_t *p);
  +                             void *data, ap_file_t *write_fd, ap_pool_t *p);
   
   /*
   
  @@ -650,6 +671,16 @@
   =cut
    */
   void ap_check_other_child(void); 
  +
  +/*
  +
  +=head1 void ap_probe_writable_fds(void)
  +
  +B<Ensure all the registered write_fds are still writable, otherwise invoke the maintenance
functions as appropriate.>
  +
  +=cut
  + */
  +void ap_probe_writable_fds(void);
   #endif /* APR_HAS_OTHER_CHILD */
   
   /*
  
  
  
  1.10      +9 -3      apache-2.0/src/lib/apr/misc/unix/otherchild.c
  
  Index: otherchild.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/unix/otherchild.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- otherchild.c	2000/04/24 21:50:18	1.9
  +++ otherchild.c	2000/05/04 00:27:52	1.10
  @@ -54,6 +54,7 @@
   
   #include "misc.h"
   #include "threadproc.h"
  +#include "../../file_io/unix/fileio.h"
   #ifdef HAVE_TIME_H
   #include <sys/time.h>
   #endif
  @@ -68,7 +69,7 @@
   
   API_EXPORT(void) ap_register_other_child(ap_proc_t *pid,
                        void (*maintenance) (int reason, void *, int status),
  -                     void *data, int write_fd, ap_pool_t *p)
  +                     void *data, ap_file_t *write_fd, ap_pool_t *p)
   {
       ap_other_child_rec_t *ocr;
   
  @@ -76,7 +77,12 @@
       ocr->pid = pid->pid;
       ocr->maintenance = maintenance;
       ocr->data = data;
  -    ocr->write_fd = write_fd;
  +    if (write_fd == NULL) {
  +        ocr->write_fd = -1;
  +    }
  +    else {
  +        ocr->write_fd = write_fd->filedes;
  +    }
       ocr->next = other_children;
       other_children = ocr;
   }
  @@ -98,7 +104,7 @@
   
   /* test to ensure that the write_fds are all still writable, otherwise
    * invoke the maintenance functions as appropriate */
  -static void probe_writable_fds(void)
  +void ap_probe_writable_fds(void)
   {
       fd_set writable_fds;
       int fd_max;
  
  
  
  1.26      +34 -0     apache-2.0/src/lib/apr/threadproc/unix/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/threadproc/unix/proc.c,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- proc.c	2000/04/30 21:17:57	1.25
  +++ proc.c	2000/05/04 00:27:53	1.26
  @@ -320,6 +320,40 @@
       return APR_SUCCESS;
   }    
   
  +ap_status_t ap_wait_all_procs(ap_proc_t **proc, 
  +                              ap_wait_how_e waithow, ap_pool_t *p)
  +{
  +    pid_t status;
  +    if (waithow == APR_WAIT) {
  +        if ((status = waitpid(-1, NULL, WUNTRACED)) > 0) {
  +            if (!*proc) {
  +                (*proc) = ap_pcalloc(p, sizeof(ap_proc_t));
  +                (*proc)->cntxt = p;
  +            }
  +            (*proc)->pid = status;
  +            return APR_CHILD_DONE;
  +        }
  +        else if (status == 0) {
  +            (*proc) = NULL;
  +            return APR_CHILD_NOTDONE;
  +        }
  +        return errno;
  +    }
  +    if ((status = waitpid(-1, NULL, WUNTRACED | WNOHANG)) > 0) {
  +        if (!*proc) {
  +            (*proc) = ap_pcalloc(p, sizeof(ap_proc_t));
  +            (*proc)->cntxt = p;
  +        }
  +        (*proc)->pid = status;
  +        return APR_CHILD_DONE;
  +    }
  +    else if (status == 0) {
  +        (*proc) = NULL;
  +        return APR_CHILD_NOTDONE;
  +    }
  +    return errno;
  +} 
  +
   ap_status_t ap_wait_proc(ap_proc_t *proc, 
                              ap_wait_how_e waithow)
   {
  
  
  

Mime
View raw message