]> git.ipfire.org Git - thirdparty/squid.git/blob - src/PeerSelectState.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / PeerSelectState.h
1 /*
2 * Copyright (C) 1996-2014 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_PEERSELECTSTATE_H
10 #define SQUID_PEERSELECTSTATE_H
11
12 #include "AccessLogEntry.h"
13 #include "acl/Checklist.h"
14 #include "cbdata.h"
15 #include "comm/forward.h"
16 #include "hier_code.h"
17 #include "ip/Address.h"
18 #include "PingData.h"
19
20 class HttpRequest;
21 class StoreEntry;
22 class ErrorState;
23
24 typedef void PSC(Comm::ConnectionList *, ErrorState *, void *);
25
26 void peerSelect(Comm::ConnectionList *, HttpRequest *, AccessLogEntry::Pointer const&, StoreEntry *, PSC *, void *data);
27 void peerSelectInit(void);
28
29 /**
30 * A CachePeer which has been selected as a possible destination.
31 * Listed as pointers here so as to prevent duplicates being added but will
32 * be converted to a set of IP address path options before handing back out
33 * to the caller.
34 *
35 * Certain connection flags and outgoing settings will also be looked up and
36 * set based on the received request and CachePeer settings before handing back.
37 */
38 class FwdServer
39 {
40 public:
41 CachePeer *_peer; /* NULL --> origin server */
42 hier_code code;
43 FwdServer *next;
44 };
45
46 class ps_state
47 {
48 CBDATA_CLASS(ps_state);
49
50 public:
51 ps_state();
52 ~ps_state();
53
54 // Produce a URL for display identifying the transaction we are
55 // trying to locate a peer for.
56 const char * url() const;
57
58 HttpRequest *request;
59 AccessLogEntry::Pointer al; ///< info for the future access.log entry
60 StoreEntry *entry;
61 allow_t always_direct;
62 allow_t never_direct;
63 int direct; // TODO: fold always_direct/never_direct/prefer_direct into this now that ACL can do a multi-state result.
64 PSC *callback;
65 void *callback_data;
66 ErrorState *lastError;
67
68 Comm::ConnectionList *paths; ///< the callers paths array. to be filled with our final results.
69 FwdServer *servers; ///< temporary linked list of peers we will pass back.
70
71 /*
72 * Why are these Ip::Address instead of CachePeer *? Because a
73 * CachePeer structure can become invalid during the CachePeer selection
74 * phase, specifically after a reconfigure. Thus we need to lookup
75 * the CachePeer * based on the address when we are finally ready to
76 * reference the CachePeer structure.
77 */
78
79 Ip::Address first_parent_miss;
80
81 Ip::Address closest_parent_miss;
82 /*
83 * ->hit can be CachePeer* because it should only be
84 * accessed during the thread when it is set
85 */
86 CachePeer *hit;
87 peer_t hit_type;
88 ping_data ping;
89 ACLChecklist *acl_checklist;
90 };
91
92 #endif /* SQUID_PEERSELECTSTATE_H */
93