]> git.ipfire.org Git - thirdparty/squid.git/blob - src/forward.h
Summary: Synced with libecap, adopted pass-all-changes-through transactions
[thirdparty/squid.git] / src / forward.h
1 #ifndef SQUID_FORWARD_H
2 #define SQUID_FORWARD_H
3
4 /* forward decls */
5
6 class CacheManager;
7 class ErrorState;
8
9 #include "comm.h"
10 #include "IPAddress.h"
11
12 class FwdServer
13 {
14
15 public:
16 peer *_peer; /* NULL --> origin server */
17 hier_code code;
18 FwdServer *next;
19 };
20
21 class FwdState : public RefCountable
22 {
23
24 public:
25 typedef RefCount<FwdState> Pointer;
26 ~FwdState();
27 static void initModule();
28 static void RegisterWithCacheManager(CacheManager & manager);
29
30 static void fwdStart(int fd, StoreEntry *, HttpRequest *);
31 void startComplete(FwdServer *);
32 void startFail();
33 void fail(ErrorState *err);
34 void unregister(int fd);
35 void complete();
36 void handleUnregisteredServerEnd();
37 int reforward();
38 bool reforwardableStatus(http_status s);
39 void serverClosed(int fd);
40 void connectStart();
41 void connectDone(int server_fd, comm_err_t status, int xerrno);
42 void connectTimeout(int fd);
43 void initiateSSL();
44 void negotiateSSL(int fd);
45 bool checkRetry();
46 bool checkRetriable();
47 void dispatch();
48 void pconnPush(int fd, const char *host, int port, const char *domain, IPAddress &client_addr);
49
50 bool dontRetry() { return flags.dont_retry; }
51
52 void dontRetry(bool val) { flags.dont_retry = val; }
53
54 bool ftpPasvFailed() { return flags.ftp_pasv_failed; }
55
56 void ftpPasvFailed(bool val) { flags.ftp_pasv_failed = val; }
57
58 static void serversFree(FwdServer **);
59
60 private:
61 // hidden for safer management of self; use static fwdStart
62 FwdState(int fd, StoreEntry *, HttpRequest *);
63 void start(Pointer aSelf);
64
65 static void logReplyStatus(int tries, http_status status);
66 void updateHierarchyInfo();
67 void completed();
68 void retryOrBail();
69
70 #if WIP_FWD_LOG
71
72 void uninit /**DOCS_NOSEMI*/
73 static void logRotate /**DOCS_NOSEMI*/
74 void status() /**DOCS_NOSEMI*/
75 #endif
76
77 public:
78 StoreEntry *entry;
79 HttpRequest *request;
80 int server_fd;
81 FwdServer *servers;
82 static void abort(void*);
83
84 private:
85 CBDATA_CLASS2(FwdState);
86 Pointer self;
87 ErrorState *err;
88 int client_fd;
89 time_t start_t;
90 int n_tries;
91 int origin_tries;
92 #if WIP_FWD_LOG
93
94 http_status last_status;
95 #endif
96
97 struct
98 {
99 unsigned int dont_retry:1;
100 unsigned int ftp_pasv_failed:1;
101 unsigned int forward_completed:1;
102 } flags;
103
104 IPAddress src; /* Client address for this connection. Needed for transparent operations. */
105 };
106
107 #endif