if (!entry->isEmpty())
return false;
- if (n_tries > Config.forward_max_tries)
+ if (exhaustedTries())
return false;
if (!EnoughTimeToReForward(start_t))
Comm::ConnOpener *cs = new Comm::ConnOpener(serverDestinations[0], calls.connector, connTimeout);
if (host)
cs->setHost(host);
+ ++n_tries;
AsyncJob::Start(cs);
}
return 0;
}
- if (n_tries > Config.forward_max_tries)
+ if (exhaustedTries())
return 0;
if (request->bodyNibbled())
++ FwdReplyCodes[tries][status];
}
+bool
+FwdState::exhaustedTries() const
+{
+ return n_tries >= Config.forward_max_tries;
+}
+
/**** PRIVATE NON-MEMBER FUNCTIONS ********************************************/
/*
void syncWithServerConn(const char *host);
void syncHierNote(const Comm::ConnectionPointer &server, const char *host);
+ /// whether we have used up all permitted forwarding attempts
+ bool exhaustedTries() const;
+
public:
StoreEntry *entry;
HttpRequest *request;
ErrorState *err;
Comm::ConnectionPointer clientConn; ///< a possibly open connection to the client.
time_t start_t;
- int n_tries;
+ int n_tries; ///< the number of forwarding attempts so far
// AsyncCalls which we set and may need cancelling.
struct {
TYPE: int
LOC: Config.forward_max_tries
DOC_START
- Controls how many different forward paths Squid will try
- before giving up. See also forward_timeout.
+ Limits the number of attempts to forward the request.
+
+ For the purpose of this limit, Squid counts all high-level request
+ forwarding attempts, including any same-destination retries after
+ certain persistent connection failures and any attempts to use a
+ different peer. However, low-level connection reopening attempts
+ (enabled using connect_retries) are not counted.
- NOTE: connect_retries (default: none) can make each of these
- possible forwarding paths be tried multiple times.
+ See also: forward_timeout and connect_retries.
DOC_END
COMMENT_START
DEFAULT: 0
DEFAULT_DOC: Do not retry failed connections.
DOC_START
- This sets the maximum number of connection attempts made for each
- TCP connection. The connect_retries attempts must all still
- complete within the connection timeout period.
+ Limits the number of reopening attempts when establishing a single
+ TCP connection. All these attempts must still complete before the
+ applicable connection opening timeout expires.
+
+ By default and when connect_retries is set to zero, Squid does not
+ retry failed connection opening attempts.
- The default is not to re-try if the first connection attempt fails.
- The (not recommended) maximum is 10 tries.
+ The (not recommended) maximum is 10 tries. An attempt to configure a
+ higher value results in the value of 10 being used (with a warning).
- A warning message will be generated if it is set to a too-high
- value and the configured value will be over-ridden.
+ Squid may open connections to retry various high-level forwarding
+ failures. For an outside observer, that activity may look like a
+ low-level connection reopening attempt, but those high-level retries
+ are governed by forward_max_tries instead.
- Note: These re-tries are in addition to forward_max_tries
- which limit how many different addresses may be tried to find
- a useful server.
+ See also: connect_timeout, forward_timeout, icap_connect_timeout,
+ ident_timeout, and forward_max_tries.
DOC_END
NAME: retry_on_error