--------------------- PatchSet 1859 Date: 2005/09/21 20:34:30 Author: dwsquid Branch: squid3-icap Tag: (none) Log: astyle Members: src/ICAPOptXact.cc:1.1.2.2->1.1.2.3 src/ICAPOptXact.h:1.1.2.1->1.1.2.2 src/ICAPOptions.cc:1.1.2.3->1.1.2.4 Index: squid3/src/ICAPOptXact.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPOptXact.cc,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid3/src/ICAPOptXact.cc 21 Sep 2005 14:38:15 -0000 1.1.2.2 +++ squid3/src/ICAPOptXact.cc 21 Sep 2005 20:34:30 -0000 1.1.2.3 @@ -117,7 +117,7 @@ ICAPOptXact::~ICAPOptXact() { stop(notifyNone); -// cbdataReferenceDone(service); + // cbdataReferenceDone(service); debug(93,0)("ICAPOptXact destructed, this=%p\n", this); if (virgin != NULL) @@ -135,7 +135,7 @@ virgin->sink = this; adapted->source = this; adapted->data = new MsgPipeData; - adapted->data->body = new MemBuf; + adapted->data->body = new MemBuf; memBufInit(adapted->data->body, ICAPMsgPipeBufSizeMin, ICAPMsgPipeBufSizeMax); memBufDefInit(&readBuf); }; @@ -144,7 +144,7 @@ { debug(93,0)("ICAPOptXact::startOptMod() called\n"); service = cbdataReference(anService); -// service = anService; + // service = anService; virgin = new MsgPipe("virgin"); leakTouch(virgin.getRaw(), leaky); @@ -160,16 +160,16 @@ leakTouch(adapted.getRaw(), leaky); adapted->sink = this; - init(virgin, adapted); + init(virgin, adapted); - virgin->sendSourceStart(); - adapted->sendSinkNeed(); + virgin->sendSourceStart(); + adapted->sendSinkNeed(); } void ICAPOptXact::startOptMod() { debug(93,0)("ICAPOptXact::startOptMod() called\n"); -// service = cbdataReference(anService); + // service = cbdataReference(anService); service = new ICAPServiceRep(); virgin = new MsgPipe("virgin"); @@ -186,10 +186,10 @@ leakTouch(adapted.getRaw(), leaky); adapted->sink = this; - init(virgin, adapted); + init(virgin, adapted); - virgin->sendSourceStart(); - adapted->sendSinkNeed(); + virgin->sendSourceStart(); + adapted->sendSinkNeed(); } @@ -205,6 +205,7 @@ if (connection < 0) throw TexcHere("cannot connect to ICAP service " /* + uri */); } + commSetTimeout(connection, Config.Timeout.connect, &ICAPOptXact_noteCommTimeout, this); @@ -256,6 +257,7 @@ leakTouch(virgin.getRaw(), leaky); #if ICAP_CLIENTSIDEHOOK_LOOPBACK + return; #else @@ -278,8 +280,8 @@ leakTouch(virgin.getRaw(), leaky); -// if (virgin->data->body->potentialSpaceSize()) -// chr->icapSpaceAvailable(); + // if (virgin->data->body->potentialSpaceSize()) + // chr->icapSpaceAvailable(); } // ICAP client aborting @@ -294,9 +296,9 @@ { debug(93,0)("ICAPOptXact::noteSourceProgress() called\n"); leakTouch(p, leaky); -// if (p->data->body->hasContent()) { -// chr->takeAdaptedBody(p->data->body); -// } + // if (p->data->body->hasContent()) { + // chr->takeAdaptedBody(p->data->body); + // } } // ICAP client is done sending adapted response @@ -342,15 +344,15 @@ freeAdapted(); } -/* - if (chr) { - if (notify == notifyOwner) - // tell ClientHttpRequest that we are aborting prematurely - chr->abortAdapting(); - cbdataReferenceDone(chr); - // chr is now NULL, will not call it any more - } -*/ + /* + if (chr) { + if (notify == notifyOwner) + // tell ClientHttpRequest that we are aborting prematurely + chr->abortAdapting(); + cbdataReferenceDone(chr); + // chr is now NULL, will not call it any more + } + */ } @@ -382,11 +384,13 @@ { if (done()) { debugs(93, 5, "ICAPOptXact::" << method << " ends xaction " << status()); - + service->icap_options = new ICAPOptions(); + if (!service->icap_options->parseResponse()) { debugs(93, 3, "ICAPOptXact::" << method << "error OPTIONS response parsing"); - } + } + doStop(); return; } @@ -429,15 +433,17 @@ state.doneReading = true; } + bool ICAPOptXact::done() const { if (notify != notifyUnknown) // mustStop() has been called return true; + return state.doneReceiving && state.doneSending && state.doneReading && state.doneWriting; } - + void ICAPOptXact::mustStop(Notify who) { Must(state.inCall); // otherwise nobody will call doStop() @@ -484,7 +490,7 @@ memBufPrintf(buf, "OPTIONS %s ICAP/1.0\r\n", service->uri); memBufPrintf(buf, "Host: %s:%d\r\n", service->host, service->port); - buf->append(crlf, 2); + buf->append(crlf, 2); } @@ -494,7 +500,7 @@ { ICAPOptXact_Enter(noteCommTimeout); -// mustStop(notifyHttp); + // mustStop(notifyHttp); ICAPOptXact_Exit(noteCommTimeout); } @@ -505,7 +511,7 @@ state.closer = NULL; ICAPOptXact_Enter(noteCommClose); -// mustStop(notifyHttp); + // mustStop(notifyHttp); ICAPOptXact_Exit(noteCommClose); } @@ -516,7 +522,7 @@ ICAPOptXact_Enter(noteCommConnected); Must(status == COMM_OK); - startReading(); + startReading(); MemBuf requestBuf; memBufDefInit(&requestBuf); @@ -553,7 +559,7 @@ state.isReading = &ICAPOptXact_noteCommRead; comm_read(connection, readBuf.space(), readBuf.spaceSize(), state.isReading, this); - } + } } void ICAPOptXact::noteCommWroteHeaders(comm_err_t status) @@ -576,7 +582,7 @@ Must(state.isReading); state.isReading = NULL; -// Must(!state.doneParsing()); + // Must(!state.doneParsing()); Must(status == COMM_OK); if (sz == 0) @@ -586,11 +592,14 @@ readBuf.appended(sz); stopReading(); + state.parsing = State::psDone; + state.doneSending = true; - + readMore(); + ICAPOptXact_Exit(noteCommRead); } Index: squid3/src/ICAPOptXact.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPOptXact.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid3/src/ICAPOptXact.h 20 Sep 2005 15:16:01 -0000 1.1.2.1 +++ squid3/src/ICAPOptXact.h 21 Sep 2005 20:35:08 -0000 1.1.2.2 @@ -1,5 +1,5 @@ /* - * $Id: ICAPOptXact.h,v 1.1.2.1 2005/09/20 15:16:01 audrus Exp $ + * $Id: ICAPOptXact.h,v 1.1.2.2 2005/09/21 20:35:08 dwsquid Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -60,7 +60,7 @@ void doneSending(); void ownerAbort(); -// int potentialSpaceSize(); + // int potentialSpaceSize(); // pipe source methods; called by ICAP while receiving the virgin message virtual void noteSinkNeed(MsgPipe *p); @@ -153,7 +153,9 @@ PF *closer; enum Parsing { psIcapHeader, psHttpHeader, psBody, psDone } parsing; - } state; + } + + state; Notify notify; Index: squid3/src/ICAPOptions.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPOptions.cc,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- squid3/src/ICAPOptions.cc 21 Sep 2005 14:38:15 -0000 1.1.2.3 +++ squid3/src/ICAPOptions.cc 21 Sep 2005 20:35:08 -0000 1.1.2.4 @@ -270,6 +270,6 @@ bool ICAPOptions::parseResponse(MemBuf *buf) { responseBuf.append(buf->content(), buf->contentSize()); - return parseResponse(); + return parseResponse(); };