From: robertc <> Date: Mon, 20 Oct 2003 17:23:37 +0000 (+0000) Subject: 2003-10-20 GMT Robert Collins patch-413 X-Git-Tag: SQUID_3_0_PRE4~1182 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=90703668eab69827161d131832059645546a90be;p=thirdparty%2Fsquid.git 2003-10-20 GMT Robert Collins patch-413 Summary: store_client refactoring Revision: squid--HEAD--3.0--patch-413 2003-10-20 GMT Robert Collins patch-412 Summary: debug review of stmem.cc Revision: squid--HEAD--3.0--patch-412 2003-10-20 GMT Robert Collins patch-411 Summary: simply mem_hdr API a little, and tweak store_client::scheduleMemRead Revision: squid--HEAD--3.0--patch-411 2003-10-20 GMT Robert Collins patch-410 Summary: fix ufsdump builds again Revision: squid--HEAD--3.0--patch-410 --- diff --git a/src/Makefile.am b/src/Makefile.am index 0aca024fbf..808a40b073 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.91 2003/10/16 21:40:17 robertc Exp $ +# $Id: Makefile.am,v 1.92 2003/10/20 11:23:38 robertc Exp $ # # Uncomment and customize the following to suit your needs: # @@ -519,6 +519,7 @@ ufsdump_SOURCES = debug.cc \ int.cc \ ufsdump.cc \ store.cc \ + StoreFileSystem.cc \ StoreMeta.cc \ StoreMeta.h \ StoreMetaMD5.cc \ @@ -556,7 +557,6 @@ ufsdump_SOURCES = debug.cc \ comm_select.cc \ comm_poll.cc \ comm_kqueue.cc \ - comm_epoll.cc \ defines.h \ $(DELAY_POOL_SOURCE) \ disk.cc \ diff --git a/src/StoreClient.h b/src/StoreClient.h index 4c9636acf3..f31513a69d 100644 --- a/src/StoreClient.h +++ b/src/StoreClient.h @@ -1,6 +1,6 @@ /* - * $Id: StoreClient.h,v 1.10 2003/07/11 04:02:01 robertc Exp $ + * $Id: StoreClient.h,v 1.11 2003/10/20 11:23:38 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -69,7 +69,6 @@ public: void callback(ssize_t len, bool error = false); void doCopy (StoreEntry *e); void readHeader(const char *buf, ssize_t len); - bool callbackPending() const; void copy(StoreEntry *, StoreIOBuffer, STCB *, void *); void dumpStats(StoreEntry * output, int clientNumber) const; @@ -119,11 +118,16 @@ private: int type; bool object_ok; + /* Until we finish stuffing code into store_client */ + +public: + struct Callback { Callback ():callback_handler(NULL), callback_data(NULL){} Callback (STCB *, void *); + bool pending() const; STCB *callback_handler; void *callback_data; } diff --git a/src/stmem.cc b/src/stmem.cc index 63199d761e..740129329e 100644 --- a/src/stmem.cc +++ b/src/stmem.cc @@ -1,6 +1,6 @@ /* - * $Id: stmem.cc,v 1.84 2003/10/20 03:57:25 robertc Exp $ + * $Id: stmem.cc,v 1.85 2003/10/20 11:23:37 robertc Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Harvest Derived @@ -152,7 +152,7 @@ mem_hdr::makeAppendSpace() void mem_hdr::internalAppend(const char *data, int len) { - debug(19, 6) ("memInternalAppend: len %d\n", len); + debugs(19, 6, "memInternalAppend: len " << len); while (len > 0) { makeAppendSpace(); @@ -217,10 +217,10 @@ mem_hdr::debugDump() const * we supply 0-500 and stop. */ ssize_t -mem_hdr::copy(off_t offset, char *buf, size_t size) const +mem_hdr::copy(StoreIOBuffer const &target) const { - debugs(19, 6, "memCopy: offset " << offset << ": size " << size); + debugs(19, 6, "memCopy: " << target.range()); /* we shouldn't ever ask for absent offsets */ @@ -232,22 +232,22 @@ mem_hdr::copy(off_t offset, char *buf, size_t size) const } /* RC: the next assert is nearly useless */ - assert(size > 0); + assert(target.length > 0); /* Seek our way into store */ - mem_node *p = getBlockContainingLocation((size_t)offset); + mem_node *p = getBlockContainingLocation((size_t)target.offset); if (!p) { - debugs(19, 1, "memCopy: could not find offset " << offset << + debugs(19, 1, "memCopy: could not find start of " << target.range() << " in memory."); debugDump(); fatal("Squid has attempted to read data from memory that is not present. This is an indication of of (pre-3.0) code that hasn't been updated to deal with sparse objects in memory. Squid should coredump.allowing to review the cause. Immediately preceeding this message is a dump of the available data in the format [start,end). The [ means from the value, the ) means up to the value. I.e. [1,5) means that there are 4 bytes of data, at offsets 1,2,3,4.\n"); return 0; } - size_t bytes_to_go = size; - char *ptr_to_buf = buf; - off_t location = offset; + size_t bytes_to_go = target.length; + char *ptr_to_buf = target.data; + off_t location = target.offset; /* Start copying begining with this block until * we're satiated */ @@ -259,7 +259,7 @@ mem_hdr::copy(off_t offset, char *buf, size_t size) const /* hit a sparse patch */ if (bytes_to_copy == 0) - return size - bytes_to_go; + return target.length - bytes_to_go; location += bytes_to_copy; @@ -270,7 +270,7 @@ mem_hdr::copy(off_t offset, char *buf, size_t size) const p = getBlockContainingLocation(location); } - return size - bytes_to_go; + return target.length - bytes_to_go; } bool @@ -336,8 +336,7 @@ bool mem_hdr::write (StoreIOBuffer const &writeBuffer) { PROF_start(mem_hdr_write); - // mem_node *tempNode; - debug(19, 6) ("mem_hdr::write: offset %lu len %ld, object end %lu\n", (unsigned long)writeBuffer.offset, (long)writeBuffer.length, (unsigned long)endOffset()); + debugs(19, 6, "mem_hdr::write: " << writeBuffer.range() << " object end " << endOffset()); if (unionNotEmpty(writeBuffer)) { fatal("Attempt to overwrite already in-memory data\n"); @@ -391,8 +390,8 @@ mem_hdr::NodeCompare(mem_node * const &left, mem_node * const &right) void mem_hdr::dump() const { - debug(20, 1) ("mem_hdr: %p nodes.start() %p\n", this, nodes.start()); - debug(20, 1) ("mem_hdr: %p nodes.finish() %p\n", this, nodes.finish()); + debugs(20, 1, "mem_hdr: " << (void *)this << " nodes.start() " << nodes.start()); + debugs(20, 1, "mem_hdr: " << (void *)this << " nodes.finish() " << nodes.finish()); } size_t diff --git a/src/stmem.h b/src/stmem.h index 798173b2fc..e39c4dca7f 100644 --- a/src/stmem.h +++ b/src/stmem.h @@ -1,6 +1,6 @@ /* - * $Id: stmem.h,v 1.6 2003/09/22 08:50:51 robertc Exp $ + * $Id: stmem.h,v 1.7 2003/10/20 11:23:38 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -52,7 +52,7 @@ public: int lowestOffset () const; off_t endOffset () const; int freeDataUpto (int); - ssize_t copy (off_t, char *, size_t) const; + ssize_t copy (StoreIOBuffer const &) const; bool hasContigousContentRange(Range const &range) const; /* success or fail */ bool write (StoreIOBuffer const &); diff --git a/src/store_client.cc b/src/store_client.cc index c784d810c2..7e00dad903 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -1,6 +1,6 @@ /* - * $Id: store_client.cc,v 1.133 2003/08/10 05:11:22 robertc Exp $ + * $Id: store_client.cc,v 1.134 2003/10/20 11:23:38 robertc Exp $ * * DEBUG: section 90 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -153,7 +153,7 @@ store_client::callback(ssize_t sz, bool error) } result.offset = cmp_offset; - assert(callbackPending()); + assert(_callback.pending()); cmp_offset = copyInto.offset + sz; STCB *temphandler = _callback.callback_handler; void *cbdata = _callback.callback_data; @@ -174,7 +174,7 @@ storeClientCopyEvent(void *data) assert (sc->flags.copy_event_pending); sc->flags.copy_event_pending = 0; - if (!sc->callbackPending()) + if (!sc->_callback.pending()) return; storeClientCopy2(sc->entry, sc); @@ -239,7 +239,7 @@ store_client::copy(StoreEntry * anEntry, assert(this == storeClientListSearch(entry->mem_obj, data)); #endif - assert(!callbackPending()); + assert(!_callback.pending()); #if ONLYCONTIGUOUSREQUESTS assert(cmp_offset == copyRequest.offset); @@ -315,7 +315,7 @@ storeClientCopy2(StoreEntry * e, store_client * sc) } debug(90, 3)("storeClientCopy2: %s\n", e->getMD5Text()); - assert(sc->callbackPending()); + assert(sc->_callback.pending()); /* * We used to check for ENTRY_ABORTED here. But there were some * problems. For example, we might have a slow client (or two) and @@ -442,9 +442,7 @@ store_client::scheduleMemRead() /* What the client wants is in memory */ /* Old style */ debug(90, 3)("store_client::doCopy: Copying normal from memory\n"); - MemObject *mem = entry->mem_obj; - size_t sz = mem->data_hdr.copy(copyInto.offset, copyInto.data, - copyInto.length); + size_t sz = entry->mem_obj->data_hdr.copy(copyInto); callback(sz); flags.store_copying = 0; } @@ -454,7 +452,7 @@ store_client::fileRead() { MemObject *mem = entry->mem_obj; - assert(callbackPending()); + assert(_callback.pending()); assert(!flags.disk_io_pending); flags.disk_io_pending = 1; @@ -477,7 +475,7 @@ storeClientReadBody(void *data, const char *buf, ssize_t len) store_client *sc = (store_client *)data; assert(sc->flags.disk_io_pending); sc->flags.disk_io_pending = 0; - assert(sc->callbackPending()); + assert(sc->_callback.pending()); debug(90, 3)("storeClientReadBody: len %d", (int) len); if (sc->copyInto.offset == 0 && len > 0 && sc->entry->getReply()->sline.status == 0) @@ -500,7 +498,7 @@ store_client::fail() * not synchronous */ - if (callbackPending()) + if (_callback.pending()) callback(0, true); } @@ -565,7 +563,7 @@ store_client::readHeader(char const *buf, ssize_t len) assert(flags.disk_io_pending); flags.disk_io_pending = 0; - assert(callbackPending()); + assert(_callback.pending()); unpackHeader (buf, len); @@ -625,7 +623,7 @@ storeClientCopyPending(store_client * sc, StoreEntry * e, void *data) #endif - if (!sc->callbackPending()) + if (!sc->_callback.pending()) return 0; return 1; @@ -671,7 +669,7 @@ storeUnregister(store_client * sc, StoreEntry * e, void *data) statCounter.swap.ins++; } - if (sc->callbackPending()) { + if (sc->_callback.pending()) { /* callback with ssize = -1 to indicate unexpected termination */ debug(90, 3) ("storeUnregister: store_client for %s has a callback\n", mem->url); @@ -721,7 +719,7 @@ InvokeHandlers(StoreEntry * e) nx = node->next; debug(90, 3) ("InvokeHandlers: checking client #%d\n", i++); - if (!sc->callbackPending()) + if (!sc->_callback.pending()) continue; if (sc->flags.disk_io_pending) @@ -744,9 +742,6 @@ storePendingNClients(const StoreEntry * e) static int CheckQuickAbort2(StoreEntry * entry) { - size_t curlen; - size_t minlen; - size_t expectlen; MemObject * const mem = entry->mem_obj; assert(mem); debug(90, 3) ("CheckQuickAbort2: entry=%p, mem=%p\n", entry, mem); @@ -761,15 +756,15 @@ CheckQuickAbort2(StoreEntry * entry) return 1; } - expectlen = entry->getReply()->content_length + entry->getReply()->hdr_sz; + size_t expectlen = entry->getReply()->content_length + entry->getReply()->hdr_sz; if (expectlen < 0) /* expectlen is < 0 if *no* information about the object has been recieved */ return 1; - curlen = (size_t) mem->endOffset (); + size_t curlen = (size_t) mem->endOffset (); - minlen = (size_t) Config.quickAbort.min << 10; + size_t minlen = (size_t) Config.quickAbort.min << 10; if (minlen < 0) { debug(90, 3) ("CheckQuickAbort2: NO disabled\n"); @@ -828,7 +823,7 @@ CheckQuickAbort(StoreEntry * entry) void store_client::dumpStats(StoreEntry * output, int clientNumber) const { - if (callbackPending()) + if (_callback.pending()) return; storeAppendPrintf(output, "\tClient #%d, %p\n", clientNumber, _callback.callback_data); @@ -854,9 +849,9 @@ store_client::dumpStats(StoreEntry * output, int clientNumber) const } bool -store_client::callbackPending() const +store_client::Callback::pending() const { - return _callback.callback_handler && _callback.callback_data; + return callback_handler && callback_data; } store_client::Callback::Callback(STCB *function, void *data) : callback_handler(function), callback_data (data) {}