void
CommCommonCbParams::print(std::ostream &os) const
{
- os << "FD " << fd;
+ if (conn != NULL)
+ os << conn;
+ else
+ os << "FD " << fd;
+
if (xerrno)
os << ", errno=" << xerrno;
if (flag != COMM_OK)
return true; // now we are in sync and can handle the call
}
-void
-CommConnectCbParams::print(std::ostream &os) const
-{
- CommCommonCbParams::print(os);
- if (conn != NULL)
- os << ", " << conn;
-}
-
/* CommIoCbParams */
CommIoCbParams::CommIoCbParams(void *aData): CommCommonCbParams(aData),
{
}
-
/* CommAcceptCbPtrFun */
CommAcceptCbPtrFun::CommAcceptCbPtrFun(IOACB *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);
}
public:
void *data; // cbdata-protected
- int fd;
+ Comm::ConnectionPointer conn;
+ int fd; // raw FD from legacy calls. use conn instead.
int xerrno;
comm_err_t flag;
CommConnectCbParams(void *aData);
bool syncWithComm(); // see CommCommonCbParams::syncWithComm
-
- void print(std::ostream &os) const;
-
-public:
- Comm::ConnectionPointer conn;
};
// read/write (I/O) parameters
#if USE_ZPH_QOS
if (Ip::Qos::TheConfig.tos_local_hit) {
debugs(33, 2, "ZPH Local hit, TOS=" << Ip::Qos::TheConfig.tos_local_hit);
- comm_set_tos(http->getConn()->fd, Ip::Qos::TheConfig.tos_local_hit);
+ comm_set_tos(http->getConn()->clientConn->fd, Ip::Qos::TheConfig.tos_local_hit);
}
#endif /* USE_ZPH_QOS */
localTempBuffer.offset = reqofs;
}
#endif
+// Legacy pre-AsyncCalls API for FD timeouts.
int
commSetTimeout(int fd, int timeout, PF * handler, void *data)
{
return commSetTimeout(fd, timeout, call);
}
-
+// Legacy pre-Comm::Connection API for FD timeouts
+// still used by non-socket FD code dealing with pipes and IPC sockets.
int
commSetTimeout(int fd, int timeout, AsyncCall::Pointer &callback)
{
}
return F->timeout;
+}
+
+int
+commSetConnTimeout(const Comm::ConnectionPointer &conn, int timeout, AsyncCall::Pointer &callback)
+{
+ debugs(5, 3, HERE << conn << " timeout " << timeout);
+ assert(Comm::IsConnOpen(conn));
+ assert(conn->fd < Squid_MaxFD);
+ fde *F = &fd_table[conn->fd];
+ assert(F->flags.open);
+
+ if (timeout < 0) {
+ F->timeoutHandler = NULL;
+ F->timeout = 0;
+ } else {
+ if (callback != NULL) {
+ typedef CommTimeoutCbParams Params;
+ Params ¶ms = GetCommParams<Params>(callback);
+ params.conn = conn;
+ F->timeoutHandler = callback;
+ }
+ F->timeout = squid_curtime + (time_t) timeout;
+ }
+
+ return F->timeout;
}
int
SQUIDCEXTERN void commCallCloseHandlers(int fd);
SQUIDCEXTERN int commSetTimeout(int fd, int, PF *, void *);
extern int commSetTimeout(int fd, int, AsyncCall::Pointer &calback);
+
+/**
+ * Set or clear the timeout for some action on an active connection.
+ * API to replace commSetTimeout() when a Comm::ConnectionPointer is available.
+ */
+extern int commSetConnTimeout(const Comm::ConnectionPointer &conn, int seconds, AsyncCall::Pointer &calback);
+
SQUIDCEXTERN int ignoreErrno(int);
SQUIDCEXTERN void commCloseAllSockets(void);
SQUIDCEXTERN void checkTimeouts(void);
urlCanonical(ex->r);
- FwdState::fwdStart(-1, ex->e, ex->r);
+ Comm::ConnectionPointer nul;
+ FwdState::fwdStart(nul, ex->e, ex->r);
#endif
}
/* push towards peer cache */
debugs(72, 3, "peerDigestRequest: forwarding to fwdStart...");
- FwdState::fwdStart(-1, e, req);
+ Comm::ConnectionPointer nul;
+ FwdState::fwdStart(nul, e, req);
tempBuffer.offset = 0;
}
void
-CacheManager::Start(int fd, HttpRequest * request, StoreEntry * entry)
+CacheManager::Start(const Comm::ConnectionPointer &conn, HttpRequest * request, StoreEntry * entry)
{
return;
}