HappyConnOpener.h
Go to the documentation of this file.
38 explicit operator bool() const { return toGivePrimeItsChance || forSpareAllowance || forPrimesToFail || forNewPeer; }
112 HappyConnOpener(const ResolvedPeersPointer &, const AsyncCallback<Answer> &, const HttpRequestPointer &, time_t aFwdStart, int tries, const AccessLogEntryPointer &);
182 void handleConnOpenerAnswer(Attempt &, const CommConnectCbParams &, const char *connDescription);
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
std::ostream & operator<<(std::ostream &, const HappyConnOpenerAnswer &)
reports Answer details (for AsyncCall parameter debugging)
Definition: HappyConnOpener.cc:86
a smart AsyncCall pointer for delivery of future results
Definition: AsyncCallbacks.h:32
Definition: AsyncJob.h:32
Definition: CommCalls.h:105
Definition: errorpage.h:89
Final result (an open connection or an error) sent to the job initiator.
Definition: HappyConnOpener.h:76
bool success() const
whether HappyConnOpener succeeded, returning a usable connection
Definition: HappyConnOpener.h:81
~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
CBDATA_CHILD(HappyConnOpener)
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
friend std::ostream & operator<<(std::ostream &, const Attempt &)
HappyConnOpener::Attempt printer for debugging.
Definition: HappyConnOpener.cc:418
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 allowPersistent(bool permitted)
configures reuse of old connections
Definition: HappyConnOpener.h:116
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
void setRetriable(bool retriable)
configures whether the request may be retried later if things go wrong
Definition: HappyConnOpener.h:119
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
keeps track of HappyConnOpener spare track waiting state
Definition: HappyConnOpener.h:36
AsyncCall::Pointer callback
a pending noteGavePrimeItsChance() or noteSpareAllowance() call
Definition: HappyConnOpener.h:47
Definition: ResolvedPeers.h:122