]> git.ipfire.org Git - thirdparty/squid.git/blob - src/comm/ConnOpener.h
Bug 3676: Fix various shadowed variables
[thirdparty/squid.git] / src / comm / ConnOpener.h
1 #ifndef _SQUID_SRC_COMM_OPENERSTATEDATA_H
2 #define _SQUID_SRC_COMM_OPENERSTATEDATA_H
3
4 #include "base/AsyncCall.h"
5 #include "base/AsyncJob.h"
6 #include "cbdata.h"
7 #include "CommCalls.h"
8 #include "comm_err_t.h"
9 #include "comm/forward.h"
10
11 namespace Comm
12 {
13
14 /**
15 * Async-opener of a Comm connection.
16 */
17 class ConnOpener : public AsyncJob
18 {
19 protected:
20 virtual void start();
21 virtual void swanSong();
22
23 public:
24 void noteAbort() { mustStop("externally aborted"); }
25
26 typedef CbcPointer<ConnOpener> Pointer;
27
28 virtual bool doneAll() const;
29
30 ConnOpener(Comm::ConnectionPointer &, AsyncCall::Pointer &handler, time_t connect_timeout);
31 ~ConnOpener();
32
33 void setHost(const char *); ///< set the hostname note for this connection
34 const char * getHost() const; ///< get the hostname noted for this connection
35
36 private:
37 // Undefined because two openers cannot share a connection
38 ConnOpener(const ConnOpener &);
39 ConnOpener & operator =(const ConnOpener &c);
40
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);
46 void connect();
47 void connected();
48 void lookupLocalAddress();
49
50 private:
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.
55
56 int totalTries_; ///< total number of connection attempts over all destinations so far.
57 int failRetries_; ///< number of retries current destination has been tried.
58
59 /**
60 * time at which to abandon the connection.
61 * the connection-done callback will be passed COMM_TIMEOUT
62 */
63 time_t connectTimeout_;
64
65 /// time at which this series of connection attempts was started.
66 time_t connectStart_;
67
68 /// handles to calls which we may need to cancel.
69 struct Calls {
70 AsyncCall::Pointer earlyAbort_;
71 AsyncCall::Pointer timeout_;
72 } calls_;
73
74 CBDATA_CLASS2(ConnOpener);
75 };
76
77 }; // namespace Comm
78
79 #endif /* _SQUID_SRC_COMM_CONNOPENER_H */