httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@hyperreal.org
Subject cvs commit: apache-2.0/src/modules/standard mod_cgi.c mod_include.c mod_mime_magic.c
Date Thu, 02 Dec 1999 18:36:48 GMT
rbb         99/12/02 10:36:47

  Modified:    src/lib/apr/file_io/unix pipe.c
               src/lib/apr/include apr_file_io.h apr_thread_proc.h
               src/lib/apr/threadproc/unix proc.c
               src/main http_log.c
               src/modules/standard mod_cgi.c mod_include.c
                        mod_mime_magic.c
  Log:
  We may not always want to make the pipes between processes non-blocking.
  This patch allows us to set if both sides of the pipes are nonblocking,
  both sides are blocking, just the parent side blocks, or just the child
  side blocks for all three of the pipes created during create_process.  I
  have also modified Apache to take advantage of this change.
  
  Revision  Changes    Path
  1.7       +24 -2     apache-2.0/src/lib/apr/file_io/unix/pipe.c
  
  Index: pipe.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/pipe.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- pipe.c	1999/11/10 16:47:04	1.6
  +++ pipe.c	1999/12/02 18:36:23	1.7
  @@ -60,6 +60,7 @@
   #include <errno.h>
   #include <string.h>
   #include <stdio.h>
  +#include <unistd.h>
   #include <sys/types.h>
   #include <sys/stat.h>
   
  @@ -84,6 +85,7 @@
       return APR_SUCCESS;
   }
   
  +
   /* ***APRDOC********************************************************
    * ap_status_t ap_set_pipe_timeout(ap_file_t *, ap_int32_t)
    *    Set the timeout value for a pipe.
  @@ -100,8 +102,6 @@
       return APR_EINVAL;
   }
   
  -
  -
   /* ***APRDOC********************************************************
    * ap_status_t ap_create_pipe(ap_file_t **, ap_context_t *, ap_file_t **)
    *    Create an anonymous pipe.
  @@ -159,4 +159,26 @@
       }
       return APR_SUCCESS;
   } 
  +
  +ap_status_t ap_block_pipe(ap_file_t *thefile)
  +{
  +    int fd_flags;
  +
  +    fd_flags = fcntl(thefile->filedes, F_GETFL, 0);
  +#if defined(O_NONBLOCK)
  +    fd_flags &= ~O_NONBLOCK;
  +#elif defined(~O_NDELAY)
  +    fd_flags &= ~O_NDELAY;
  +#elif defined(FNDELAY)
  +    fd_flags &= ~O_FNDELAY;
  +#else
  +    /* XXXX: this breaks things, but an alternative isn't obvious...*/
  +    return -1;
  +#endif
  +    if (fcntl(thefile->filedes, F_SETFL, fd_flags) == -1) {
  +        return errno;
  +    }
  +    return APR_SUCCESS;
  +}
  +    
   
  
  
  
  1.21      +1 -0      apache-2.0/src/lib/apr/include/apr_file_io.h
  
  Index: apr_file_io.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_file_io.h,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- apr_file_io.h	1999/12/01 20:35:22	1.20
  +++ apr_file_io.h	1999/12/02 18:36:25	1.21
  @@ -142,6 +142,7 @@
   ap_status_t ap_create_pipe(ap_file_t **, ap_file_t **, ap_context_t *);
   ap_status_t ap_create_namedpipe(char **, char *, ap_fileperms_t, ap_context_t *);
   ap_status_t ap_set_pipe_timeout(ap_file_t *thepipe, ap_int32_t timeout);
  +ap_status_t ap_block_pipe(ap_file_t *thepipe);
   
   /*accessor and general file_io functions. */
   ap_status_t ap_get_filename(char **, ap_file_t *);
  
  
  
  1.11      +6 -0      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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- apr_thread_proc.h	1999/12/01 18:39:21	1.10
  +++ apr_thread_proc.h	1999/12/02 18:36:26	1.11
  @@ -67,6 +67,12 @@
   typedef enum {APR_SHELLCMD, APR_PROGRAM} ap_cmdtype_e;
   typedef enum {APR_WAIT, APR_NOWAIT} ap_wait_how_e;
   
  +#define APR_NO_PIPE          0
  +#define APR_FULL_BLOCK       1
  +#define APR_FULL_NONBLOCK    2
  +#define APR_PARENT_BLOCK     3
  +#define APR_CHILD_BLOCK      4
  +
   #define APR_CANCEL_ASYNCH      1
   #define APR_CANCEL_DEFER       2
   #define APR_CANCEL_ENABLE      3
  
  
  
  1.11      +28 -1     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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- proc.c	1999/11/04 07:26:22	1.10
  +++ proc.c	1999/12/02 18:36:29	1.11
  @@ -107,21 +107,48 @@
                                    ap_int32_t out, ap_int32_t err)
   {
       ap_status_t status;
  -    if (in) {
  +    if (in != 0) {
           if ((status = ap_create_pipe(&attr->child_in, &attr->parent_in, 
                                      attr->cntxt)) != APR_SUCCESS) {
  +            switch (in) {
  +            case APR_FULL_BLOCK:
  +                ap_block_pipe(attr->child_in);
  +                ap_block_pipe(attr->parent_in);
  +            case APR_PARENT_BLOCK:
  +                ap_block_pipe(attr->parent_in);
  +            case APR_CHILD_BLOCK:
  +                ap_block_pipe(attr->child_in);
  +            }
               return status;
           }
       } 
       if (out) {
           if ((status = ap_create_pipe(&attr->parent_out, &attr->child_out,

                                      attr->cntxt)) != APR_SUCCESS) {
  +            switch (in) {
  +            case APR_FULL_BLOCK:
  +                ap_block_pipe(attr->child_out);
  +                ap_block_pipe(attr->parent_out);
  +            case APR_PARENT_BLOCK:
  +                ap_block_pipe(attr->parent_out);
  +            case APR_CHILD_BLOCK:
  +                ap_block_pipe(attr->child_out);
  +            }
               return status;
           }
       } 
       if (err) {
           if ((status = ap_create_pipe(&attr->parent_err, &attr->child_err,

                                      attr->cntxt)) != APR_SUCCESS) {
  +            switch (in) {
  +            case APR_FULL_BLOCK:
  +                ap_block_pipe(attr->child_err);
  +                ap_block_pipe(attr->parent_err);
  +            case APR_PARENT_BLOCK:
  +                ap_block_pipe(attr->parent_err);
  +            case APR_CHILD_BLOCK:
  +                ap_block_pipe(attr->child_err);
  +            }
               return status;
           }
       } 
  
  
  
  1.20      +7 -18     apache-2.0/src/main/http_log.c
  
  Index: http_log.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_log.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- http_log.c	1999/12/01 01:16:10	1.19
  +++ http_log.c	1999/12/02 18:36:31	1.20
  @@ -157,8 +157,7 @@
   };
   
   static int log_child(ap_context_t *p, const char *progname,
  -                     ap_file_t **fpout, ap_file_t **fpin,
  -                     ap_file_t **fperr)
  +                     ap_file_t **fpin)
   {
       /* Child process code for 'ErrorLog "|..."';
        * may want a common framework for this, since I expect it will
  @@ -179,9 +178,9 @@
   
       if ((ap_createprocattr_init(&procattr, p)          != APR_SUCCESS) ||
           (ap_setprocattr_io(procattr,
  -                           fpin  ? 1 : 0,
  -                           fpout ? 1 : 0,
  -                           fperr ? 1 : 0)              != APR_SUCCESS) ||
  +                           APR_NO_PIPE,
  +                           APR_FULL_BLOCK,
  +                           APR_NO_PIPE) != APR_SUCCESS) ||
           (ap_setprocattr_dir(procattr, progname)        != APR_SUCCESS)) {
           /* Something bad happened, give up and go away. */
           rc = -1;
  @@ -198,17 +197,7 @@
               ap_get_os_proc(&fred, procnew);
               ap_note_subprocess(p, fred, kill_after_timeout);
   #endif
  -            if (fpin) {
  -                ap_get_childin(fpin, procnew);
  -            }
  -
  -            if (fpout) {
  -                ap_get_childout(fpout, procnew);
  -            }
  -
  -            if (fperr) {
  -                ap_get_childerr(fperr, procnew);
  -            }
  +            ap_get_childin(fpin, procnew);
           }
       }
   
  @@ -226,7 +215,7 @@
   	ap_file_t *dummy;
   
           /* This starts a new process... */
  -        rc = log_child (p, s->error_fname+1, NULL, &dummy, NULL);
  +        rc = log_child (p, s->error_fname+1, &dummy);
           if (rc != APR_SUCCESS) {
   	    perror("ap_spawn_child");
   	    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
  @@ -767,7 +756,7 @@
       ap_file_t *dummy;
       int rc;
   
  -    rc = log_child(p, program, NULL, &dummy, NULL);
  +    rc = log_child(p, program, &dummy);
       if (rc != APR_SUCCESS) {
   	perror("ap_spawn_child");
   	ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
  
  
  
  1.19      +4 -1      apache-2.0/src/modules/standard/mod_cgi.c
  
  Index: mod_cgi.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_cgi.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- mod_cgi.c	1999/10/31 09:02:55	1.18
  +++ mod_cgi.c	1999/12/02 18:36:36	1.19
  @@ -320,7 +320,10 @@
        * NB only ISINDEX scripts get decoded arguments.
        */
       if ((ap_createprocattr_init(&procattr, p) != APR_SUCCESS) ||
  -        (ap_setprocattr_io(procattr, 1, 1, 1) != APR_SUCCESS) ||
  +        (ap_setprocattr_io(procattr, 
  +                           APR_FULL_BLOCK, 
  +                           APR_FULL_BLOCK,
  +                           APR_FULL_BLOCK) != APR_SUCCESS) ||
           (ap_setprocattr_dir(procattr, ap_make_dirstr_parent(r->pool, r->filename))
       != APR_SUCCESS) ||
           (ap_setprocattr_cmdtype(procattr, APR_PROGRAM)    != APR_SUCCESS)) {
           /* Something bad happened, tell the world. */
  
  
  
  1.9       +2 -1      apache-2.0/src/modules/standard/mod_include.c
  
  Index: mod_include.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_include.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- mod_include.c	1999/11/19 18:48:40	1.8
  +++ mod_include.c	1999/12/02 18:36:37	1.9
  @@ -851,7 +851,8 @@
       }
   
       if ((ap_createprocattr_init(&procattr, r->pool) != APR_SUCCESS) ||
  -        (ap_setprocattr_io(procattr, 0, 1, 0) != APR_SUCCESS) ||
  +        (ap_setprocattr_io(procattr, APR_NO_PIPE, 
  +                           APR_FULL_BLOCK, APR_NO_PIPE) != APR_SUCCESS) ||
           (ap_setprocattr_dir(procattr, ap_make_dirstr_parent(r->pool, r->filename))
!= APR_SUCCESS) ||
           (ap_setprocattr_cmdtype(procattr, APR_PROGRAM) != APR_SUCCESS)) {
           /* Something bad happened, tell the world. */
  
  
  
  1.9       +2 -1      apache-2.0/src/modules/standard/mod_mime_magic.c
  
  Index: mod_mime_magic.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_mime_magic.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- mod_mime_magic.c	1999/12/02 16:00:41	1.8
  +++ mod_mime_magic.c	1999/12/02 18:36:39	1.9
  @@ -2162,7 +2162,8 @@
       env = ap_create_environment(child_context, r->subprocess_env);
   
       if ((ap_createprocattr_init(&procattr, child_context) != APR_SUCCESS) ||
  -        (ap_setprocattr_io(procattr, 1, 1, 0)             != APR_SUCCESS) ||
  +        (ap_setprocattr_io(procattr, APR_FULL_BLOCK, 
  +                           APR_FULL_BLOCK, APR_NO_PIPE)   != APR_SUCCESS) ||
           (ap_setprocattr_dir(procattr, r->filename)        != APR_SUCCESS) ||
           (ap_setprocattr_cmdtype(procattr, APR_PROGRAM)    != APR_SUCCESS)) {
           /* Something bad happened, tell the world. */
  
  
  

Mime
View raw message