--------------------- PatchSet 1583 Date: 2005/08/24 15:15:20 Author: rousskov Branch: squid3-icap Tag: (none) Log: - Stop reading when we read everything we wanted so that the transaction can finish. - Report transasction status when entering and exiting async calls. Members: src/ICAPXaction.cc:1.1.2.4->1.1.2.5 src/ICAPXaction.h:1.1.2.3->1.1.2.4 Index: squid3/src/ICAPXaction.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPXaction.cc,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- squid3/src/ICAPXaction.cc 24 Aug 2005 14:21:17 -0000 1.1.2.4 +++ squid3/src/ICAPXaction.cc 24 Aug 2005 15:15:20 -0000 1.1.2.5 @@ -178,8 +178,7 @@ commSetTimeout(connection, -1, NULL, NULL); comm_remove_close_handler(connection, &ICAPXaction_noteCommClose, this); - if (state.isReading) - comm_read_cancel(connection, state.isReading, this); + stopReading(); comm_close(connection); connection = -1; } @@ -325,7 +324,7 @@ debugs(93, 5, "read " << sz << " bytes"); if (sz == 0) - state.doneReading = true; + stopReading(); else if (sz > 0) readBuf.appended(sz); @@ -336,6 +335,14 @@ ICAPXaction_Exit(noteCommRead); } +void ICAPXaction::stopReading() { + if (state.isReading) { + comm_read_cancel(connection, state.isReading, this); + state.isReading = NULL; + } + state.doneReading = true; +} + void ICAPXaction::parseMore() { debugs(93, 5, "have " << readBuf.contentSize() << " bytes to parse" << "; state: " << state.parsing); @@ -397,7 +404,7 @@ return; } - // XXX: check whether we must assert state.doneReading; pconns? + stopReading(); state.parsing = State::psDone; state.doneSending = true; adapted->sendSourceFinish(); @@ -551,7 +558,7 @@ } bool ICAPXaction::callStart(const char *method) { - debugs(93, 5, "ICAPXaction::" << method << " called."); + debugs(93, 5, "ICAPXaction::" << method << " called " << status()); if (state.inCall) { // this may happen when we have bugs or when arguably buggy // comm interface calls us while we are closing the connection @@ -565,21 +572,41 @@ void ICAPXaction::callException(const char *method, const TextException &e, Notify defaultWho) { debugs(93, 4, "ICAPXaction::" << method << " caught an exception: " << - e.message); + e.message << ' ' << status()); if (!done()) mustStop(defaultWho); } void ICAPXaction::callEnd(const char *method) { - debugs(93, 5, "ICAPXaction::" << method << " ending"); - if (done()) { + debugs(93, 5, "ICAPXaction::" << method << " ends xaction " << + status()); doStop(); return; } - debugs(93, 5, "ICAPXaction continues after " << method); - - debugs(93, 6, "ICAPXaction::" << method << " ended"); + debugs(93, 6, "ICAPXaction::" << method << " ended " << status()); state.inCall = false; } + +// returns a temporary string depicting transaction status, for debugging +const char *ICAPXaction::status() const { + static MemBuf status; + memBufReset(&status); + + status.append("[", 1); + if (notify != notifyUnknown) + memBufPrintf(&status, "N(%d)", notify); + if (state.doneReceiving) + status.append("R", 1); + if (state.doneSending) + status.append("S", 1); + if (state.doneReading) + status.append("r", 1); + if (state.doneWriting) + status.append("w", 1); + status.append("]", 1); + + status.terminate(); + return status.content(); +} Index: squid3/src/ICAPXaction.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPXaction.h,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/ICAPXaction.h 24 Aug 2005 06:19:14 -0000 1.1.2.3 +++ squid3/src/ICAPXaction.h 24 Aug 2005 15:15:20 -0000 1.1.2.4 @@ -1,6 +1,6 @@ /* - * $Id: ICAPXaction.h,v 1.1.2.3 2005/08/24 06:19:14 rousskov Exp $ + * $Id: ICAPXaction.h,v 1.1.2.4 2005/08/24 15:15:20 rousskov Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -99,12 +99,16 @@ notifyAll } Notify; void mustStop(Notify who); void doStop(); + void stopReading(); bool callStart(const char *method); void callException(const char *method, const TextException &e, Notify who); void callEnd(const char *method); private: + // returns a temporary string depicting transaction status, for debugging + const char *status() const; + Pointer self; MsgPipe *virgin; MsgPipe *adapted;