I thought of the (possible) reason earlier tonite.
If you read and get back len==0, then how do you distinguish between "none
available (yet)" and "you won't get any more."
I believe the current code says "APR_EOF means you won't get any more;
otherwise, the len is what is available right now."
IMO, the bucket should transform itself from a pipe/socket to an N-length
(heap) bucket when it discovers EOF. But *never* return EOF. The EOF is an
"internal" indicator of the bucket.
When you read a bucket with APR_BLOCK_READ, it *must* always read at least
one byte. The only reason to not read a byte is if/when the pipe/socket
ends, so the bucket should transform to a zero-length heap bucket. If bytes
are read, then we use current behavior: transform the bucket to a heap
holding N bytes of data, then insert a pipe/socket as the next bucket with
the data from the current bucket.
If you read with APR_NONBLOCK_READ, then you may get back zero-length
buckets. People who use this reading style should be *VERY* careful: you
don't want to loop with NONBLOCK because you could sit there and read
zero-length buckets for a long time. Basically, if a NONBLOCK user reads
zero-length, then they should switch to BLOCK to read at least one byte,
then return to NONBLOCK. If a NONBLOCK pipe/socket bucket hits EOF, then (as
usual) a zero-length heap is inserted, but it skips the step of re-inserting
a pipe/socket after the heap bucket.
That ought to do the trick. It seems like clean semantics across the board.
Cheers,
-g
On Mon, Feb 19, 2001 at 02:38:57AM -0800, [EMAIL PROTECTED] wrote:
>
> I realize this doesn't make much sense, but there was a definite reason
> for doing this. I don't remember what it was off the top of my head, and
> I'm trying to stay off the computer this weekend. If this isn't answered
> Tuesday norning, I'll give a more complete answer.
>
> Ryan
>
> On Sat, 17 Feb 2001, Ben Laurie wrote:
>
> > the end of socket_read (in apr-util/buckets/apr_buckets_socket.c) looks
> > like this:
> >
> > if (*len > 0) {
> > b = apr_bucket_socket_create(p);
> > APR_BUCKET_INSERT_AFTER(a, b);
> > }
> > else if (rv == APR_EOF && block == APR_NONBLOCK_READ) {
> > return APR_EOF;
> > }
> > return APR_SUCCESS;
> > }
> >
> > why the test for APR_NONBLOCK_READ? Surely an EOF is an EOF, whatever
> > mode you are in? Shouldn't it just return APR_EOF if rv == APR_EOF,
> > regardless of mode?
> >
> > Cheers,
> >
> > Ben.
> >
> > --
> > http://www.apache-ssl.org/ben.html
> >
> > "There is no limit to what a man can do or how far he can go if he
> > doesn't mind who gets the credit." - Robert Woodruff
> >
> >
>
>
> _______________________________________________________________________________
> Ryan Bloom [EMAIL PROTECTED]
> 406 29th St.
> San Francisco, CA 94131
> -------------------------------------------------------------------------------
--
Greg Stein, http://www.lyra.org/