]>
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"
8 #include "comm_err_t.h"
9 #include "comm/forward.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 doneConnecting(comm_err_t errFlag
, int xerrno
);
44 static void InProgressConnectRetry(int fd
, void *data
);
45 static void DelayedConnectRetry(void *data
);
48 void lookupLocalAddress();
51 char *host_
; ///< domain name we are trying to connect to.
52 int temporaryFd_
; ///< the FD being opened. Do NOT set conn_->fd until it is fully open.
53 Comm::ConnectionPointer conn_
; ///< single connection currently to be opened.
54 AsyncCall::Pointer callback_
; ///< handler to be called on connection completion.
56 int totalTries_
; ///< total number of connection attempts over all destinations so far.
57 int failRetries_
; ///< number of retries current destination has been tried.
60 * time at which to abandon the connection.
61 * the connection-done callback will be passed COMM_TIMEOUT
63 time_t connectTimeout_
;
65 /// time at which this series of connection attempts was started.
68 /// handles to calls which we may need to cancel.
70 AsyncCall::Pointer earlyAbort_
;
71 AsyncCall::Pointer timeout_
;
74 CBDATA_CLASS2(ConnOpener
);
79 #endif /* _SQUID_SRC_COMM_CONNOPENER_H */