httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@attglobal.net>
Subject [PATCH] mod_cgid tells APR that an os file is a pipe
Date Tue, 01 Oct 2002 19:50:34 GMT
mod_cgid has an AF_UNIX socket which it uses to create an apr_file_t
which it uses to create a pipe bucket which it passes down the filter
chain

but it gets to a filter (content-length filter) which wants to play
with the I/O timeout and APR fails the timeout manipulation because it
doesn't think the apr_file_t represents a pipe (or something close
enough to a pipe)

Thus the content-length filter's code to allow streaming output
doesn't work with mod_cgid because of the socket/file/pipe confusion.

The following patch adds a way for an APR app to say that the
apr_file_t being created from an os file should be treated as a pipe.

Index: modules/generators/mod_cgid.c
===================================================================
RCS file: /cvs/phoenix/2.0.42/modules/generators/mod_cgid.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mod_cgid.c
--- modules/generators/mod_cgid.c	19 Sep 2002 12:20:17 -0000	1.1.1.1
+++ modules/generators/mod_cgid.c	1 Oct 2002 18:57:49 -0000
@@ -1101,7 +1101,7 @@
      * Note that this does not register a cleanup for the socket.  We did
      * that explicitly right after we created the socket.
      */
-    apr_os_file_put(&tempsock, &sd, 0, r->pool);
+    apr_os_file_put_ex(&tempsock, &sd, 1, 0, r->pool);
 
     if ((argv0 = strrchr(r->filename, '/')) != NULL) 
         argv0++; 
@@ -1422,7 +1422,7 @@
      * Note that this does not register a cleanup for the socket.  We did
      * that explicitly right after we created the socket.
      */
-    apr_os_file_put(&tempsock, &sd, 0, r->pool);
+    apr_os_file_put_ex(&tempsock, &sd, 1, 0, r->pool);
 
     if ((retval = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR))) 
         return retval; 
Index: srclib/apr/file_io/unix/open.c
===================================================================
RCS file: /cvs/phoenix/2.0.42/srclib/apr/file_io/unix/open.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 open.c
--- srclib/apr/file_io/unix/open.c	19 Sep 2002 12:20:20 -0000	1.1.1.1
+++ srclib/apr/file_io/unix/open.c	1 Oct 2002 18:57:49 -0000
@@ -219,15 +219,18 @@
     return APR_SUCCESS;
 }
 
-APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, 
-                                          apr_os_file_t *thefile,
-                                          apr_int32_t flags, apr_pool_t *pool)
+APR_DECLARE(apr_status_t) apr_os_file_put_ex(apr_file_t **file, 
+                                             apr_os_file_t *thefile,
+                                             int is_pipe,
+                                             apr_int32_t flags,
+                                             apr_pool_t *pool)
 {
     int *dafile = thefile;
     
     (*file) = apr_pcalloc(pool, sizeof(apr_file_t));
     (*file)->pool = pool;
     (*file)->eof_hit = 0;
+    (*file)->is_pipe = is_pipe != 0;
     (*file)->blocking = BLK_UNKNOWN; /* in case it is a pipe */
     (*file)->timeout = -1;
     (*file)->ungetchar = -1; /* no char avail */
@@ -250,6 +253,14 @@
     }
     return APR_SUCCESS;
 }    
+
+APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, 
+                                          apr_os_file_t *thefile,
+                                          apr_int32_t flags,
+                                          apr_pool_t *pool)
+{
+    return apr_os_file_put_ex(file, thefile, 0, flags, pool);
+}
 
 APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr)
 {
Index: srclib/apr/include/apr_portable.h
===================================================================
RCS file: /cvs/phoenix/2.0.42/srclib/apr/include/apr_portable.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 apr_portable.h
--- srclib/apr/include/apr_portable.h	19 Sep 2002 12:20:21 -0000	1.1.1.1
+++ srclib/apr/include/apr_portable.h	1 Oct 2002 18:57:49 -0000
@@ -364,6 +364,20 @@
                                           apr_int32_t flags, apr_pool_t *cont); 
 
 /**
+ * convert the file from os specific type to apr type.
+ * @param file The apr file we are converting to.
+ * @param thefile The os specific file to convert
+ * @param ispipe Whether or not the descriptor should be treated as a pipe
+ * @param flags The flags that were used to open this file.
+ * @param cont The pool to use if it is needed.
+ * @remark On Unix, it is only possible to put a file descriptor into
+ *         an apr file type.
+ */
+APR_DECLARE(apr_status_t) apr_os_file_put_ex(apr_file_t **file,
+                                             apr_os_file_t *thefile, int is_pipe,
+                                             apr_int32_t flags, apr_pool_t *cont); 
+
+/**
  * convert the dir from os specific type to apr type.
  * @param dir The apr dir we are converting to.
  * @param thedir The os specific dir to convert



-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Mime
View raw message