/*
- * $Id: ICAPConfig.cc,v 1.3 2005/12/01 22:39:46 wessels Exp $
+ * $Id: ICAPConfig.cc,v 1.4 2005/12/02 19:43:38 wessels Exp $
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
* ----------------------------------------------------------
if (point != theService->point)
continue;
- debug(93,1)("ICAPAccessCheck::check: class '%s' has candidate service '%s'\n", theClass->key.buf(), theService->key.buf());
+ debug(93,3)("ICAPAccessCheck::check: class '%s' has candidate service '%s'\n", theClass->key.buf(), theService->key.buf());
candidateClasses += theClass->key;
* when there are no canidates, set matchedClass to NULL string
* and call the wrapper with answer = 1
*/
- debug(93,1)("ICAPAccessCheck::check: NO candidates or matches found\n");
+ debug(93,3)("ICAPAccessCheck::check: NO candidates or matches found\n");
matchedClass.clean();
return false;
}
+ if (httpHeaderHasConnDir(&head->header, "close")) {
+ debug(0,0)("%s(%d) found connection close!\n", __FILE__,__LINE__);
+ reuseConnection = false;
+ }
+
readBuf.consume(head->hdr_sz);
return true;
}
if (request->auth_user_request->username())
buf.Printf("X-Client-Username: %s\r\n", request->auth_user_request->username());
- fprintf(stderr, "%s\n", buf.content());
+ // fprintf(stderr, "%s\n", buf.content());
buf.append(ICAP::crlf, 2); // terminate ICAP header
connection(-1),
commBuf(NULL), commBufSize(0),
commEof(false),
+ reuseConnection(true),
connector(NULL), reader(NULL), writer(NULL), closer(NULL),
typeName(aTypeName),
theService(NULL),
// TODO: check whether NULL domain is appropriate here
connection = pconnPop(s.host.buf(), s.port, NULL);
+ if (connection >= 0) {
+ debug(93,3)("%s(%d) reused pconn FD %d\n", __FILE__, __LINE__, connection);
+ eventAdd("ICAPXaction::reusedConnection",
+ reusedConnection,
+ this,
+ 0.0,
+ 0,
+ true);
+ return;
+ }
+
if (connection < 0) {
connection = comm_open(SOCK_STREAM, 0, getOutgoingAddr(NULL), 0,
COMM_NONBLOCKING, s.uri.buf());
commConnectStart(connection, s.host.buf(), s.port, connector, this);
}
+/*
+ * This event handler is necessary to work around the no-rentry policy
+ * of ICAPXaction::callStart()
+ */
+void
+ICAPXaction::reusedConnection(void *data)
+{
+ debug(93,5)("ICAPXaction::reusedConnection\n");
+ ICAPXaction *x = (ICAPXaction*)data;
+ /*
+ * XXX noteCommConnected Must()s that connector is set to something;
+ */
+ x->connector = &ICAPXaction_noteCommConnected;
+ x->noteCommConnected(COMM_OK);
+}
+
void ICAPXaction::closeConnection()
{
if (connection >= 0) {
cancelRead();
- comm_close(connection);
+ if (reuseConnection) {
+ debug(93,3)("%s(%d) pushing pconn %d\n", __FILE__,__LINE__,connection);
+ pconnPush(connection, theService->host.buf(), theService->port, NULL);
+ } else {
+ debug(93,3)("%s(%d) closing pconn %d\n", __FILE__,__LINE__,connection);
+ comm_close(connection);
+ }
connector = NULL;
connection = -1;
/*
- * $Id: ICAPXaction.h,v 1.2 2005/11/21 23:46:27 wessels Exp $
+ * $Id: ICAPXaction.h,v 1.3 2005/12/02 19:43:38 wessels Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
char *commBuf;
size_t commBufSize;
bool commEof;
+ bool reuseConnection;
const char *stopReason;
const char *inCall; // name of the asynchronous call being executed, if any
+ static void ICAPXaction::reusedConnection(void *data);
+
//CBDATA_CLASS2(ICAPXaction);
};