bool
CommIoCbParams::syncWithComm()
{
+#if 0 // transition past??
// transition only: read/write legacy code does not know about conn, it just sets FD
if (fd >= 0) {
- if (conn == NULL)
+ if (conn == NULL) {
conn = new Comm::Connection;
- if (conn->fd != fd)
conn->fd = fd;
+ }
}
+#endif
// change parameters if the call was scheduled before comm_close but
// is being fired after comm_close
/* CommTimeoutCbPtrFun */
-CommTimeoutCbPtrFun::CommTimeoutCbPtrFun(PF *aHandler,
+CommTimeoutCbPtrFun::CommTimeoutCbPtrFun(CTCB *aHandler,
const CommTimeoutCbParams &aParams):
CommDialerParamsT<CommTimeoutCbParams>(aParams),
handler(aHandler)
void
CommTimeoutCbPtrFun::dial()
{
- // AYJ NP: since the old code is still used by pipes and IPC
- // we cant discard the params.fd functions entirely for old callbacks.
- // new callers supposed to only set conn.
- // sync FD and conn fields at this single failure point before dialing.
- if (params.conn != NULL) {
- if (params.fd < 0 && params.conn->fd > 0)
- params.fd = params.conn->fd;
- assert(params.fd == params.conn->fd); // Must() ?
- }
-
- handler(params.fd, params.data);
+ handler(params);
}
void
* The classes cover two call dialer kinds:
* - A C-style call using a function pointer (depricated);
* - A C++-style call to an AsyncJob child.
- * and three comm_* callback kinds:
- * - accept (IOACB),
- * - connect (CNCB),
- * - I/O (IOCB).
+ * and several comm_* callback kinds:
+ * - accept (IOACB)
+ * - connect (CNCB)
+ * - I/O (IOCB)
+ * - timeout (CTCB)
*/
typedef void IOACB(int fd, const Comm::ConnectionPointer &details, comm_err_t flag, int xerrno, void *data);
typedef void CNCB(const Comm::ConnectionPointer &conn, comm_err_t status, int xerrno, void *data);
typedef void IOCB(const Comm::ConnectionPointer &conn, char *, size_t size, comm_err_t flag, int xerrno, void *data);
+class CommTimeoutCbParams;
+typedef void CTCB(const CommTimeoutCbParams ¶ms);
+
/*
* TODO: When there are no function-pointer-based callbacks left, all
* this complexity can be removed. Jobs that need comm services will just
* \itemize On read calls this is the connection just read from.
* \itemize On close calls this describes the connection which is now closed.
* \itemize On timeouts this is the connection whose operation timed out.
- * NP: timeouts should now return to the connect/read/write handler with COMM_ERR_TIMEOUT.
+ * NP: timeouts might also return to the connect/read/write handler with COMM_ERR_TIMEOUT.
*/
Comm::ConnectionPointer conn;
public:
typedef CommTimeoutCbParams Params;
- CommTimeoutCbPtrFun(PF *aHandler, const Params &aParams);
+ CommTimeoutCbPtrFun(CTCB *aHandler, const Params &aParams);
void dial();
virtual void print(std::ostream &os) const;
public:
- PF *handler;
+ CTCB *handler;
};
// AsyncCall to comm handlers implemented as global functions.
if (reuseConnection) {
//status() adds leading spaces.
debugs(93,3, HERE << "pushing pconn" << status());
- AsyncCall::Pointer nul;
- commSetTimeout(connection->fd, -1, nul);
+ AsyncCall::Pointer nil;
+ commUnsetConnTimeout(connection);
icapPconnPool->push(connection, NULL);
disableRetries();
} else {
// TODO: service bypass status may differ from that of a transaction
typedef CommCbMemFunT<Adaptation::Icap::Xaction, CommTimeoutCbParams> TimeoutDialer;
AsyncCall::Pointer call = JobCallback(93, 5, TimeoutDialer, this, Adaptation::Icap::Xaction::noteCommTimedout);
- commSetTimeout(connection->fd, TheConfig.io_timeout(service().cfg().bypass), call);
+ commSetConnTimeout(connection, TheConfig.io_timeout(service().cfg().bypass), call);
} else {
// clear timeout when there is no I/O
// Do we need a lifetime timeout?
- AsyncCall::Pointer call = NULL;
- commSetTimeout(connection->fd, -1, call);
+ commUnsetConnTimeout(connection);
}
}
static IOACB httpAccept;
static IOACB httpsAccept;
static bool clientParseRequest(ConnStateData * conn, bool &do_next_read);
-static PF clientLifetimeTimeout;
+static CTCB clientLifetimeTimeout;
static ClientSocketContext *parseHttpRequestAbort(ConnStateData * conn, const char *uri);
static ClientSocketContext *parseHttpRequest(ConnStateData *, HttpParser *, HttpRequestMethod *, HttpVersion *);
#if USE_IDENT
typedef CommCbMemFunT<ConnStateData, CommTimeoutCbParams> TimeoutDialer;
AsyncCall::Pointer timeoutCall = JobCallback(33, 5,
TimeoutDialer, this, ConnStateData::requestTimeout);
- commSetTimeout(clientConn->fd, Config.Timeout.persistent_request, timeoutCall);
+ commSetConnTimeout(clientConn, Config.Timeout.persistent_request, timeoutCall);
readSomeData();
/** Please don't do anything with the FD past here! */
/* status -1 or 1 */
if (context) {
debugs(33, 5, HERE << conn->clientConn << ": parsed a request");
- commSetTimeout(conn->clientConn->fd, Config.Timeout.lifetime, clientLifetimeTimeout,
- context->http);
+ AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "clientLifetimeTimeout",
+ CommTimeoutCbPtrFun(clientLifetimeTimeout, context->http));
+ commSetConnTimeout(conn->clientConn, Config.Timeout.lifetime, timeoutCall);
clientProcessRequest(conn, &hp, context, method, http_ver);
typedef CommCbMemFunT<ConnStateData, CommTimeoutCbParams> TimeoutDialer;
AsyncCall::Pointer timeoutCall = JobCallback(33, 5,
TimeoutDialer, this, ConnStateData::requestTimeout);
- commSetTimeout(io.fd, 30, timeoutCall);
+ commSetConnTimeout(io.conn, 30, timeoutCall);
/*
* Aha, but we don't want a read handler!
* connection)
*/
debugs(33, 3, "requestTimeout: FD " << io.fd << ": lifetime is expired.");
-
- clientConn->close();
-
+ io.conn->close();
#endif
}
static void
-clientLifetimeTimeout(int fd, void *data)
+clientLifetimeTimeout(const CommTimeoutCbParams &io)
{
- ClientHttpRequest *http = (ClientHttpRequest *)data;
+ ClientHttpRequest *http = static_cast<ClientHttpRequest *>(io.data);
debugs(33, DBG_IMPORTANT, "WARNING: Closing client connection due to lifetime timeout");
debugs(33, DBG_IMPORTANT, "\t" << http->uri);
http->al.http.timedout = true;
- if (http->getConn() && Comm::IsConnOpen(http->getConn()->clientConn))
- http->getConn()->clientConn->close();
+ if (Comm::IsConnOpen(io.conn))
+ io.conn->close();
}
ConnStateData *
typedef CommCbMemFunT<ConnStateData, CommTimeoutCbParams> TimeoutDialer;
AsyncCall::Pointer timeoutCall = JobCallback(33, 5,
TimeoutDialer, connState, ConnStateData::requestTimeout);
- commSetTimeout(details->fd, Config.Timeout.read, timeoutCall);
+ commSetConnTimeout(details, Config.Timeout.read, timeoutCall);
#if USE_IDENT
if (Ident::TheConfig.identLookup) {
typedef CommCbMemFunT<ConnStateData, CommTimeoutCbParams> TimeoutDialer;
AsyncCall::Pointer timeoutCall = JobCallback(33, 5,
TimeoutDialer, connState, ConnStateData::requestTimeout);
- commSetTimeout(details->fd, Config.Timeout.request, timeoutCall);
+ commSetConnTimeout(details, Config.Timeout.request, timeoutCall);
#if USE_IDENT
if (Ident::TheConfig.identLookup) {
if (!(ssl = httpsCreate(clientConn, sslContext)))
return false;
- // commSetTimeout() was called for this request before we switched.
+ // commSetConnTimeout() was called for this request before we switched.
// Disable the client read handler until peer selection is complete
commSetSelect(clientConn->fd, COMM_SELECT_READ, NULL, NULL, 0);
#if 0
int
-commSetTimeout_old(int fd, int timeout, PF * handler, void *data)
+commSetTimeout_old(int fd, int timeout, CTCB * handler, void *data)
{
debugs(5, 3, HERE << "FD " << fd << " timeout " << timeout);
assert(fd >= 0);
// Legacy pre-AsyncCalls API for FD timeouts.
int
-commSetTimeout(int fd, int timeout, PF * handler, void *data)
+commSetTimeout(int fd, int timeout, CTCB * handler, void *data)
{
AsyncCall::Pointer call;
debugs(5, 3, HERE << "FD " << fd << " timeout " << timeout);
return F->timeout;
}
+int
+commUnsetConnTimeout(const Comm::ConnectionPointer &conn)
+{
+ debugs(5, 3, HERE << "Remove timeout for " << conn);
+ AsyncCall::Pointer nil;
+ return commSetConnTimeout(conn, -1, nil);
+}
+
int
comm_connect_addr(int sock, const Ip::Address &address)
{
SQUIDCEXTERN int comm_udp_sendto(int sock, const Ip::Address &to, const void *buf, int buflen);
SQUIDCEXTERN void commCallCloseHandlers(int fd);
-SQUIDCEXTERN int commSetTimeout(int fd, int, PF *, void *);
+SQUIDCEXTERN int commSetTimeout(int fd, int, CTCB *, void *);
extern int commSetTimeout(int fd, int, AsyncCall::Pointer &callback);
/**
* API to replace commSetTimeout() when a Comm::ConnectionPointer is available.
*/
extern int commSetConnTimeout(const Comm::ConnectionPointer &conn, int seconds, AsyncCall::Pointer &callback);
+extern int commUnsetConnTimeout(const Comm::ConnectionPointer &conn);
SQUIDCEXTERN int ignoreErrno(int);
SQUIDCEXTERN void commCloseAllSockets(void);
if (conn_ != NULL && conn_->isOpen()) {
// drop any handlers now to save a lot of cycles later
commSetSelect(conn_->fd, COMM_SELECT_WRITE, NULL, NULL, 0);
- commSetTimeout(conn_->fd, -1, NULL, NULL);
+ commUnsetConnTimeout(conn_);
// it never reached fully open, so abort the FD
conn_->close();
}
typedef CommCbMemFunT<Comm::ConnOpener, CommTimeoutCbParams> timeoutDialer;
calls_.timeout_ = JobCallback(5, 4, timeoutDialer, this, Comm::ConnOpener::timeout);
debugs(5, 3, HERE << conn_ << " timeout " << connectTimeout_);
- commSetTimeout(conn_->fd, connectTimeout_, calls_.timeout_);
+ commSetConnTimeout(conn_, connectTimeout_, calls_.timeout_);
connectStart_ = squid_curtime;
connect();
/**
* Handles the case(s) when a partially setup connection gets timed out.
- * NP: When commSetTimeout accepts generic CommCommonCbParams this can die.
+ * NP: When commSetConnTimeout accepts generic CommCommonCbParams this can die.
*/
void
Comm::ConnOpener::timeout(const CommTimeoutCbParams &)
vc->busy = 1;
- commSetTimeout(vc->conn->fd, Config.Timeout.idns_query, NULL, NULL);
+ AsyncCall::Pointer nil;
+ commSetConnTimeout(vc->conn, Config.Timeout.idns_query, nil);
AsyncCall::Pointer call = commCbCall(78, 5, "idnsSentQueryVC",
CommIoCbPtrFun(&idnsSentQueryVC, vc));
void
FtpStateData::switchTimeoutToDataChannel()
{
- AsyncCall::Pointer nullCall = NULL;
- commSetTimeout(ctrl.conn->fd, -1, nullCall);
+ commUnsetConnTimeout(ctrl.conn);
typedef CommCbMemFunT<FtpStateData, CommTimeoutCbParams> TimeoutDialer;
AsyncCall::Pointer timeoutCall = JobCallback(9, 5, TimeoutDialer, this, FtpStateData::ftpTimeout);
- commSetTimeout(data.conn->fd, Config.Timeout.read, timeoutCall);
+ commSetConnTimeout(data.conn, Config.Timeout.read, timeoutCall);
}
void
void
FtpStateData::ftpTimeout(const CommTimeoutCbParams &io)
{
- debugs(9, 4, "ftpTimeout: FD " << io.fd << ": '" << entry->url() << "'" );
+ debugs(9, 4, HERE << io.conn << ": '" << entry->url() << "'" );
- if (SENT_PASV == state && io.fd == data.conn->fd) {
+ if (SENT_PASV == state && io.conn->fd == data.conn->fd) {
/* stupid ftp.netscape.com */
flags.pasv_supported = false;
debugs(9, DBG_IMPORTANT, "ftpTimeout: timeout in SENT_PASV state" );
typedef CommCbMemFunT<FtpStateData, CommTimeoutCbParams> TimeoutDialer;
AsyncCall::Pointer timeoutCall = JobCallback(9, 5,
TimeoutDialer, this, FtpStateData::ftpTimeout);
- commSetTimeout(data.conn->fd, Config.Timeout.read, timeoutCall);
+ commSetConnTimeout(data.conn, Config.Timeout.read, timeoutCall);
debugs(9,5,HERE << "queueing read on FD " << data.conn->fd);
typedef CommCbMemFunT<FtpStateData, CommTimeoutCbParams> TimeoutDialer;
AsyncCall::Pointer timeoutCall = JobCallback(9, 5,
TimeoutDialer, this, FtpStateData::ftpTimeout);
- commSetTimeout(io.fd, Config.Timeout.read, timeoutCall);
+ commSetConnTimeout(io.conn, Config.Timeout.read, timeoutCall);
maybeReadVirginBody();
} else {
* establish one on the control socket.
*/
if (Comm::IsConnOpen(data.conn)) {
- AsyncCall::Pointer nullCall = NULL;
- commSetTimeout(data.conn->fd, -1, nullCall);
+ commUnsetConnTimeout(data.conn);
}
typedef CommCbMemFunT<FtpStateData, CommTimeoutCbParams> TimeoutDialer;
AsyncCall::Pointer timeoutCall = JobCallback(9, 5, TimeoutDialer, this, FtpStateData::ftpTimeout);
- commSetTimeout(ctrl.conn->fd, Config.Timeout.read, timeoutCall);
+ commSetConnTimeout(ctrl.conn, Config.Timeout.read, timeoutCall);
typedef CommCbMemFunT<FtpStateData, CommIoCbParams> Dialer;
AsyncCall::Pointer reader = JobCallback(9, 5, Dialer, this, FtpStateData::ftpReadControlReply);
typedef CommCbMemFunT<FtpStateData, CommTimeoutCbParams> TimeoutDialer;
AsyncCall::Pointer timeoutCall = JobCallback(9, 5,
TimeoutDialer, ftpState, FtpStateData::ftpTimeout);
-
- commSetTimeout(ftpState->ctrl.conn->fd, Config.Timeout.connect, timeoutCall);
+ commSetConnTimeout(ftpState->ctrl.conn, Config.Timeout.connect, timeoutCall);
}
void
char *request);
static void gopherEndHTML(GopherStateData *);
static void gopherToHTML(GopherStateData *, char *inbuf, int len);
-static PF gopherTimeout;
+static CTCB gopherTimeout;
static IOCB gopherReadReply;
static IOCB gopherSendComplete;
static PF gopherSendRequest;
/// \ingroup ServerProtocolGopherInternal
static void
-gopherTimeout(int fd, void *data)
+gopherTimeout(const CommTimeoutCbParams &io)
{
- GopherStateData *gopherState = (GopherStateData *)data;
- debugs(10, 4, HERE << gopherState->serverConn << ": '" << gopherState->entry->url() << "'" );
+ GopherStateData *gopherState = static_cast<GopherStateData *>(io.data);
+ debugs(10, 4, HERE << io.conn << ": '" << gopherState->entry->url() << "'" );
gopherState->fwd->fail(errorCon(ERR_READ_TIMEOUT, HTTP_GATEWAY_TIMEOUT, gopherState->fwd->request));
- if (Comm::IsConnOpen(gopherState->serverConn))
- gopherState->serverConn->close();
+ if (Comm::IsConnOpen(io.conn))
+ io.conn->close();
}
/**
kb_incr(&statCounter.server.all.kbytes_in, len);
kb_incr(&statCounter.server.other.kbytes_in, len);
- commSetTimeout(conn->fd, Config.Timeout.read, NULL, NULL);
+ AsyncCall::Pointer nil;
+ commSetConnTimeout(conn, Config.Timeout.read, nil);
IOStats.Gopher.reads++;
for (clen = len - 1, bin = 0; clen; bin++)
}
/* Schedule read reply. */
- AsyncCall::Pointer call = commCbCall(10,5, "gopherReadReply",
+ AsyncCall::Pointer call = commCbCall(5,5, "gopherReadReply",
CommIoCbPtrFun(gopherReadReply, gopherState));
entry->delayAwareRead(conn, gopherState->replybuf, BUFSIZ, call);
gopherState->serverConn = fwd->serverConnection();
gopherSendRequest(fwd->serverConnection()->fd, gopherState);
- commSetTimeout(fwd->serverConnection()->fd, Config.Timeout.read, gopherTimeout, gopherState);
+ AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "gopherTimeout",
+ CommTimeoutCbPtrFun(gopherTimeout, gopherState));
+ commSetConnTimeout(fwd->serverConnection(), Config.Timeout.read, timeoutCall);
}
void
HttpStateData::processReplyBody()
{
- AsyncCall::Pointer call;
Ip::Address client_addr;
bool ispinned = false;
} else
switch (persistentConnStatus()) {
case INCOMPLETE_MSG:
+ {
debugs(11, 5, "processReplyBody: INCOMPLETE_MSG from " << serverConnection);
/* Wait for more data or EOF condition */
+ AsyncCall::Pointer nil;
if (flags.keepalive_broken) {
- call = NULL;
- commSetTimeout(serverConnection->fd, 10, call);
+ commSetConnTimeout(serverConnection, 10, nil);
} else {
- call = NULL;
- commSetTimeout(serverConnection->fd, Config.Timeout.read, call);
+ commSetConnTimeout(serverConnection, Config.Timeout.read, nil);
}
flags.do_next_read = 1;
+ }
break;
case COMPLETE_PERSISTENT_MSG:
debugs(11, 5, "processReplyBody: COMPLETE_PERSISTENT_MSG from " << serverConnection);
/* yes we have to clear all these! */
- call = NULL;
- commSetTimeout(serverConnection->fd, -1, call);
+ commUnsetConnTimeout(serverConnection);
flags.do_next_read = 0;
comm_remove_close_handler(serverConnection->fd, closeHandler);
AsyncCall::Pointer timeoutCall = JobCallback(11, 5,
TimeoutDialer, this, HttpStateData::httpTimeout);
- commSetTimeout(serverConnection->fd, Config.Timeout.read, timeoutCall);
+ commSetConnTimeout(serverConnection, Config.Timeout.read, timeoutCall);
flags.request_sent = 1;
typedef CommCbMemFunT<HttpStateData, CommTimeoutCbParams> TimeoutDialer;
AsyncCall::Pointer timeoutCall = JobCallback(11, 5,
TimeoutDialer, this, HttpStateData::httpTimeout);
- commSetTimeout(serverConnection->fd, Config.Timeout.lifetime, timeoutCall);
+ commSetConnTimeout(serverConnection, Config.Timeout.lifetime, timeoutCall);
flags.do_next_read = 1;
maybeReadVirginBody();
// TODO: make these all a series of Async job calls. They are self-contained callbacks now.
static IOCB ReadReply;
static PF Close;
-static PF Timeout;
+static CTCB Timeout;
static CNCB ConnectDone;
static hash_table *ident_hash = NULL;
static void ClientAdd(IdentStateData * state, IDCB * callback, void *callback_data);
}
void
-Ident::Timeout(int fd, void *data)
+Ident::Timeout(const CommTimeoutCbParams &io)
{
- IdentStateData *state = (IdentStateData *)data;
- debugs(30, 3, HERE << "FD " << fd << ", " << state->conn->remote);
- state->conn->close();
+ debugs(30, 3, HERE << io.conn);
+ io.conn->close();
}
void
conn->local.GetPort());
AsyncCall::Pointer nil;
Comm::Write(conn, &mb, nil);
- AsyncCall::Pointer call = commCbCall(5,4, "Ident::ReadReply",
- CommIoCbPtrFun(Ident::ReadReply, state));
- comm_read(conn, state->buf, IDENT_BUFSIZE, call);
- commSetTimeout(conn->fd, Ident::TheConfig.timeout, Ident::Timeout, state);
+ AsyncCall::Pointer readCall = commCbCall(5,4, "Ident::ReadReply",
+ CommIoCbPtrFun(Ident::ReadReply, state));
+ comm_read(conn, state->buf, IDENT_BUFSIZE, readCall);
+ AsyncCall::Pointer timeoutCall = commCbCall(5,4, "Ident::Timeout",
+ CommTimeoutCbPtrFun(Ident::Timeout, state));
+ commSetConnTimeout(conn, Ident::TheConfig.timeout, timeoutCall);
}
void
typedef CommCbMemFunT<UdsOp, CommTimeoutCbParams> Dialer;
AsyncCall::Pointer handler = asyncCall(54,5, handlerName,
Dialer(CbcPointer<UdsOp>(this), &UdsOp::noteTimeout));
- commSetTimeout(conn()->fd, seconds, handler);
+ commSetConnTimeout(conn(), seconds, handler);
}
void Ipc::UdsOp::clearTimeout()
{
- commSetTimeout(conn()->fd, -1, NULL, NULL); // TODO: add Comm::ClearTimeout(fd)
+ commUnsetConnTimeout(conn());
}
void Ipc::UdsOp::noteTimeout(const CommTimeoutCbParams &)
{
debugs(48, 3, HERE << "removing close handler for " << conn);
comm_read_cancel(conn->fd, IdleConnList::Read, this);
- commSetTimeout(conn->fd, -1, NULL, NULL);
+ commUnsetConnTimeout(conn);
}
void
}
theList_[size_++] = conn;
- AsyncCall::Pointer call = commCbCall(5,4, "IdleConnList::Read",
- CommIoCbPtrFun(IdleConnList::Read, this));
- comm_read(conn, fakeReadBuf_, sizeof(fakeReadBuf_), call);
- commSetTimeout(conn->fd, Config.Timeout.pconn, IdleConnList::Timeout, this);
+ AsyncCall::Pointer readCall = commCbCall(5,4, "IdleConnList::Read",
+ CommIoCbPtrFun(IdleConnList::Read, this));
+ comm_read(conn, fakeReadBuf_, sizeof(fakeReadBuf_), readCall);
+ AsyncCall::Pointer timeoutCall = commCbCall(5,4, "IdleConnList::Read",
+ CommTimeoutCbPtrFun(IdleConnList::Timeout, this));
+ commSetConnTimeout(conn, Config.Timeout.pconn, timeoutCall);
}
/*
}
void
-IdleConnList::Timeout(int fd, void *data)
+IdleConnList::Timeout(const CommTimeoutCbParams &io)
{
- debugs(48, 3, HERE << "FD " << fd);
- IdleConnList *list = (IdleConnList *) data;
- Comm::ConnectionPointer temp = new Comm::Connection; // XXX: transition. make timeouts pass conn in
- temp->fd = fd;
- int index = list->findIndexOf(temp);
+ debugs(48, 3, HERE << io.conn);
+ IdleConnList *list = static_cast<IdleConnList *>(io.data);
+ int index = list->findIndexOf(io.conn);
if (index >= 0) {
/* might delete list */
list->removeAt(index);
- temp->close();
- } else
- temp->fd = -1; // XXX: transition. prevent temp erasure double-closing FD until timeout CB passess conn in.
+ io.conn->close();
+ }
}
/* ========== PconnPool PRIVATE FUNCTIONS ============================================ */
bool removeAt(int index);
int findIndexOf(const Comm::ConnectionPointer &conn) const;
static IOCB Read;
- static PF Timeout;
+ static CTCB Timeout;
public:
hash_link hash; /** must be first */
static ERCB tunnelErrorComplete;
static PF tunnelServerClosed;
static PF tunnelClientClosed;
-static PF tunnelTimeout;
+static CTCB tunnelTimeout;
static PSC tunnelPeerSelectComplete;
static void tunnelStateFree(TunnelStateData * tunnelState);
static void tunnelConnected(const Comm::ConnectionPointer &server, void *);
cbdataInternalLock(this); /* ??? should be locked by the caller... */
/* Bump the source connection read timeout on any activity */
- if (Comm::IsConnOpen(from.conn))
- commSetTimeout(from.conn->fd, Config.Timeout.read, tunnelTimeout, this);
+ if (Comm::IsConnOpen(from.conn)) {
+ AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "tunnelTimeout",
+ CommTimeoutCbPtrFun(tunnelTimeout, this));
+ commSetConnTimeout(from.conn, Config.Timeout.read, timeoutCall);
+ }
if (len < 0 || errcode)
from.error (xerrno);
}
static void
-tunnelTimeout(int fd, void *data)
+tunnelTimeout(const CommTimeoutCbParams &io)
{
- TunnelStateData *tunnelState = (TunnelStateData *)data;
- debugs(26, 3, "tunnelTimeout: FD " << fd);
+ TunnelStateData *tunnelState = static_cast<TunnelStateData *>(io.data);
+ debugs(26, 3, HERE << io.conn);
/* Temporary lock to protect our own feets (comm_close -> tunnelClientClosed -> Free) */
cbdataInternalLock(tunnelState);
tunnelConnected(conn, tunnelState);
}
- commSetTimeout(conn->fd, Config.Timeout.read, tunnelTimeout, tunnelState);
+ AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "tunnelTimeout",
+ CommTimeoutCbPtrFun(tunnelTimeout, tunnelState));
+ commSetConnTimeout(conn, Config.Timeout.read, timeoutCall);
}
extern tos_t GetTosToServer(HttpRequest * request);
comm_add_close_handler(tunnelState->client.conn->fd,
tunnelClientClosed,
tunnelState);
- commSetTimeout(tunnelState->client.conn->fd,
- Config.Timeout.lifetime,
- tunnelTimeout,
- tunnelState);
+
+ AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "tunnelTimeout",
+ CommTimeoutCbPtrFun(tunnelTimeout, tunnelState));
+ commSetConnTimeout(tunnelState->client.conn, Config.Timeout.lifetime, timeoutCall);
peerSelect(&(tunnelState->serverDestinations), request,
NULL,
packerClean(&p);
mb.append("\r\n", 2);
- AsyncCall::Pointer call = commCbCall(5,5, "tunnelConnectedWriteDone",
- CommIoCbPtrFun(tunnelConnectedWriteDone, tunnelState));
- Comm::Write(srv, &mb, call);
- commSetTimeout(srv->fd, Config.Timeout.read, tunnelTimeout, tunnelState);
+ AsyncCall::Pointer writeCall = commCbCall(5,5, "tunnelConnectedWriteDone",
+ CommIoCbPtrFun(tunnelConnectedWriteDone, tunnelState));
+ Comm::Write(srv, &mb, writeCall);
+
+ AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "tunnelTimeout",
+ CommTimeoutCbPtrFun(tunnelTimeout, tunnelState));
+ commSetConnTimeout(srv, Config.Timeout.read, timeoutCall);
}
static void
};
static PF whoisClose;
-static PF whoisTimeout;
+static CTCB whoisTimeout;
static IOCB whoisReadReply;
/* PUBLIC */
AsyncCall::Pointer readCall = commCbCall(5,4, "whoisReadReply",
CommIoCbPtrFun(whoisReadReply, p));
comm_read(fwd->serverConnection(), p->buf, BUFSIZ, readCall);
- commSetTimeout(fwd->serverConnection()->fd, Config.Timeout.read, whoisTimeout, p);
+ AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "whoisTimeout",
+ CommTimeoutCbPtrFun(whoisTimeout, p));
+ commSetConnTimeout(fwd->serverConnection(), Config.Timeout.read, timeoutCall);
}
/* PRIVATE */
static void
-whoisTimeout(int fd, void *data)
+whoisTimeout(const CommTimeoutCbParams &io)
{
- WhoisState *p = (WhoisState *)data;
- debugs(75, 1, "whoisTimeout: " << p->entry->url() );
- whoisClose(fd, p);
+ WhoisState *p = static_cast<WhoisState *>(io.data);
+ debugs(75, 3, HERE << io.conn << ", URL " << p->entry->url());
+ io.conn->close();
}
static void