httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Stein <gst...@lyra.org>
Subject Re: cvs commit: apache-2.0/src/main http_protocol.c
Date Thu, 09 Nov 2000 03:45:39 GMT
On Wed, Nov 08, 2000 at 07:16:43PM -0800, rbb@covalent.net wrote:
> On Wed, 8 Nov 2000, Greg Stein wrote:
>...
> > PIPE and SOCKET need refcounting, but they cannot be copied. The data must
> > first be acquired, then it can be copied.
> 
> We aren't copying data, we are copying the bucket, so the dup function
> should just create a second bucket that points to the same
> pipe/socket.

That won't work. You can't have two buckets pointing to the same pipe/socket
because they cannot each read() the pipe/socket.

If a bucket represents a pipe which is known to have 10 bytes in it before
the end-of-pipe (due to whatever protocol), and you copy the bucket, now you
have two buckets: one with 10 bytes in it, and one with none. And it all
just depends on which order you happen to read them from.

To make it work, the pipe must read [into a heap bucket], then the copy is
made. Effectively, if you call copy(), then the pipe will read in a chunk,
create a heap bucket (adjust the brigade), then copy the heap bucket. Note
that you may still have a pipe bucket remaining (after the newly-created
heap bucket), and that bucket may need to be copied further.

> The data should not be copied first.  Now, having said that,
> it is incredibly unlikely that anybody will ever dup a pipe/socket bucket,
> because you really need either the data or length before you know if you
> want to dup or not.

I would tend to agree on this one.

Actually, I think what is going to happen:

split(brigade, range_start, &start_bucket)
split(brigade, range_end, &end_bucket)
while (start_bucket != end_bucket):
  append(bsend, copy(start_bucket))
  start_bucket = next(start_bucket)

Note that the split-brigade function would zoom through the brigade's
buckets looking for the split-position. If pipes/sockets are encountered,
then the contents will need to be read into memory. So yes... by the time
that we reach the copy(), there won't be any pipes/sockets in that area.
However, the pipe/socket *could* still exist at "end_bucket" or later.

To really get this stuff up to top perf, we would want functional copy() and
split() operations on all bucket types.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Mime
View raw message