You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Bill Stoddard <bi...@wstoddard.com> on 2002/04/06 20:13:09 UTC
Question about this patch to core_input_filter...
Justin,
This is your patch... core_input_filter adds a socket bucket, does a APR_BRIGADE_NORMALIZE
and then calls APR_BRIGADE_EMPTY(). How can this check ever return an empty brigade?
Bill
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/core.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -r1.144 -r1.145
--- httpd-2.0/server/core.c 2002/02/05 22:56:44 1.144
+++ httpd-2.0/server/core.c 2002/02/06 02:24:18 1.145
@@ -3062,9 +3062,13 @@
/* ### This is bad. */
APR_BRIGADE_NORMALIZE(ctx->b);
- /* check for empty brigade *AFTER* APR_BRIGADE_NORMALIZE() */
+ /* check for empty brigade *AFTER* APR_BRIGADE_NORMALIZE()
+ * If we have lost our socket bucket (see above), we are EOF.
+ *
+ * Ideally, this should be returning SUCCESS with EOS bucket, but
+ * some higher-up APIs (spec. read_request_line via ap_rgetline)
+ * want an error code. */
if (APR_BRIGADE_EMPTY(ctx->b)) {
- /* hit EOF on socket already */
return APR_EOF;
}
@@ -3150,6 +3154,22 @@
}
else if (rv != APR_SUCCESS) {
return rv;
+ } else if (block == APR_BLOCK_READ && len == 0) {
+ /* We wanted to read some bytes in blocking mode. We read
+ * 0 bytes. Hence, we now assume we are EOS.
+ *
+ * When we are in normal mode, return an EOS bucket to the
+ * caller.
+ * When we are in speculative mode, leave ctx->b empty, so
+ * that the next call returns an EOS bucket.
+ */
+ apr_bucket_delete(e);
+
+ if (mode == AP_MODE_READBYTES) {
+ e = apr_bucket_eos_create();
+ APR_BRIGADE_INSERT_TAIL(b, e);
+ }
+ return APR_SUCCESS;
}
/* We can only return at most what we read. */
Re: Question about this patch to core_input_filter...
Posted by Bill Stoddard <bi...@wstoddard.com>.
> Justin,
> This is your patch... core_input_filter adds a socket bucket, does a
APR_BRIGADE_NORMALIZE
> and then calls APR_BRIGADE_EMPTY(). How can this check ever return an empty brigade?
> Bill
>
> ===================================================================
> RCS file: /home/cvspublic/httpd-2.0/server/core.c,v
> retrieving revision 1.144
> retrieving revision 1.145
> diff -u -r1.144 -r1.145
> --- httpd-2.0/server/core.c 2002/02/05 22:56:44 1.144
> +++ httpd-2.0/server/core.c 2002/02/06 02:24:18 1.145
> @@ -3062,9 +3062,13 @@
> /* ### This is bad. */
> APR_BRIGADE_NORMALIZE(ctx->b);
>
> - /* check for empty brigade *AFTER* APR_BRIGADE_NORMALIZE() */
> + /* check for empty brigade *AFTER* APR_BRIGADE_NORMALIZE()
> + * If we have lost our socket bucket (see above), we are EOF.
Let me ask a different way... Referring to the comment above, how can we loose a socket
bucket that was just created?
Thanks,
Bill
RE: Question about this patch to core_input_filter...
Posted by Cliff Woolley <jw...@virginia.edu>.
On Sat, 6 Apr 2002, Ryan Bloom wrote:
> > Justin,
> > This is your patch... core_input_filter adds a socket bucket, does a
> > APR_BRIGADE_NORMALIZE
> > and then calls APR_BRIGADE_EMPTY(). How can this check ever return an
> > empty brigade?
>
> If the socket is closed on the other side, then the bucket code will
> remove the socket from the brigade.
Right. Well, more precisely, it morphs itself to a zero-length immortal
bucket, which is then removed from the brigade by APR_BRIGADE_NORMALIZE.
--Cliff
--------------------------------------------------------------
Cliff Woolley
cliffwoolley@yahoo.com
Charlottesville, VA
RE: Question about this patch to core_input_filter...
Posted by Ryan Bloom <rb...@covalent.net>.
> Justin,
> This is your patch... core_input_filter adds a socket bucket, does a
> APR_BRIGADE_NORMALIZE
> and then calls APR_BRIGADE_EMPTY(). How can this check ever return an
> empty brigade?
If the socket is closed on the other side, then the bucket code will
remove the socket from the brigade.
Ryan