Squid Web Cache master
Loading...
Searching...
No Matches
ConnOpener.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef SQUID_SRC_COMM_CONNOPENER_H
10#define SQUID_SRC_COMM_CONNOPENER_H
11
12#include "base/AsyncCall.h"
13#include "base/AsyncJob.h"
14#include "cbdata.h"
15#include "comm/Flag.h"
16#include "comm/forward.h"
17#include "CommCalls.h"
18
19namespace Comm
20{
21
24class ConnOpener : public AsyncJob
25{
27
28public:
30
31 bool doneAll() const override;
32
34 ~ConnOpener() override;
35
36 void setHost(const char *);
37 const char * getHost() const;
38
39protected:
40 void start() override;
41 void swanSong() override;
42
43private:
44 // Undefined because two openers cannot share a connection
47
48 void earlyAbort(const CommCloseCbParams &);
49 void timeout(const CommTimeoutCbParams &);
50 void sendAnswer(Comm::Flag errFlag, int xerrno, const char *why);
51 static void InProgressConnectRetry(int fd, void *data);
52 static void DelayedConnectRetry(void *data);
53 void doConnect();
54 void connected();
55 void lookupLocalAddress();
56
57 void retrySleep();
58 void restart();
59
60 bool createFd();
61 void closeFd();
62 void keepFd();
63 void cleanFd();
64
65 void cancelSleep();
66
67private:
68 char *host_;
72
75
77 time_t deadline_;
78
87};
88
89}; // namespace Comm
90
91#endif /* SQUID_SRC_COMM_CONNOPENER_H */
92
int totalTries_
total number of connection attempts over all destinations so far.
Definition ConnOpener.h:73
void timeout(const CommTimeoutCbParams &)
ConnOpener(const ConnOpener &)
Comm::ConnectionPointer conn_
single connection currently to be opened.
Definition ConnOpener.h:70
void restart()
called at the end of Comm::ConnOpener::DelayedConnectRetry event
static void InProgressConnectRetry(int fd, void *data)
void retrySleep()
Close and wait a little before trying to open and connect again.
struct Comm::ConnOpener::Calls calls_
void cancelSleep()
cleans up this job sleep state
int failRetries_
number of retries current destination has been tried.
Definition ConnOpener.h:74
CBDATA_CHILD(ConnOpener)
CbcPointer< ConnOpener > Pointer
Definition ConnOpener.h:29
~ConnOpener() override
Definition ConnOpener.cc:54
static void DelayedConnectRetry(void *data)
void setHost(const char *)
set the hostname note for this connection
void earlyAbort(const CommCloseCbParams &)
void closeFd()
cleans I/O state and ends I/O for temporaryFd_
time_t deadline_
if we are not done by then, we will call back with Comm::TIMEOUT
Definition ConnOpener.h:77
void sendAnswer(Comm::Flag errFlag, int xerrno, const char *why)
void start() override
called by AsyncStart; do not call directly
int temporaryFd_
the FD being opened. Do NOT set conn_->fd until it is fully open.
Definition ConnOpener.h:69
void lookupLocalAddress()
ConnOpener & operator=(const ConnOpener &c)
char * host_
domain name we are trying to connect to.
Definition ConnOpener.h:68
void swanSong() override
Definition ConnOpener.cc:78
bool doneAll() const override
whether positive goal has been reached
Definition ConnOpener.cc:60
void keepFd()
cleans I/O state and moves temporaryFd_ to the conn_ for long-term use
void doConnect()
Make an FD connection attempt.
AsyncCall::Pointer callback_
handler to be called on connection completion.
Definition ConnOpener.h:71
const char * getHost() const
get the hostname noted for this connection
static int connect_timeout
Abstraction layer for TCP, UDP, TLS, UDS and filedescriptor sockets.
Flag
Definition Flag.h:15
handles to calls which we may need to cancel.
Definition ConnOpener.h:80
AsyncCall::Pointer earlyAbort_
Definition ConnOpener.h:81
AsyncCall::Pointer timeout_
Definition ConnOpener.h:82