ConnOpener.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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_OPENERSTATEDATA_H
10#define _SQUID_SRC_COMM_OPENERSTATEDATA_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 virtual bool doneAll() const;
32
35
36 void setHost(const char *);
37 const char * getHost() const;
38
39protected:
40 virtual void start();
41 virtual void swanSong();
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
80 struct Calls {
85 bool sleep_;
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 &)
Definition: ConnOpener.cc:464
virtual void swanSong()
Definition: ConnOpener.cc:77
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
Definition: ConnOpener.cc:266
static void InProgressConnectRetry(int fd, void *data)
Definition: ConnOpener.cc:475
void retrySleep()
Close and wait a little before trying to open and connect again.
Definition: ConnOpener.cc:397
struct Comm::ConnOpener::Calls calls_
virtual bool doneAll() const
whether positive goal has been reached
Definition: ConnOpener.cc:59
void cancelSleep()
cleans up this job sleep state
Definition: ConnOpener.cc:409
int failRetries_
number of retries current destination has been tried.
Definition: ConnOpener.h:74
CbcPointer< ConnOpener > Pointer
Definition: ConnOpener.h:29
static void DelayedConnectRetry(void *data)
Definition: ConnOpener.cc:493
void setHost(const char *)
set the hostname note for this connection
Definition: ConnOpener.cc:100
void earlyAbort(const CommCloseCbParams &)
Definition: ConnOpener.cc:451
void closeFd()
cleans I/O state and ends I/O for temporaryFd_
Definition: ConnOpener.cc:219
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)
Definition: ConnOpener.cc:122
CBDATA_CLASS(ConnOpener)
ConnOpener(const Comm::ConnectionPointer &, const AsyncCall::Pointer &handler, time_t connect_timeout)
Definition: ConnOpener.cc:32
int temporaryFd_
the FD being opened. Do NOT set conn_->fd until it is fully open.
Definition: ConnOpener.h:69
void lookupLocalAddress()
Definition: ConnOpener.cc:430
virtual void start()
called by AsyncStart; do not call directly
Definition: ConnOpener.cc:250
ConnOpener & operator=(const ConnOpener &c)
char * host_
domain name we are trying to connect to.
Definition: ConnOpener.h:68
void keepFd()
cleans I/O state and moves temporaryFd_ to the conn_ for long-term use
Definition: ConnOpener.cc:238
void doConnect()
Make an FD connection attempt.
Definition: ConnOpener.cc:356
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
Definition: ConnOpener.cc:112
static int connect_timeout
Abstraction layer for TCP, UDP, TLS, UDS and filedescriptor sockets.
Definition: AcceptLimiter.h:17
Flag
Definition: Flag.h:15
static void handler(int signo)
Definition: purge.cc:854
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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors