store_client::readBody and writing to memory

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Tue, 27 Oct 2009 00:26:21 -0600

Hello,

    Recent memory cache enhancements in trunk added a piece of code that
copies disk object data into the memory cache. The code has a comment
that essentially says that Squid code parts has their own idea what the
right "offset" is and we have to adjust when going from the store feud
to the memory feud:

/* Copy read data back into memory.
 * but first we need to adjust offset.. some parts of the code
 * counts offset including headers, some parts count offset as
 * withing the body.. copyInto is including headers, but the mem
 * cache expects offset without headers (using negative for headers)
 * eventually not storing packed headers in memory at all.
 */

Following the above comment, the code decrements for-memory offset by
the reply header size (copyInto.offset - rep->hdr_sz). The same code
does not decrement the buffer length (len) and does not increment the
buffer pointer (copyInto.data) to exclude parsed headers.

I suspect that everything works correctly because the memory code does
the necessary length and buffer pointer adjustments itself, when needed,
under the assumption that the headers are always in the first written
buffer. Is that the right explanation for why we adjust the offset but
not the buffer pointer or the buffer length?

If the memory code assumes the headers are there in the first written
chunk, would it be better to adjust the "offset" in the memory code as
well then, so that all the adjustments are done in one place?

Is it possible to define exactly what that offset parameter means for
the MemObject::write() code? Or does the meaning change depending on
MemObject state?

Thank you,

Alex.
Received on Tue Oct 27 2009 - 06:25:39 MDT

This archive was generated by hypermail 2.2.0 : Tue Oct 27 2009 - 12:00:05 MDT