--------------------- PatchSet 1599 Date: 2005/08/24 22:50:29 Author: dwsquid Branch: squid3-icap Tag: (none) Log: - add StoreEntry::isAccepting() method to know if its okay to append more data to the StoreEntry. - use this method in http.cc with ICAP to know when to abort the ICAP side Members: src/Store.h:1.15->1.15.8.1 src/http.cc:1.49.2.13->1.49.2.14 src/store.cc:1.27->1.27.8.1 Index: squid3/src/Store.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Store.h,v retrieving revision 1.15 retrieving revision 1.15.8.1 diff -u -r1.15 -r1.15.8.1 --- squid3/src/Store.h 7 Jan 2005 03:13:20 -0000 1.15 +++ squid3/src/Store.h 24 Aug 2005 22:50:29 -0000 1.15.8.1 @@ -1,6 +1,6 @@ /* - * $Id: Store.h,v 1.15 2005/01/07 03:13:20 squidadm Exp $ + * $Id: Store.h,v 1.15.8.1 2005/08/24 22:50:29 dwsquid Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -66,6 +66,7 @@ virtual HttpReply const *getReply() const; virtual void write (StoreIOBuffer); virtual _SQUID_INLINE_ bool isEmpty() const; + virtual bool isAccepting() const; virtual size_t bytesWanted(Range const) const; virtual void complete(); virtual store_client_t storeClientType() const; Index: squid3/src/http.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/http.cc,v retrieving revision 1.49.2.13 retrieving revision 1.49.2.14 diff -u -r1.49.2.13 -r1.49.2.14 --- squid3/src/http.cc 24 Aug 2005 21:28:23 -0000 1.49.2.13 +++ squid3/src/http.cc 24 Aug 2005 22:50:29 -0000 1.49.2.14 @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.49.2.13 2005/08/24 21:28:23 dwsquid Exp $ + * $Id: http.cc,v 1.49.2.14 2005/08/24 22:50:29 dwsquid Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -1997,6 +1997,12 @@ HttpStateData::takeAdaptedHeaders(HttpReply *rep) { debug(11,5)("HttpStateData::takeAdaptedHeaders() called\n"); + assert(entry->store_status == STORE_PENDING); + if (!entry->isAccepting()) { + debug(11,5)("\toops, entry is not Accepting!\n"); + icap->ownerAbort(); + return; + } storeEntryReplaceObject(entry, rep); /* * After calling storeEntryReplaceObject() we give up control @@ -2004,6 +2010,7 @@ */ rep = reply = NULL; haveParsedReplyHeaders(); + debug(11,5)("HttpStateData::takeAdaptedHeaders() finished\n"); } void @@ -2012,6 +2019,13 @@ debug(11,5)("HttpStateData::takeAdaptedBody() called\n"); debug(11,5)("\t%d bytes\n", buf->contentSize()); debug(11,5)("\t%d is current offset\n", (int)currentOffset); + assert(entry->store_status == STORE_PENDING); + + if (!entry->isAccepting()) { + debug(11,5)("\toops, entry is not Accepting!\n"); + icap->ownerAbort(); + return; + } entry->write(StoreIOBuffer(buf, currentOffset)); // write everything currentOffset += buf->contentSize(); @@ -2022,6 +2036,11 @@ HttpStateData::doneAdapting() { debug(11,5)("HttpStateData::doneAdapting() called\n"); + if (!entry->isAccepting()) { + debug(11,5)("\toops, entry is not Accepting!\n"); + icap->ownerAbort(); + return; + } fwdComplete(fwd); httpStateFree(-1, this); assert(fd == -1); Index: squid3/src/store.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/store.cc,v retrieving revision 1.27 retrieving revision 1.27.8.1 diff -u -r1.27 -r1.27.8.1 --- squid3/src/store.cc 4 Jan 2005 03:13:39 -0000 1.27 +++ squid3/src/store.cc 24 Aug 2005 22:50:29 -0000 1.27.8.1 @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.27 2005/01/04 03:13:39 squidadm Exp $ + * $Id: store.cc,v 1.27.8.1 2005/08/24 22:50:29 dwsquid Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -1895,6 +1895,20 @@ store()->unlink(*this); } +/* + * return true if the entry is in a state where + * it can accept more data (ie with write() method) + */ +bool +StoreEntry::isAccepting() const +{ + if (STORE_PENDING != store_status) + return false; + if (EBIT_TEST(flags, ENTRY_ABORTED)) + return false; + return true; +} + /* NullStoreEntry */ NullStoreEntry NullStoreEntry::_instance;