rbb 00/11/04 08:34:51
Modified: src CHANGES src/ap ap_buckets_pipe.c src/lib/apr/file_io/unix pipe.c src/lib/apr/include apr_file_io.h Log: Make non-blocking reads from pipes work through the bucket interface. Revision Changes Path 1.307 +5 -0 apache-2.0/src/CHANGES Index: CHANGES =================================================================== RCS file: /home/cvs/apache-2.0/src/CHANGES,v retrieving revision 1.306 retrieving revision 1.307 diff -u -r1.306 -r1.307 --- CHANGES 2000/11/03 04:34:41 1.306 +++ CHANGES 2000/11/04 16:34:45 1.307 @@ -1,4 +1,9 @@ Changes with Apache 2.0a8 + *) Make blocking and non-blocking bucket reads work correctly for + sockets and pipes. These are the only bucket types that should + have non-blocking reads, because the other bucket types should + ALWAYS be able to return something immediately. + [Ryan Bloom] *) In the Apache/Win32 console window, accept Ctrl+C to stop the server, but use Ctrl+Break to initiate a graceful restart 1.18 +10 -0 apache-2.0/src/ap/ap_buckets_pipe.c Index: ap_buckets_pipe.c =================================================================== RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets_pipe.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- ap_buckets_pipe.c 2000/11/04 01:30:28 1.17 +++ ap_buckets_pipe.c 2000/11/04 16:34:47 1.18 @@ -65,11 +65,21 @@ ap_bucket *b; char *buf; apr_status_t rv; + apr_interval_time_t timeout; + if (block == AP_NONBLOCK_READ) { + apr_get_pipe_timeout(p, &timeout); + apr_set_pipe_timeout(p, 0); + } + buf = malloc(IOBUFSIZE); /* XXX: check for failure? */ *str = buf; *len = IOBUFSIZE; rv = apr_read(p, buf, len); + + if (block == AP_NONBLOCK_READ) { + apr_set_pipe_timeout(p, timeout); + } if (rv != APR_SUCCESS && rv != APR_EOF) { *str = NULL; 1.41 +7 -0 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.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- pipe.c 2000/10/25 15:02:41 1.40 +++ pipe.c 2000/11/04 16:34:49 1.41 @@ -145,6 +145,13 @@ return APR_EINVAL; } +apr_status_t apr_get_pipe_timeout(apr_file_t *thepipe, apr_interval_time_t *timeout) +{ + if (thepipe->pipe == 1) { + *timeout = thepipe->timeout; + } +} + apr_status_t apr_create_pipe(apr_file_t **in, apr_file_t **out, apr_pool_t *cont) { int filedes[2]; 1.69 +8 -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.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- apr_file_io.h 2000/10/23 17:21:13 1.68 +++ apr_file_io.h 2000/11/04 16:34:50 1.69 @@ -595,6 +595,14 @@ apr_pool_t *cont); /** + * Get the timeout value for a pipe or manipulate the blocking state. + * @param thepipe The pipe we are getting a timeout for. + * @param timeoutThe timeout value in microseconds. Values < 0 mean wait + * forever, 0 means do not wait at all. + */ +apr_status_t apr_get_pipe_timeout(apr_file_t *thepipe, apr_interval_time_t *timeout); + +/** * Set the timeout value for a pipe or manipulate the blocking state. * @param thepipe The pipe we are setting a timeout on. * @param timeoutThe timeout value in microseconds. Values < 0 mean wait