--------------------- PatchSet 3848 Date: 2006/10/07 05:19:40 Author: rousskov Branch: squid3-icap Tag: (none) Log: - When canceling pending comm_read does not seem to work out (how can one ever be sure?), do not risk it and close the connection instead of leaving it open for other ICAP transactions to pick up. - We cannot cancel a pending comm_write at all, so if there is a write pending, close the connection instead of leaving it open for other ICAP transactions to pick up. - Polished debugging. Members: src/ICAP/ICAPXaction.cc:1.1.2.7->1.1.2.8 Index: squid3/src/ICAP/ICAPXaction.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/ICAPXaction.cc,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -u -r1.1.2.7 -r1.1.2.8 --- squid3/src/ICAP/ICAPXaction.cc 4 Oct 2006 05:00:23 -0000 1.1.2.7 +++ squid3/src/ICAP/ICAPXaction.cc 7 Oct 2006 05:19:40 -0000 1.1.2.8 @@ -68,6 +68,7 @@ theService(NULL), inCall(NULL) { + debug(93,3)("%s constructed, this=%p\n", typeName, this); readBuf.init(SQUID_TCP_SO_RCVBUF, SQUID_TCP_SO_RCVBUF); commBuf = (char*)memAllocBuf(SQUID_TCP_SO_RCVBUF, &commBufSize); // make sure maximum readBuf space does not exceed commBuf size @@ -76,6 +77,7 @@ ICAPXaction::~ICAPXaction() { + debug(93,3)("%s destructing, this=%p\n", typeName, this); doStop(); readBuf.clean(); memFreeBuf(commBufSize, commBuf); @@ -144,18 +146,25 @@ closer = NULL; } - cancelRead(); + cancelRead(); // may not work + + if (reuseConnection && (writer || reader)) { + debugs(93,5, HERE << "not reusing pconn due to pending I/O " << status()); + reuseConnection = false; + } if (reuseConnection) { - debugs(93,3, HERE << "pushing pconn " << connection); + debugs(93,3, HERE << "pushing pconn " << status()); commSetTimeout(connection, -1, NULL, NULL); icapPconnPool->push(connection, theService->host.buf(), theService->port, NULL); } else { - debugs(93,3, HERE << "closing pconn " << connection); + debugs(93,3, HERE << "closing pconn " << status()); // comm_close will clear timeout comm_close(connection); } + writer = NULL; + reader = NULL; connector = NULL; connection = -1; } @@ -320,10 +329,10 @@ // These checks try to mimic the comm_read_cancel() assertions. if (comm_has_pending_read(connection) && - !comm_has_pending_read_callback(connection)) + !comm_has_pending_read_callback(connection)) { comm_read_cancel(connection, reader, this); - - reader = NULL; + reader = NULL; + } } }