]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/comm/ConnOpener.h
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef _SQUID_SRC_COMM_OPENERSTATEDATA_H
10 #define _SQUID_SRC_COMM_OPENERSTATEDATA_H
12 #include "base/AsyncCall.h"
13 #include "base/AsyncJob.h"
15 #include "comm/Flag.h"
16 #include "comm/forward.h"
17 #include "CommCalls.h"
23 * Async-opener of a Comm connection.
25 class ConnOpener
: public AsyncJob
27 CBDATA_CLASS(ConnOpener
);
31 virtual void swanSong();
34 void noteAbort() { mustStop("externally aborted"); }
36 typedef CbcPointer
<ConnOpener
> Pointer
;
38 virtual bool doneAll() const;
40 ConnOpener(Comm::ConnectionPointer
&, AsyncCall::Pointer
&handler
, time_t connect_timeout
);
43 void setHost(const char *); ///< set the hostname note for this connection
44 const char * getHost() const; ///< get the hostname noted for this connection
47 // Undefined because two openers cannot share a connection
48 ConnOpener(const ConnOpener
&);
49 ConnOpener
& operator =(const ConnOpener
&c
);
51 void earlyAbort(const CommCloseCbParams
&);
52 void timeout(const CommTimeoutCbParams
&);
53 void sendAnswer(Comm::Flag errFlag
, int xerrno
, const char *why
);
54 static void InProgressConnectRetry(int fd
, void *data
);
55 static void DelayedConnectRetry(void *data
);
58 void lookupLocalAddress();
71 char *host_
; ///< domain name we are trying to connect to.
72 int temporaryFd_
; ///< the FD being opened. Do NOT set conn_->fd until it is fully open.
73 Comm::ConnectionPointer conn_
; ///< single connection currently to be opened.
74 AsyncCall::Pointer callback_
; ///< handler to be called on connection completion.
76 int totalTries_
; ///< total number of connection attempts over all destinations so far.
77 int failRetries_
; ///< number of retries current destination has been tried.
79 /// if we are not done by then, we will call back with Comm::TIMEOUT
82 /// handles to calls which we may need to cancel.
84 AsyncCall::Pointer earlyAbort_
;
85 AsyncCall::Pointer timeout_
;
86 /// Whether we are idling before retrying to connect; not yet a call
87 /// [that we can cancel], but it will probably become one eventually.
94 #endif /* _SQUID_SRC_COMM_CONNOPENER_H */