----- Original Message -----
From: "Alex Rousskov" <rousskov@measurement-factory.com>
To: "Robert Collins" <robert.collins@itdomain.com.au>
Cc: <squid-dev@squid-cache.org>
Sent: Wednesday, February 21, 2001 8:41 AM
Subject: Re: eventio API
> On Wed, 21 Feb 2001, Robert Collins wrote:
>
> > I have a small question:
> > What if I want to pull the first 32K out of a 64K IOBuf, and send
that
> > somewhere in squid. Then I want to send a locally generated 12Kb
buff,
> > and then the rest of the 64Kb buffer. Do I need to memcpy the 32Kb
> > buffers? Can the 12Kb be a static buffer? (marked in some fashion as
not
> > needing free - or is this just plain bad? )
>
> I can answer only using the IOBufRange approach. Henrik probably has a
> different, better interface in mind.
>
> You could use IOBufRange pointing to the "first 32K out of a 64K
> IOBuf" to write those 32K.
>
> The "locally generated 12Kb buff" must be dynamically allocated or
> static memory (i.e., not stack memory). The reference counters should
> be smart enough to distinguish a static case from dynamically
> allocated one (i.e. refcount for static memory should be set to 1 when
> the static object is created so it is never freed() during normal
> program execution). You will use that 12K buffer (or a "full"
> IOBufRange pointing to it) for your second ncomm_write() call.
>
> Finally, you will use another IOBufRange pointing to the "rest of
> the 64Kb buffer" for the third ncom_write() call.
>
> Putting all things together:
>
> ncom_write(..., IOBufRange(buf64, 0, 32K), ...);
> ncom_write(..., IOBufRange(buf12, 0, buf12.size()), ...);
> ncom_write(..., IOBufRange(buf64, 32K, buf64.size()), ...);
>
> Where IOBufRange(buf, min, maxplusone) returns an IOBufRange structure
> with the given parameters. We could even have a IOBufRest(buf, min)
> call to avoid calling buf.size() all the time.
>
> Callbacks could be called with appropriate IOBufRanges as parameters
> as well.
>
> No copying is necessary. I omitted calls to IOBufLockRead (before
> ncom_write) and IOBufUnlockRead (in the callback, as appropriate).
>
> HTH,
>
> Alex.
>
>
Excellent. That fits in closely with what I've been doing in the filters
work. I had the size/offset/buf split off (I see no reason not to put
them in a struct), and just wanted to confirm that sort of work will
still be feasible.
Rob
Received on Tue Feb 20 2001 - 14:44:16 MST
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:13:33 MST