FwdState.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 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);
84  void unregister(Comm::ConnectionPointer &conn);
85  void unregister(int fd);
86  void complete();
87  void handleUnregisteredServerEnd();
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 
107  Comm::ConnectionPointer const & serverConnection() const { return serverConn; };
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();
126  ErrorState *makeConnectingError(const err_type type) const;
127  void connectedToPeer(Security::EncryptorAnswer &answer);
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 
137  bool exhaustedTries() const;
138 
139 public:
143 
144  static void abort(void*);
145 
146 private:
147  Pointer self;
150  time_t start_t;
151  int n_tries;
152 
153  // AsyncCalls which we set and may need cancelling.
154  struct {
156  } calls;
157 
158  struct {
162  } flags;
163 
166 
168 
170 
172  typedef enum { raceImpossible, racePossible, raceHappened } PconnRace;
173  PconnRace pconnRace;
174 };
175 
177 
178 #endif /* SQUID_FORWARD_H */
179 
static void dispatch(thing *t, char *url)
Definition: tcp-banger3.c:298
void getOutgoingAddress(HttpRequest *request, Comm::ConnectionPointer conn)
Definition: FwdState.cc:1302
int type
Definition: errorpage.cc:78
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
std::vector< Comm::ConnectionPointer > ConnectionList
Definition: forward.h:29
HttpRequest * request
Definition: FwdState.h:141
Interface for those who need a list of peers to forward a request to.
int conn
the current server connection FD
Definition: Transport.cc:26
Comm::ConnectionPointer const & serverConnection() const
Definition: FwdState.h:107
PconnRace
possible pconn race states
Definition: FwdState.h:172
unsigned char tos_t
Definition: forward.h:26
time_t start_t
Definition: FwdState.h:150
void GetMarkingsToServer(HttpRequest *request, Comm::Connection &conn)
Sets initial TOS value and Netfilter for the future outgoing connection.
Definition: FwdState.cc:1369
void dontRetry(bool val)
Definition: FwdState.h:104
StatusCode
Definition: StatusCode.h:20
Comm::ConnectionPointer clientConn
a possibly open connection to the client.
Definition: FwdState.h:149
tos_t GetTosToServer(HttpRequest *request)
Definition: FwdState.cc:1354
Comm::ConnectionList serverDestinations
Definition: FwdState.h:165
PconnRace pconnRace
current pconn race state
Definition: FwdState.h:173
nfmark_t GetNfmarkToServer(HttpRequest *request)
Definition: FwdState.cc:1361
bool dont_retry
Definition: FwdState.h:160
RefCount< FwdState > Pointer
Definition: FwdState.h:64
Flag
Definition: Flag.h:15
RefCount< PconnPool > PconnPoolPointer
Definition: FwdState.h:29
AsyncCall::Pointer closeHandler
The serverConn close handler.
Definition: FwdState.h:169
AccessLogEntryPointer al
info for the future access.log entry
Definition: FwdState.h:142
Definition: Xaction.cc:47
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:159
bool dontRetry()
Definition: FwdState.h:102
Comm::ConnectionPointer serverConn
a successfully opened connection to a server.
Definition: FwdState.h:167
#define CBDATA_CHILD(type)
Definition: cbdata.h:307
int n_tries
the number of forwarding attempts so far
Definition: FwdState.h:151
ErrorState * err
Definition: FwdState.h:148
bool forward_completed
Definition: FwdState.h:161
StoreEntry * entry
Definition: FwdState.h:140
uint32_t nfmark_t
Definition: forward.h:25
void Start(const Comm::ConnectionPointer &conn, IDCB *callback, void *cbdata)
Definition: Ident.cc:237
err_type
Definition: err_type.h:12
AsyncCall::Pointer connector
a call linking us to the ConnOpener producing serverConn.
Definition: FwdState.h:155

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors