}
void
-MemObject::write ( StoreIOBuffer writeBuffer, STMCB *callback, void *callbackData)
+MemObject::write(const StoreIOBuffer &writeBuffer)
{
PROF_start(MemObject_write);
debugs(19, 6, "memWrite: offset " << writeBuffer.offset << " len " << writeBuffer.length);
- /* the offset is into the content, not the headers */
- writeBuffer.offset += (_reply ? _reply->hdr_sz : 0);
-
/* We don't separate out mime headers yet, so ensure that the first
* write is at offset 0 - where they start
*/
assert (data_hdr.endOffset() || writeBuffer.offset == 0);
assert (data_hdr.write (writeBuffer));
- callback (callbackData, writeBuffer);
PROF_stop(MemObject_write);
}
/// replaces construction-time URLs with correct ones; see hidden_mem_obj
void resetUrls(char const *aUrl, char const *aLog_url);
- void write(StoreIOBuffer, STMCB *, void *);
+ void write(const StoreIOBuffer &buf);
void unlinkRequest();
HttpReply const *getReply() const;
void replaceHttpReply(HttpReply *newrep);
#include <limits.h>
#endif
-static STMCB storeWriteComplete;
-
#define REBUILD_TIMESTAMP_DELTA_MAX 2
#define STORE_IN_MEM_BUCKETS (229)
expires = squid_curtime;
}
-void
-storeWriteComplete (void *data, StoreIOBuffer wroteBuffer)
-{
- PROF_start(storeWriteComplete);
- StoreEntry *e = (StoreEntry *)data;
-
- if (EBIT_TEST(e->flags, DELAY_SENDING)) {
- PROF_stop(storeWriteComplete);
- return;
- }
-
- e->invokeHandlers();
- PROF_stop(storeWriteComplete);
-}
-
void
StoreEntry::write (StoreIOBuffer writeBuffer)
{
PROF_start(StoreEntry_write);
assert(store_status == STORE_PENDING);
+ // XXX: caller uses content offset, but we also store headers
+ if (const HttpReply *reply = mem_obj->getReply())
+ writeBuffer.offset += reply->hdr_sz;
+
debugs(20, 5, "storeWrite: writing " << writeBuffer.length << " bytes for '" << getMD5Text() << "'");
PROF_stop(StoreEntry_write);
storeGetMemSpace(writeBuffer.length);
- mem_obj->write (writeBuffer, storeWriteComplete, this);
+ mem_obj->write(writeBuffer);
+
+ if (!EBIT_TEST(flags, DELAY_SENDING))
+ invokeHandlers();
}
/* Append incoming data from a primary server to an entry. */
this);
}
-static void
-storeClientMemWriteComplete(void *data, StoreIOBuffer wroteBuffer)
-{
- // Nothin to do here but callback is needed
-}
-
void
store_client::readBody(const char *buf, ssize_t len)
{
// The above may start to free our object so we need to check again
if (entry->mem_obj->inmem_lo == 0) {
/* 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.
+ * copyInto.offset includes headers, which is what mem cache needs
*/
int64_t mem_offset = entry->mem_obj->endOffset();
if ((copyInto.offset == mem_offset) || (parsed_header && mem_offset == rep->hdr_sz)) {
- entry->mem_obj->write(StoreIOBuffer(len, copyInto.offset - rep->hdr_sz, copyInto.data), storeClientMemWriteComplete, this);
+ entry->mem_obj->write(StoreIOBuffer(len, copyInto.offset, copyInto.data));
}
}
}