HappyConnOpener.cc
Go to the documentation of this file.
115 SpareAllowanceGiver(): HappyOrderEnforcer("happy_eyeballs_connect_gap/happy_eyeballs_connect_limit enforcement") {}
189HappyOrderEnforcer::startedWaiting(const HappyAbsoluteTime lastStart, const int cfgTimeoutMsec) const
208 eventAdd(name, &HappyOrderEnforcer::NoteWaitOver, const_cast<HappyOrderEnforcer*>(this), waitTime, 0, false);
330HappyConnOpener::HappyConnOpener(const ResolvedPeers::Pointer &dests, const AsyncCallback<Answer> &callback, const HttpRequest::Pointer &request, const time_t aFwdStart, const int tries, const AccessLogEntry::Pointer &anAle):
417std::ostream &
499HappyConnOpener::sendSuccess(const PeerConnectionPointer &conn, const bool reused, const char *connKind)
616HappyConnOpener::handleConnOpenerAnswer(Attempt &attempt, const CommConnectCbParams ¶ms, const char *what)
740 } else if (currentPeer && !spareWaiting.forNewPeer && spareWaiting && destinations->doneWithSpares(*currentPeer)) {
RefCount< AsyncCallT< Dialer > > asyncCall(int aDebugSection, int aDebugLevel, const char *aName, const Dialer &aDialer)
Definition: AsyncCall.h:156
#define CallJobHere(debugSection, debugLevel, job, Class, method)
Definition: AsyncJobCalls.h:58
void NoteOutgoingConnectionFailure(CachePeer *const peer, const Http::StatusCode code)
Definition: CachePeer.h:243
void CallBack(const CodeContext::Pointer &callbackContext, Fun &&callback)
Definition: CodeContext.h:116
PconnPool * fwdPconnPool
a collection of previously used persistent Squid-to-peer HTTP(S) connections
Definition: FwdState.cc:78
void GetMarkingsToServer(HttpRequest *request, Comm::Connection &conn)
Definition: FwdState.cc:1555
std::ostream & operator<<(std::ostream &os, const HappyConnOpenerAnswer &answer)
reports Answer details (for AsyncCall parameter debugging)
Definition: HappyConnOpener.cc:86
std::list< CbcPointer< HappyConnOpener > > HappySpareWaitList
A FIFO queue of HappyConnOpener jobs waiting to open a spare connection.
Definition: HappyConnOpener.h:30
double HappyAbsoluteTime
absolute time in fractional seconds; compatible with current_timed
Definition: HappyConnOpener.h:33
a smart AsyncCall pointer for delivery of future results
Definition: AsyncCallbacks.h:32
Definition: AsyncJob.h:32
Definition: CommCalls.h:166
Definition: CommCalls.h:105
Definition: ConnOpener.h:25
time_t connectTimeout(const time_t fwdStart) const
Definition: Connection.cc:164
ConnectionPointer cloneProfile() const
Create a new closed Connection with the same configuration as this one.
Definition: Connection.cc:64
Definition: errorpage.h:89
static time_t ForwardTimeout(const time_t fwdStart)
time left to finish the whole forwarding process (which started at fwdStart)
Definition: FwdState.cc:428
Final result (an open connection or an error) sent to the job initiator.
Definition: HappyConnOpener.h:76
~HappyConnOpenerAnswer()
Definition: HappyConnOpener.cc:319
a connection opening attempt in progress (or falsy)
Definition: HappyConnOpener.h:138
void finish()
reacts to a natural attempt completion (successful or otherwise)
Definition: HappyConnOpener.cc:912
void(HappyConnOpener::*)(const CommConnectCbParams &) CallbackMethod
HappyConnOpener method implementing a ConnOpener callback.
Definition: HappyConnOpener.h:141
JobWait< Comm::ConnOpener > connWait
waits for a connection to the peer to be established/opened
Definition: HappyConnOpener.h:156
Attempt(const CallbackMethod method, const char *methodName)
Definition: HappyConnOpener.cc:905
Definition: HappyConnOpener.h:106
bool doneAll() const override
whether positive goal has been reached
Definition: HappyConnOpener.cc:366
void noteSpareConnectDone(const CommConnectCbParams &)
Comm::ConnOpener callback for the spare connection attempt.
Definition: HappyConnOpener.cc:605
bool ignoreSpareRestrictions
whether spare connection attempts disregard happy_eyeballs_* settings
Definition: HappyConnOpener.h:226
bool gotSpareAllowance
whether we have received a permission to open a spare while spares are limited
Definition: HappyConnOpener.h:229
void noteGavePrimeItsChance()
reacts to expired happy_eyeballs_connect_timeout
Definition: HappyConnOpener.cc:755
bool retriable_
whether we are opening connections for a request that may be resent
Definition: HappyConnOpener.h:235
const char * status() const override
internal cleanup; do not call directly
Definition: HappyConnOpener.cc:432
void cancelAttempt(Attempt &, const char *reason)
cancels the in-progress attempt, making its path a future candidate
Definition: HappyConnOpener.cc:511
void maybeGivePrimeItsChance()
Definition: HappyConnOpener.cc:814
void setHost(const char *)
configures the origin server domain name
Definition: HappyConnOpener.cc:351
const char * ranOutOfTimeOrAttemptsEarlier_
Reason to ran out of time or attempts.
Definition: HappyConnOpener.h:248
void sendSuccess(const PeerConnectionPointer &conn, bool reused, const char *connKind)
send a successful result to the initiator (if it still needs an answer)
Definition: HappyConnOpener.cc:499
HappyConnOpener(const ResolvedPeersPointer &, const AsyncCallback< Answer > &, const HttpRequestPointer &, time_t aFwdStart, int tries, const AccessLogEntryPointer &)
Definition: HappyConnOpener.cc:330
void updateSpareWaitAfterPrimeFailure()
reacts to a prime attempt failure
Definition: HappyConnOpener.cc:651
HttpRequestPointer cause
the request that needs a to-server connection
Definition: HappyConnOpener.h:241
void stopGivingPrimeItsChance()
called when the prime attempt has used up its chance for a solo victory
Definition: HappyConnOpener.cc:672
void maybeOpenSpareConnection()
if possible, starts a spare connection attempt
Definition: HappyConnOpener.cc:845
Answer * futureAnswer(const PeerConnectionPointer &)
Definition: HappyConnOpener.cc:485
void checkForNewConnection()
Definition: HappyConnOpener.cc:715
void handleConnOpenerAnswer(Attempt &, const CommConnectCbParams &, const char *connDescription)
prime/spare-agnostic processing of a Comm::ConnOpener result
Definition: HappyConnOpener.cc:616
bool ranOutOfTimeOrAttempts() const
Check for maximum connection tries and forwarding time restrictions.
Definition: HappyConnOpener.cc:885
void stopWaitingForSpareAllowance()
called when the spare attempt should no longer obey spare connection limits
Definition: HappyConnOpener.cc:680
ErrorState * makeError(const err_type type) const
Definition: HappyConnOpener.cc:476
void noteSpareAllowance()
reacts to satisfying happy_eyeballs_connect_gap and happy_eyeballs_connect_limit
Definition: HappyConnOpener.cc:763
HappySpareWait spareWaiting
preconditions for an attempt to open a spare connection
Definition: HappyConnOpener.h:217
void sendFailure()
inform the initiator about our failure to connect (if needed)
Definition: HappyConnOpener.cc:520
bool reuseOldConnection(PeerConnectionPointer &)
Definition: HappyConnOpener.cc:558
void startConnecting(Attempt &, PeerConnectionPointer &)
starts opening (or reusing) a connection to the given destination
Definition: HappyConnOpener.cc:542
Attempt spare
current connection opening attempt on the spare track (if any)
Definition: HappyConnOpener.h:210
ResolvedPeersPointer destinations
Candidate paths. Shared with the initiator. May not be finalized yet.
Definition: HappyConnOpener.h:204
HappyAbsoluteTime primeStart
the start of the first connection attempt for the currentPeer
Definition: HappyConnOpener.h:134
void maybeOpenPrimeConnection()
starts a prime connection attempt if possible or does nothing otherwise
Definition: HappyConnOpener.cc:782
void openFreshConnection(Attempt &, PeerConnectionPointer &)
Definition: HappyConnOpener.cc:575
void notePrimeConnectDone(const CommConnectCbParams &)
Comm::ConnOpener callback for the prime connection attempt.
Definition: HappyConnOpener.cc:598
void cancelSpareWait(const char *reason)
stops waiting for the right conditions to open a spare connection
Definition: HappyConnOpener.cc:691
void noteCandidatesChange()
reacts to changes in the destinations list
Definition: HappyConnOpener.cc:534
Attempt prime
current connection opening attempt on the prime track (if any)
Definition: HappyConnOpener.h:207
Definition: HappyConnOpener.cc:55
void dequeue(HappyConnOpener &)
stops managing the job's wait; cancels the pending callback, if any
Definition: HappyConnOpener.cc:161
bool startedWaiting(const HappyAbsoluteTime lastStart, const int cfgTimeoutMsec) const
Definition: HappyConnOpener.cc:189
static void NoteWaitOver(void *raw)
Definition: HappyConnOpener.cc:217
virtual AsyncCall::Pointer notify(const CbcPointer< HappyConnOpener > &)=0
virtual bool readyNow(const HappyConnOpener &) const =0
void enqueue(HappyConnOpener &)
starts managing the job's wait; the job should expect a call back
Definition: HappyConnOpener.cc:152
HappyOrderEnforcer(const char *aName)
Definition: HappyConnOpener.cc:58
HappyAbsoluteTime waitEnd_
expected NoteWaitOver() call time (or zero)
Definition: HappyConnOpener.cc:83
AsyncCall::Pointer callback
a pending noteGavePrimeItsChance() or noteSpareAllowance() call
Definition: HappyConnOpener.h:47
void start(const JobPointer &aJob, const AsyncCall::Pointer &aCallback)
starts waiting for the given job to call the given callback
Definition: JobWait.h:69
Comm::ConnectionPointer pop(const Comm::ConnectionPointer &dest, const char *domain, bool keepOpen)
Definition: pconn.cc:449
Definition: ResolvedPeers.h:122
void finalize(const Comm::ConnectionPointer &conn)
upgrade stored peer selection details with a matching actual connection
Definition: ResolvedPeers.h:139
bool readyNow(const HappyConnOpener &job) const override
Definition: HappyConnOpener.cc:234
AsyncCall::Pointer notify(const CbcPointer< HappyConnOpener > &) override
Definition: HappyConnOpener.cc:240
PeerConnectionPointer extractFront()
extracts and returns the first queued address
Definition: ResolvedPeers.cc:111
bool haveSpare(const Comm::Connection ¤tPeer)
whether extractSpare() would return a non-nil path right now
Definition: ResolvedPeers.cc:159
bool doneWithPrimes(const Comm::Connection ¤tPeer)
whether extractPrime() returns and will continue to return nil
Definition: ResolvedPeers.cc:185
bool doneWithPeer(const Comm::Connection ¤tPeer)
whether doneWithPrimes() and doneWithSpares() are true for currentPeer
Definition: ResolvedPeers.cc:191
void reinstatePath(const PeerConnectionPointer &)
Definition: ResolvedPeers.cc:23
PeerConnectionPointer extractSpare(const Comm::Connection ¤tPeer)
Definition: ResolvedPeers.cc:129
bool notificationPending
whether HappyConnOpener::noteCandidatesChange() is scheduled to fire
Definition: ResolvedPeers.h:85
bool destinationsFinalized
whether all of the available candidate paths received from DNS
Definition: ResolvedPeers.h:82
PeerConnectionPointer extractPrime(const Comm::Connection ¤tPeer)
Definition: ResolvedPeers.cc:118
bool doneWithSpares(const Comm::Connection ¤tPeer)
whether extractSpare() returns and will continue to return nil
Definition: ResolvedPeers.cc:179
Definition: Stream.h:21
enforces happy_eyeballs_connect_gap and happy_eyeballs_connect_limit
Definition: HappyConnOpener.cc:113
void jobGotInstantAllowance()
Definition: HappyConnOpener.cc:262
bool concurrencyLimitReached() const
whether opening a spare connection now would violate happy_eyeballs_connect_limit
Definition: HappyConnOpener.cc:303
bool readyNow(const HappyConnOpener &job) const override
Definition: HappyConnOpener.cc:248
void jobDroppedAllowance()
reacts to HappyConnOpener dropping its spare connection allowance
Definition: HappyConnOpener.cc:274
HappyAbsoluteTime lastAllowanceStart
the time of the last noteSpareAllowance() call
Definition: HappyConnOpener.cc:139
AsyncCall::Pointer notify(const CbcPointer< HappyConnOpener > &) override
Definition: HappyConnOpener.cc:255
void jobUsedAllowance()
reacts to HappyConnOpener getting a spare connection opening result
Definition: HappyConnOpener.cc:268
struct SquidConfig::@118 happyEyeballs
void eventAdd(const char *name, EVH *func, void *arg, double when, int weight, bool cbdata)
Definition: event.cc:107
double current_dtime
the current UNIX time in seconds (with microsecond precision)
Definition: stub_libtime.cc:19