]>
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/comm_err_t.h"
9 #include "comm/forward.h"
14 * Async-opener of a Comm connection.
16 class ConnOpener
: public AsyncJob
19 // ****** AsynJob API implementation ******
21 /** Actual start opening a TCP connection. */
24 virtual bool doneAll() const;
25 virtual void swanSong();
28 // ****** ConnOpener API iplementation ******
30 /** attempt to open a connection. */
31 ConnOpener(Comm::ConnectionPointer
&, AsyncCall::Pointer
&handler
, time_t connect_timeout
);
34 void setHost(const char *); ///< set the hostname note for this connection
35 const char * getHost() const; ///< get the hostname noted for this connection
38 /* These objects may NOT be created without connections to act on. Do not define this operator. */
39 ConnOpener(const ConnOpener
&);
40 /* These objects may NOT be copied. Do not define this operator. */
41 ConnOpener
operator =(const ConnOpener
&c
);
43 /** Make an FD connection attempt.
44 * Handles the case(s) when a partially setup connection gets closed early.
46 void connect(const CommConnectCbParams
&unused
);
48 /** Abort connection attempt.
49 * Handles the case(s) when a partially setup connection gets closed early.
51 void earlyAbort(const CommConnectCbParams
&);
54 * Handles the case(s) when a partially setup connection gets timed out.
55 * NP: When commSetTimeout accepts generic CommCommonCbParams this can die.
57 void timeout(const CommTimeoutCbParams
&unused
);
60 * Connection attempt are completed. One way or the other.
61 * Pass the results back to the external handler.
63 void callCallback(comm_err_t status
, int xerrno
);
65 // Legacy Wrapper for the retry event after COMM_INPROGRESS
66 // As soon as comm IO accepts Async calls we can use a ConnOpener::connect call
67 static void ConnectRetry(int fd
, void *data
);
71 * time at which to abandon the connection.
72 * the connection-done callback will be passed COMM_TIMEOUT
74 time_t connect_timeout
;
76 char *host
; ///< domain name we are trying to connect to.
78 Comm::ConnectionPointer solo
; ///< single connection currently being opened.
79 AsyncCall::Pointer callback
; ///< handler to be called on connection completion.
81 int total_tries
; ///< total number of connection attempts over all destinations so far.
82 int fail_retries
; ///< number of retries current destination has been tried.
83 time_t connstart
; ///< time at which this series of connection attempts was started.
85 /// handles to calls which we may need to cancel.
87 AsyncCall::Pointer earlyabort
;
88 AsyncCall::Pointer timeout
;
91 CBDATA_CLASS2(ConnOpener
);
96 #endif /* _SQUID_SRC_COMM_CONNOPENER_H */