]>
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/comm_err_t.h"
8 #include "comm/forward.h"
11 * Async-opener of a Comm connection.
13 class ConnOpener
: public AsyncJob
16 /** attempt to open a connection. */
17 ConnOpener(Comm::ConnectionPointer
&, AsyncCall::Pointer handler
);
21 /** Actual start opening a TCP connection. */
25 /* These objects may NOT be created without connections to act on. Do not define this operator. */
26 ConnOpener(const ConnOpener
&);
27 /* These objects may NOT be copied. Do not define this operator. */
28 ConnOpener
operator =(const ConnOpener
&c
);
31 * Wrapper to start the connection attempts happening.
33 static void Connect(void *data
);
36 static void ConnectRetry(int fd
, void *data
);
39 * Temporary close handler used during connect.
40 * Handles the case(s) when a partially setup connection gets closed early.
42 static void EarlyAbort(int fd
, void *data
);
45 * Temporary timeout handler used during connect.
46 * Handles the case(s) when a partially setup connection gets timed out.
48 static void ConnectTimeout(int fd
, void *data
);
51 * Connection attempt are completed. One way or the other.
52 * Pass the results back to the external handler.
54 void callCallback(comm_err_t status
, int xerrno
);
58 * time at which to abandon the connection.
59 * the connection-done callback will be passed COMM_TIMEOUT
61 time_t connect_timeout
;
63 void setHost(const char *); ///< set the hostname note for this connection
64 const char * getHost(void) const; ///< get the hostname noted for this connection
67 char *host
; ///< domain name we are trying to connect to.
69 Comm::ConnectionPointer solo
; ///< single connection currently being opened.
70 AsyncCall::Pointer callback
; ///< handler to be called on connection completion.
72 int total_tries
; ///< total number of connection attempts over all destinations so far.
73 int fail_retries
; ///< number of retries current destination has been tried.
74 time_t connstart
; ///< time at which this series of connection attempts was started.
76 CBDATA_CLASS2(ConnOpener
);
79 #endif /* _SQUID_SRC_COMM_CONNOPENER_H */