]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/comm/ConnOpener.h
1 #ifndef _SQUID_SRC_COMM_OPENERSTATEDATA_H
2 #define _SQUID_SRC_COMM_OPENERSTATEDATA_H
4 #include "base/AsyncCall.h"
5 #include "base/AsyncJob.h"
7 #include "comm/forward.h"
8 #include "comm_err_t.h"
15 * Async-opener of a Comm connection.
17 class ConnOpener
: public AsyncJob
21 virtual void swanSong();
24 void noteAbort() { mustStop("externally aborted"); }
26 typedef CbcPointer
<ConnOpener
> Pointer
;
28 virtual bool doneAll() const;
30 ConnOpener(Comm::ConnectionPointer
&, AsyncCall::Pointer
&handler
, time_t connect_timeout
);
33 void setHost(const char *); ///< set the hostname note for this connection
34 const char * getHost() const; ///< get the hostname noted for this connection
37 // Undefined because two openers cannot share a connection
38 ConnOpener(const ConnOpener
&);
39 ConnOpener
& operator =(const ConnOpener
&c
);
41 void earlyAbort(const CommCloseCbParams
&);
42 void timeout(const CommTimeoutCbParams
&);
43 void sendAnswer(comm_err_t errFlag
, int xerrno
, const char *why
);
44 static void InProgressConnectRetry(int fd
, void *data
);
45 static void DelayedConnectRetry(void *data
);
48 void lookupLocalAddress();
61 char *host_
; ///< domain name we are trying to connect to.
62 int temporaryFd_
; ///< the FD being opened. Do NOT set conn_->fd until it is fully open.
63 Comm::ConnectionPointer conn_
; ///< single connection currently to be opened.
64 AsyncCall::Pointer callback_
; ///< handler to be called on connection completion.
66 int totalTries_
; ///< total number of connection attempts over all destinations so far.
67 int failRetries_
; ///< number of retries current destination has been tried.
69 /// if we are not done by then, we will call back with COMM_TIMEOUT
72 /// handles to calls which we may need to cancel.
74 AsyncCall::Pointer earlyAbort_
;
75 AsyncCall::Pointer timeout_
;
76 /// Whether we are idling before retrying to connect; not yet a call
77 /// [that we can cancel], but it will probably become one eventually.
81 CBDATA_CLASS2(ConnOpener
);
86 #endif /* _SQUID_SRC_COMM_CONNOPENER_H */