Return-Path: Delivered-To: apmail-apache-cvs-archive@apache.org Received: (qmail 51160 invoked by uid 500); 19 Oct 2000 10:51:45 -0000 Mailing-List: contact apache-cvs-help@apache.org; run by ezmlm Precedence: bulk Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list apache-cvs@apache.org Received: (qmail 51149 invoked by uid 500); 19 Oct 2000 10:51:44 -0000 Delivered-To: apmail-apache-2.0-cvs@apache.org Date: 19 Oct 2000 10:51:44 -0000 Message-ID: <20001019105144.51145.qmail@locus.apache.org> From: trawick@locus.apache.org To: apache-2.0-cvs@apache.org Subject: cvs commit: apache-2.0/src/ap ap_buckets_pipe.c ap_buckets_socket.c trawick 00/10/19 03:51:44 Modified: src/ap ap_buckets_pipe.c ap_buckets_socket.c Log: pipe_read() and socket_read(): set the buffer pointer to NULL if we're an error occurred pipe_read(): go ahead and close the pipe (the read side) if we've reached the end Revision Changes Path 1.16 +9 -4 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.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- ap_buckets_pipe.c 2000/10/16 06:04:28 1.15 +++ ap_buckets_pipe.c 2000/10/19 10:51:42 1.16 @@ -71,6 +71,7 @@ *len = IOBUFSIZE; rv = apr_read(p, buf, len); if (rv != APR_SUCCESS && rv != APR_EOF) { + *str = NULL; free(buf); return rv; } @@ -81,7 +82,8 @@ ap_bucket_make_heap(a, buf, *len, 0, NULL); /* XXX: check for failure? */ /* * If there's more to read we have to keep the rest of the pipe - * for later. XXX: Note that more complicated bucket types that + * for later. Otherwise, we'll close the pipe. + * XXX: Note that more complicated bucket types that * refer to data not in memory and must therefore have a read() * function similar to this one should be wary of copying this * code because if they have a destroy function they probably @@ -94,15 +96,18 @@ b = ap_bucket_create_pipe(p); AP_BUCKET_INSERT_AFTER(a, b); } + else { + apr_close(p); + } return APR_SUCCESS; } AP_DECLARE(ap_bucket *) ap_bucket_make_pipe(ap_bucket *b, apr_file_t *p) { /* - * XXX: We rely on a cleanup on some pool or other to actually - * destroy the pipe. We should probably explicitly call apr to - * destroy it instead. + * A pipe is closed when the end is reached in pipe_read(). If the + * pipe isn't read to the end (e.g., error path), the pipe will be + * closed when its pool goes away. * * Note that typically the pipe is allocated from the request pool * so it will disappear when the request is finished. However the 1.6 +5 -0 apache-2.0/src/ap/ap_buckets_socket.c Index: ap_buckets_socket.c =================================================================== RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets_socket.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ap_buckets_socket.c 2000/10/16 06:04:29 1.5 +++ ap_buckets_socket.c 2000/10/19 10:51:43 1.6 @@ -71,6 +71,7 @@ *len = IOBUFSIZE; rv = apr_recv(p, buf, len); if (rv != APR_SUCCESS && rv != APR_EOF) { + *str = NULL; free(buf); return rv; } @@ -89,6 +90,10 @@ * old bucket to a raw new one and adjust it as appropriate, * rather than destroying the old one and creating a completely * new bucket. + * + * Even if there is nothing more to read, don't close the socket here + * as we have to use it to send any response :) We could shut it + * down for reading, but there is no benefit to doing so. */ if (*len > 0) { b = ap_bucket_create_socket(p);