--------------------- PatchSet 1570 Date: 2005/08/23 23:17:53 Author: dwsquid Branch: squid3-icap Tag: (none) Log: - Added HttpStateData::abortAdapting() - Were clearing ENTRY_FWD_HDR_WAIT too early for ICAP. Need to do it after HTTP reply headers have been parsed and assigned to the StoreEntry. Members: src/ICAPAnchor.cc:1.1.2.9->1.1.2.10 src/MsgPipe.cc:1.1.2.5->1.1.2.6 src/http.cc:1.49.2.7->1.49.2.8 src/http.h:1.11.4.4->1.11.4.5 Index: squid3/src/ICAPAnchor.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPAnchor.cc,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -r1.1.2.9 -r1.1.2.10 --- squid3/src/ICAPAnchor.cc 20 Aug 2005 06:09:03 -0000 1.1.2.9 +++ squid3/src/ICAPAnchor.cc 23 Aug 2005 23:17:53 -0000 1.1.2.10 @@ -10,7 +10,7 @@ CBDATA_CLASS_INIT(ICAPAnchor); -ICAPAnchor::ICAPAnchor(): virgin(NULL), adapted(NULL) { +ICAPAnchor::ICAPAnchor(): virgin(NULL), adapted(NULL), httpState(NULL) { debug(93,5)("ICAPAnchor constructed, this=%p\n", this); } @@ -36,8 +36,10 @@ adapted = new MsgPipe("adapted"); adapted->sink = this; +#if ICAP_ANCHOR_LOOPBACK adapted->data = new MsgPipeData; adapted->data->cause = request; // should not hurt +#endif #if ICAP_ANCHOR_LOOPBACK #else @@ -120,6 +122,7 @@ // ICAP client is aborting void ICAPAnchor::noteSourceAbort(MsgPipe *p) { debug(93,5)("ICAPAnchor::noteSourceAbort() called\n"); + httpState->abortAdapting(); stop(notifyOwner); } Index: squid3/src/MsgPipe.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/MsgPipe.cc,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- squid3/src/MsgPipe.cc 23 Aug 2005 15:36:54 -0000 1.1.2.5 +++ squid3/src/MsgPipe.cc 23 Aug 2005 23:17:53 -0000 1.1.2.6 @@ -30,22 +30,26 @@ void MsgPipe::sendSourceStart() { + debug(99,5)("MsgPipe::sendSourceStart() called\n"); sendLater("SourceStart", &MsgPipe_sendSourceStart, sink); } void MsgPipe::sendSourceProgress() { + debug(99,5)("MsgPipe::sendSourceProgress() called\n"); sendLater("SourceProgress", &MsgPipe_sendSourceProgress, sink); } void MsgPipe::sendSourceFinish() { - sendLater("SourceFinish", &MsgPipe_sendSourceFinish, sink); + debug(99,5)("MsgPipe::sendSourceFinish() called\n"); + sendLater("sendSourceFinish", &MsgPipe_sendSourceFinish, sink); source = NULL; } void MsgPipe::sendSourceAbort() { + debug(99,5)("MsgPipe::sendSourceAbort() called\n"); sendLater("SourceAbort", &MsgPipe_sendSourceAbort, sink); source = NULL; } @@ -53,11 +57,13 @@ void MsgPipe::sendSinkNeed() { + debug(99,5)("MsgPipe::sendSinkNeed() called\n"); sendLater("SinkNeed", &MsgPipe_sendSinkNeed, source); } void MsgPipe::sendSinkAbort() { + debug(99,5)("MsgPipe::sendSinkAbort() called\n"); sendLater("SinkAbort", &MsgPipe_sendSinkAbort, source); sink = NULL; } Index: squid3/src/http.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/http.cc,v retrieving revision 1.49.2.7 retrieving revision 1.49.2.8 diff -u -r1.49.2.7 -r1.49.2.8 --- squid3/src/http.cc 19 Aug 2005 23:16:24 -0000 1.49.2.7 +++ squid3/src/http.cc 23 Aug 2005 23:17:53 -0000 1.49.2.8 @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.49.2.7 2005/08/19 23:16:24 dwsquid Exp $ + * $Id: http.cc,v 1.49.2.8 2005/08/23 23:17:53 dwsquid Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -832,6 +832,16 @@ entry->mem_obj->vary_headers = xstrdup(vary); } +#if WIP_FWD_LOG + fwdStatus(fwd, s); +#endif + /* + * If its not a reply that we will re-forward, then + * allow the client to get it. + */ + if (!fwdReforwardableStatus(s)) + EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT); + switch (cacheableReply()) { case 1: @@ -1118,18 +1128,6 @@ return; } -#if WIP_FWD_LOG - - fwdStatus(fwd, s); - -#endif - /* - * If its not a reply that we will re-forward, then - * allow the client to get it. - */ - - if (!fwdReforwardableStatus(s)) - EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT); } } @@ -2027,6 +2025,7 @@ HttpStateData::takeAdaptedHeaders(HttpReply *rep) { debug(11,5)("HttpStateData::takeAdaptedHeaders() called\n"); + assert(this); storeEntryReplaceObject(entry, rep); /* * NOTE: reply and rep point to the same thing because we passed @@ -2041,6 +2040,7 @@ HttpStateData::takeAdaptedBody(MemBuf *buf) { debug(11,5)("HttpStateData::takeAdaptedBody() called\n"); + assert(this); debug(11,5)("\t%d bytes\n", buf->contentSize()); debug(11,5)("\t%d is current offset\n", (int)currentOffset); entry->write(StoreIOBuffer(buf, currentOffset)); @@ -2051,8 +2051,31 @@ HttpStateData::doneAdapting() { debug(11,5)("HttpStateData::doneAdapting() called\n"); + assert(this); fwdComplete(fwd); httpStateFree(-1, this); + assert(fd == -1); +} + +void +HttpStateData::abortAdapting() +{ + debug(11,5)("HttpStateData::abortAdapting() called\n"); + assert(this); + if (entry->isEmpty()) { + ErrorState *err; + err = errorCon(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR); + err->request = requestLink((HttpRequest *) request); + err->xerrno = errno; + fwdFail(fwd, err); + flags.do_next_read = 0; + } else { + fwdComplete(fwd); + } + if (fd >= 0) + comm_close(fd); + else + httpStateFree(fd, this); } Index: squid3/src/http.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/http.h,v retrieving revision 1.11.4.4 retrieving revision 1.11.4.5 diff -u -r1.11.4.4 -r1.11.4.5 --- squid3/src/http.h 19 Aug 2005 22:57:41 -0000 1.11.4.4 +++ squid3/src/http.h 23 Aug 2005 23:17:54 -0000 1.11.4.5 @@ -1,6 +1,6 @@ /* - * $Id: http.h,v 1.11.4.4 2005/08/19 22:57:41 dwsquid Exp $ + * $Id: http.h,v 1.11.4.5 2005/08/23 23:17:54 dwsquid Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -54,6 +54,7 @@ void takeAdaptedHeaders(HttpReply *); void takeAdaptedBody(MemBuf *); void doneAdapting(); + void HttpStateData::abortAdapting(); #endif StoreEntry *entry;