FwdState.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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_FORWARD_H
10 #define SQUID_FORWARD_H
11 
12 #include "base/RefCount.h"
13 #include "comm.h"
14 #include "comm/Connection.h"
15 #include "err_type.h"
16 #include "fde.h"
17 #include "http/StatusCode.h"
18 #include "ip/Address.h"
19 #include "PeerSelectState.h"
20 #include "security/forward.h"
21 #if USE_OPENSSL
22 #include "ssl/support.h"
23 #endif
24 
25 /* forward decls */
26 
29 class PconnPool;
31 class ErrorState;
32 class HttpRequest;
33 
34 #if USE_OPENSSL
35 namespace Ssl
36 {
37 class ErrorDetail;
38 class CertValidationResponse;
39 };
40 #endif
41 
47 
53 
56 
57 class HelperReply;
58 
60 {
62 
63 public:
65  virtual ~FwdState();
66  static void initModule();
67 
69  static void Start(const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *, const AccessLogEntryPointer &alp);
71  static void fwdStart(const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *);
73  static time_t ForwardTimeout(const time_t fwdStart);
76  static bool EnoughTimeToReForward(const time_t fwdStart);
77 
81  void startConnectionOrFail();
82 
83  void fail(ErrorState *err);
85  void unregister(int fd);
86  void complete();
88  int reforward();
89  bool reforwardableStatus(const Http::StatusCode s) const;
90  void serverClosed(int fd);
91  void connectStart();
92  void connectDone(const Comm::ConnectionPointer & conn, Comm::Flag status, int xerrno);
93  void connectTimeout(int fd);
94  bool checkRetry();
95  bool checkRetriable();
96  void dispatch();
99  Comm::ConnectionPointer pconnPop(const Comm::ConnectionPointer &dest, const char *domain);
100  void pconnPush(Comm::ConnectionPointer & conn, const char *domain);
101 
102  bool dontRetry() { return flags.dont_retry; }
103 
104  void dontRetry(bool val) { flags.dont_retry = val; }
105 
108 
109 private:
110  // hidden for safer management of self; use static fwdStart
112  void start(Pointer aSelf);
113  void stopAndDestroy(const char *reason);
114 
115  /* PeerSelectionInitiator API */
116  virtual void noteDestination(Comm::ConnectionPointer conn) override;
117  virtual void noteDestinationsEnd(ErrorState *selectionError) override;
118 
119 #if STRICT_ORIGINAL_DST
120  void selectPeerForIntercepted();
121 #endif
122  static void logReplyStatus(int tries, const Http::StatusCode status);
123  void doneWithRetries();
124  void completed();
125  void retryOrBail();
128  static void RegisterWithCacheManager(void);
129 
131  void closeServerConnection(const char *reason);
132 
133  void syncWithServerConn(const char *host);
134  void syncHierNote(const Comm::ConnectionPointer &server, const char *host);
135 
136 public:
140 
141  static void abort(void*);
142 
143 private:
144  Pointer self;
147  time_t start_t;
148  int n_tries;
149 
150  // AsyncCalls which we set and may need cancelling.
151  struct {
153  } calls;
154 
155  struct {
159  } flags;
160 
163 
165 
167 
171 };
172 
174 
175 #endif /* SQUID_FORWARD_H */
176 
int reforward()
Definition: FwdState.cc:1091
virtual void noteDestination(Comm::ConnectionPointer conn) override
called when a new unique destination has been found
Definition: FwdState.cc:552
void connectedToPeer(Security::EncryptorAnswer &answer)
Definition: FwdState.cc:780
void getOutgoingAddress(HttpRequest *request, Comm::ConnectionPointer conn)
Definition: FwdState.cc:1293
static bool EnoughTimeToReForward(const time_t fwdStart)
Definition: FwdState.cc:417
struct FwdState::@72 calls
void pconnPush(Comm::ConnectionPointer &conn, const char *domain)
Definition: FwdState.cc:1206
void serverClosed(int fd)
Definition: FwdState.cc:666
int type
Definition: errorpage.cc:79
void dispatch()
Definition: FwdState.cc:967
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
std::vector< Comm::ConnectionPointer > ConnectionList
Definition: forward.h:29
static void RegisterWithCacheManager(void)
Definition: FwdState.cc:1243
FwdState(const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *, const AccessLogEntryPointer &alp)
Definition: FwdState.cc:130
void connectTimeout(int fd)
Definition: FwdState.cc:813
HttpRequest * request
Definition: FwdState.h:138
Interface for those who need a list of peers to forward a request to.
void stopAndDestroy(const char *reason)
ends forwarding; relies on refcounting so the effect may not be immediate
Definition: FwdState.cc:189
int conn
the current server connection FD
Definition: Transport.cc:26
struct FwdState::@73 flags
void retryOrBail()
Definition: FwdState.cc:677
void completed()
Definition: FwdState.cc:234
PconnRace
possible pconn race states
Definition: FwdState.h:169
static void fwdStart(const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *)
Same as Start() but no master xaction info (AccessLogEntry) available.
Definition: FwdState.cc:393
unsigned char tos_t
Definition: forward.h:26
CBDATA_CHILD(FwdState)
virtual ~FwdState()
Definition: FwdState.cc:280
void connectDone(const Comm::ConnectionPointer &conn, Comm::Flag status, int xerrno)
Definition: FwdState.cc:723
time_t start_t
Definition: FwdState.h:147
void GetMarkingsToServer(HttpRequest *request, Comm::Connection &conn)
Sets initial TOS value and Netfilter for the future outgoing connection.
Definition: FwdState.cc:1358
void dontRetry(bool val)
Definition: FwdState.h:104
void syncHierNote(const Comm::ConnectionPointer &server, const char *host)
Definition: FwdState.cc:850
StatusCode
Definition: StatusCode.h:20
void start(Pointer aSelf)
Definition: FwdState.cc:152
Comm::ConnectionPointer clientConn
a possibly open connection to the client.
Definition: FwdState.h:146
tos_t GetTosToServer(HttpRequest *request)
Definition: FwdState.cc:1344
void complete()
Definition: FwdState.cc:513
static time_t ForwardTimeout(const time_t fwdStart)
time left to finish the whole forwarding process (which started at fwdStart)
Definition: FwdState.cc:409
Comm::ConnectionList serverDestinations
Definition: FwdState.h:162
void closeServerConnection(const char *reason)
stops monitoring server connection for closure and updates pconn stats
Definition: FwdState.cc:119
static void abort(void *)
Definition: FwdState.cc:104
void handleUnregisteredServerEnd()
Definition: FwdState.cc:715
static void logReplyStatus(int tries, const Http::StatusCode status)
Definition: FwdState.cc:1249
bool reforwardableStatus(const Http::StatusCode s) const
Definition: FwdState.cc:1174
PconnRace pconnRace
current pconn race state
Definition: FwdState.h:170
nfmark_t GetNfmarkToServer(HttpRequest *request)
Definition: FwdState.cc:1351
void connectStart()
Definition: FwdState.cc:864
bool dont_retry
Definition: FwdState.h:157
void doneWithRetries()
Definition: FwdState.cc:707
void syncWithServerConn(const char *host)
called when serverConn is set to an open to-peer connection
Definition: FwdState.cc:836
RefCount< FwdState > Pointer
Definition: FwdState.h:64
Comm::ConnectionPointer const & serverConnection() const
Definition: FwdState.h:107
Flag
Definition: Flag.h:15
RefCount< PconnPool > PconnPoolPointer
Definition: FwdState.h:29
AsyncCall::Pointer closeHandler
The serverConn close handler.
Definition: FwdState.h:166
void startConnectionOrFail()
Definition: FwdState.cc:423
AccessLogEntryPointer al
info for the future access.log entry
Definition: FwdState.h:139
static char server[MAXLINE]
RefCount< AccessLogEntry > AccessLogEntryPointer
Definition: FwdState.h:27
bool connected_okay
TCP link ever opened properly. This affects retry of POST,PUT,CONNECT,etc.
Definition: FwdState.h:156
bool dontRetry()
Definition: FwdState.h:102
Comm::ConnectionPointer serverConn
a successfully opened connection to a server.
Definition: FwdState.h:164
static void Start(const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *, const AccessLogEntryPointer &alp)
Initiates request forwarding to a peer or origin server.
Definition: FwdState.cc:318
void fail(ErrorState *err)
Definition: FwdState.cc:458
ErrorState * makeConnectingError(const err_type type) const
Definition: FwdState.cc:1138
virtual void noteDestinationsEnd(ErrorState *selectionError) override
Definition: FwdState.cc:563
static void initModule()
Definition: FwdState.cc:1237
int n_tries
Definition: FwdState.h:148
bool checkRetriable()
Whether we may try sending this request again after a failure.
Definition: FwdState.cc:653
bool checkRetry()
Definition: FwdState.cc:612
ErrorState * err
Definition: FwdState.h:145
bool forward_completed
Definition: FwdState.h:158
StoreEntry * entry
Definition: FwdState.h:137
uint32_t nfmark_t
Definition: forward.h:25
Comm::ConnectionPointer pconnPop(const Comm::ConnectionPointer &dest, const char *domain)
Definition: FwdState.cc:1216
err_type
Definition: err_type.h:12
void unregister(Comm::ConnectionPointer &conn)
Definition: FwdState.cc:487
AsyncCall::Pointer connector
a call linking us to the ConnOpener producing serverConn.
Definition: FwdState.h:152

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors