apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: apr/threadproc/unix proc.c
Date Sun, 11 Nov 2001 05:51:00 GMT
trawick     01/11/10 21:51:00

  Modified:    .        CHANGES
               threadproc/unix proc.c
  Log:
  Fix some file cleanup problems in apr_proc_create() which could
  result in the pipes for stdin/stdout/stderr being closed
  immediately.
  
  Revision  Changes    Path
  1.178     +5 -1      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.177
  retrieving revision 1.178
  diff -u -r1.177 -r1.178
  --- CHANGES	2001/11/09 22:59:00	1.177
  +++ CHANGES	2001/11/11 05:51:00	1.178
  @@ -1,8 +1,12 @@
   Changes with APR b1  
   
  +  *) Fix some file cleanup problems in apr_proc_create() which could
  +     result in the pipes for stdin/stdout/stderr being closed
  +     immediately.  [Jeff Trawick]
  +
     *) New functions apr_hash_[merge|copy], change to overlay fn
        so that it calls merge, which does a inline iteration instead
  -     of calling the iterator function. [Brian Pan <bpane@pacbell.net]
  +     of calling the iterator function. [Brian Pane <bpane@pacbell.net]
   
     *) Introduce the apr_pool_userdata_setn() variant that doesn't 
        strdup the key.  Allows both the _setn() and _set() variant to 
  
  
  
  1.53      +19 -4     apr/threadproc/unix/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/unix/proc.c,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- proc.c	2001/10/27 00:48:19	1.52
  +++ proc.c	2001/11/11 05:51:00	1.53
  @@ -290,8 +290,7 @@
           int status;
           /* child process */
   
  -        /* XXX major SNAFU
  -         *
  +        /*
            * If we do exec cleanup before the dup2() calls to set up pipes 
            * on 0-2, we accidentally close the pipes used by programs like 
            * mod_cgid.
  @@ -299,9 +298,27 @@
            * If we do exec cleanup after the dup2() calls, cleanup can accidentally
            * close our pipes which replaced any files which previously had
            * descriptors 0-2.
  +         *
  +         * The solution is to kill the cleanup for the pipes, then do
  +         * exec cleanup, then do the dup2() calls.
            */
   
           if (attr->child_in) {
  +            apr_pool_cleanup_kill(apr_file_pool_get(attr->child_in), 
  +                                  attr->child_in, apr_unix_file_cleanup);
  +        }
  +        if (attr->child_out) {
  +            apr_pool_cleanup_kill(apr_file_pool_get(attr->child_out),
  +                                  attr->child_out, apr_unix_file_cleanup);
  +        }
  +        if (attr->child_err) {
  +            apr_pool_cleanup_kill(apr_file_pool_get(attr->child_err),
  +                                  attr->child_err, apr_unix_file_cleanup);
  +        }
  +
  +        apr_pool_cleanup_for_exec();
  +
  +        if (attr->child_in) {
               apr_file_close(attr->parent_in);
               dup2(attr->child_in->filedes, STDIN_FILENO);
               apr_file_close(attr->child_in);
  @@ -324,8 +341,6 @@
                   exit(-1);   /* We have big problems, the child should exit. */
               }
           }
  -
  -        apr_pool_cleanup_for_exec();
   
           if ((status = limit_proc(attr)) != APR_SUCCESS) {
               return status;
  
  
  

Mime
View raw message