Resolve a TODO in the code.
#include "NeighborTypeDomainList.h"
#include "pconn.h"
#include "PeerPoolMgr.h"
+#include "SquidConfig.h"
CBDATA_CLASS_INIT(CachePeer);
xfree(domain);
}
+time_t
+CachePeer::connectTimeout() const
+{
+ if (connect_timeout_raw > 0)
+ return connect_timeout_raw;
+ return Config.Timeout.peer_connect;
+}
+
CachePeer() = default;
~CachePeer();
+ /// \returns the effective connect timeout for the given peer
+ time_t connectTimeout() const;
+
u_int index = 0;
char *name = nullptr;
char *host = nullptr;
} sourcehash;
char *login = nullptr; /* Proxy authorization */
- time_t connect_timeout_raw = 0; ///< connect_timeout; use peerConnectTimeout() instead!
+ time_t connect_timeout_raw = 0; ///< connect_timeout; use connectTimeout() instead!
int connect_fail_limit = 0;
int max_conn = 0;
};
#endif /* SQUID_CACHEPEER_H_ */
-
tests_testRock_SOURCES = \
AccessLogEntry.cc \
AccessLogEntry.h \
+ tests/stub_CachePeer.cc \
cbdata.cc \
CacheDigest.h \
CollapsedForwarding.h \
AccessLogEntry.h \
tests/testUfs.cc \
tests/testUfs.h \
+ tests/stub_CachePeer.cc \
tests/stub_cache_manager.cc \
tests/stub_client_db.cc \
tests/stub_CollapsedForwarding.cc \
AccessLogEntry.h \
CacheDigest.h \
tests/stub_CacheDigest.cc \
+ tests/stub_CachePeer.cc \
cbdata.cc \
client_db.h \
ClientInfo.h \
securer = asyncCall(48, 4, "PeerPoolMgr::handleSecuredPeer",
MyAnswerDialer(this, &PeerPoolMgr::handleSecuredPeer));
- const int peerTimeout = peerConnectTimeout(peer);
+ const auto peerTimeout = peer->connectTimeout();
const int timeUsed = squid_curtime - params.conn->startTime();
// Use positive timeout when less than one second is left for conn.
const int timeLeft = positiveTimeout(peerTimeout - timeUsed);
getOutgoingAddress(request.getRaw(), conn);
GetMarkingsToServer(request.getRaw(), *conn);
- const int ctimeout = peerConnectTimeout(peer);
+ const auto ctimeout = peer->connectTimeout();
typedef CommCbMemFunT<PeerPoolMgr, CommConnectCbParams> Dialer;
opener = JobCallback(48, 5, Dialer, this, PeerPoolMgr::handleOpenedConnection);
Comm::ConnOpener *cs = new Comm::ConnOpener(conn, opener, ctimeout);
{
// a connection opening timeout (ignoring forwarding time limits for now)
const CachePeer *peer = getPeer();
- const time_t ctimeout = peer ? peerConnectTimeout(peer) : Config.Timeout.connect;
+ const auto ctimeout = peer ? peer->connectTimeout() : Config.Timeout.connect;
// time we have left to finish the whole forwarding process
const time_t fwdTimeLeft = FwdState::ForwardTimeout(fwdStart);
return 1;
}
-/// \returns the effective connect timeout for this peer
-time_t
-peerConnectTimeout(const CachePeer *peer)
-{
- return peer->connect_timeout_raw > 0 ?
- peer->connect_timeout_raw : Config.Timeout.peer_connect;
-}
-
time_t
positiveTimeout(const time_t timeout)
{
}
p->reprobe = false;
- const time_t ctimeout = peerConnectTimeout(p);
+ const auto ctimeout = p->connectTimeout();
/* for each IP address of this CachePeer. find one that we can connect to and probe it. */
for (int i = 0; i < p->n_addresses; ++i) {
Comm::ConnectionPointer conn = new Comm::Connection;
void dump_peer_options(StoreEntry *, CachePeer *);
int peerHTTPOkay(const CachePeer *, PeerSelector *);
-// TODO: Consider moving this method to CachePeer class.
-/// \returns the effective connect timeout for the given peer
-time_t peerConnectTimeout(const CachePeer *peer);
-
/// \returns max(1, timeout)
time_t positiveTimeout(const time_t timeout);
--- /dev/null
+/*
+ * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#include "squid.h"
+
+#define STUB_API "CachePeer.cc"
+#include "tests/STUB.h"
+
+#include "CachePeer.h"
+
+time_t CachePeer::connectTimeout() const STUB_RETVAL(0)
void
peerConnClosed(CachePeer *p) STUB
-time_t
-peerConnectTimeout(const CachePeer *peer) STUB_RETVAL(0)
time_t
FwdState::ForwardTimeout(const time_t) STUB_RETVAL(0)
bool