74
74
return Pool().inUseCount();
78
MemObject::storeId() const {
79
if (!storeId_.defined()) {
80
debugs(20, DBG_IMPORTANT, "Bug: Missing MemObject::storeId value");
82
storeId_ = "[unknown_URI]";
84
return storeId_.termedBuf();
88
MemObject::logUri() const {
89
return logUri_.defined() ? logUri_.termedBuf() : storeId();
93
MemObject::hasUris() const {
94
return storeId_.defined();
78
MemObject::resetUrls(char const *aUrl, char const *aLog_url)
98
MemObject::setUris(char const *aStoreId, char const *aLogUri, const HttpRequestMethod &aMethod)
81
safe_free(log_url); /* XXX account log_url */
82
log_url = xstrdup(aLog_url);
102
// fast pointer comparison for a common storeCreateEntry(url,url,...) case
103
if (!aLogUri || aLogUri == aStoreId)
104
logUri_.clean(); // use storeId_ by default to minimize copying
110
#if URL_CHECKSUM_DEBUG
111
chksum = url_checksum(urlXXX());
86
MemObject::MemObject(char const *aUrl, char const *aLog_url)
115
MemObject::MemObject(): smpCollapsed(false)
88
117
debugs(20, 3, HERE << "new MemObject " << this);
89
118
_reply = new HttpReply;
90
119
HTTPMSGLOCK(_reply);
94
#if URL_CHECKSUM_DEBUG
96
chksum = url_checksum(url);
100
log_url = xstrdup(aLog_url);
104
123
/* XXX account log_url */
109
128
MemObject::~MemObject()
111
130
debugs(20, 3, HERE << "del MemObject " << this);
112
const Ctx ctx = ctx_enter(url);
131
const Ctx ctx = ctx_enter(hasUris() ? urlXXX() : "[unknown_ctx]");
113
133
#if URL_CHECKSUM_DEBUG
115
assert(chksum == url_checksum(url));
137
if (!shutting_down) { // Store::Root() is FATALly missing during shutdown
138
assert(xitTable.index < 0);
139
assert(memCache.index < 0);
119
140
assert(swapout.sio == NULL);
121
143
data_hdr.freeContent();
152
MemObject::write ( StoreIOBuffer writeBuffer, STMCB *callback, void *callbackData)
170
MemObject::write(const StoreIOBuffer &writeBuffer)
154
172
PROF_start(MemObject_write);
155
173
debugs(19, 6, "memWrite: offset " << writeBuffer.offset << " len " << writeBuffer.length);
157
/* the offset is into the content, not the headers */
158
writeBuffer.offset += (_reply ? _reply->hdr_sz : 0);
160
175
/* We don't separate out mime headers yet, so ensure that the first
161
176
* write is at offset 0 - where they start
163
178
assert (data_hdr.endOffset() || writeBuffer.offset == 0);
165
180
assert (data_hdr.write (writeBuffer));
166
callback (callbackData, writeBuffer);
167
181
PROF_stop(MemObject_write);
182
196
debugs(20, DBG_IMPORTANT, "MemObject->nclients: " << nclients);
183
197
debugs(20, DBG_IMPORTANT, "MemObject->reply: " << _reply);
184
198
debugs(20, DBG_IMPORTANT, "MemObject->request: " << request);
185
debugs(20, DBG_IMPORTANT, "MemObject->log_url: " << checkNullString(log_url));
199
debugs(20, DBG_IMPORTANT, "MemObject->logUri: " << logUri_);
200
debugs(20, DBG_IMPORTANT, "MemObject->storeId: " << storeId_);
188
203
HttpReply const *
226
241
MemObject::stat(MemBuf * mb) const
228
243
mb->Printf("\t%s %s\n",
229
RequestMethodStr(method), log_url);
244
RequestMethodStr(method), logUri());
230
245
if (vary_headers)
231
246
mb->Printf("\tvary_headers: %s\n", vary_headers);
232
247
mb->Printf("\tinmem_lo: %" PRId64 "\n", inmem_lo);
238
253
mb->Printf("\tswapout: %" PRId64 " bytes written\n",
239
254
(int64_t) swapout.sio->offset());
256
if (xitTable.index >= 0)
257
mb->Printf("\ttransient index: %d state: %d\n",
258
xitTable.index, xitTable.io);
259
if (memCache.index >= 0)
260
mb->Printf("\tmem-cache index: %d state: %d offset: %" PRId64 "\n",
261
memCache.index, memCache.io, memCache.offset);
263
mb->Printf("\tobject_sz: %" PRId64 "\n", object_sz);
265
mb->Printf("\tsmp-collapsed\n");
241
267
StoreClientStats statsVisitor(mb);
243
269
for_each<StoreClientStats>(clients, statsVisitor);
308
334
MemObject::readAheadPolicyCanRead() const
310
return endOffset() - getReply()->hdr_sz < lowestMemReaderOffset() + Config.readAheadGap;
336
const bool canRead = endOffset() - getReply()->hdr_sz <
337
lowestMemReaderOffset() + Config.readAheadGap;
340
debugs(19, 9, "no: " << endOffset() << '-' << getReply()->hdr_sz <<
341
" < " << lowestMemReaderOffset() << '+' << Config.readAheadGap);
401
435
MemObject::trimUnSwappable()
403
int64_t new_mem_lo = policyLowestOffsetToKeep(0);
404
assert (new_mem_lo > 0);
406
data_hdr.freeDataUpto(new_mem_lo);
407
inmem_lo = new_mem_lo;
437
if (const int64_t new_mem_lo = policyLowestOffsetToKeep(false)) {
438
assert (new_mem_lo > 0);
439
data_hdr.freeDataUpto(new_mem_lo);
440
inmem_lo = new_mem_lo;
441
} // else we should not trim anything at this time