]> git.ipfire.org Git - thirdparty/squid.git/blob - src/PeerSelectState.h
Merged from trunk
[thirdparty/squid.git] / src / PeerSelectState.h
1 /*
2 * AUTHOR: Robert Collins
3 *
4 * SQUID Web Proxy Cache http://www.squid-cache.org/
5 * ----------------------------------------------------------
6 *
7 * Squid is the result of efforts by numerous individuals from
8 * the Internet community; see the CONTRIBUTORS file for full
9 * details. Many organizations have provided support for Squid's
10 * development; see the SPONSORS file for full details. Squid is
11 * Copyrighted (C) 2001 by the Regents of the University of
12 * California; see the COPYRIGHT file for full details. Squid
13 * incorporates software developed and/or copyrighted by other
14 * sources; see the CREDITS file for full details.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
29 *
30 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
31 */
32
33 #ifndef SQUID_PEERSELECTSTATE_H
34 #define SQUID_PEERSELECTSTATE_H
35
36 #include "acl/Checklist.h"
37 #include "Array.h"
38 #include "cbdata.h"
39 #include "comm/forward.h"
40 #include "hier_code.h"
41 #include "PingData.h"
42 #include "ip/Address.h"
43
44 class HttpRequest;
45 class StoreEntry;
46 class ErrorState;
47
48 typedef void PSC(Comm::ConnectionList *, ErrorState *, void *);
49
50 SQUIDCEXTERN void peerSelect(Comm::ConnectionList *, HttpRequest *, StoreEntry *, PSC *, void *data);
51 SQUIDCEXTERN void peerSelectInit(void);
52
53 /**
54 * A CachePeer which has been selected as a possible destination.
55 * Listed as pointers here so as to prevent duplicates being added but will
56 * be converted to a set of IP address path options before handing back out
57 * to the caller.
58 *
59 * Certain connection flags and outgoing settings will also be looked up and
60 * set based on the received request and CachePeer settings before handing back.
61 */
62 class FwdServer
63 {
64 public:
65 CachePeer *_peer; /* NULL --> origin server */
66 hier_code code;
67 FwdServer *next;
68 };
69
70 class ps_state
71 {
72
73 public:
74 void *operator new(size_t);
75 ps_state();
76 HttpRequest *request;
77 StoreEntry *entry;
78 allow_t always_direct;
79 allow_t never_direct;
80 int direct; // TODO: fold always_direct/never_direct/prefer_direct into this now that ACL can do a multi-state result.
81 PSC *callback;
82 void *callback_data;
83 ErrorState *lastError;
84
85 Comm::ConnectionList *paths; ///< the callers paths array. to be filled with our final results.
86 FwdServer *servers; ///< temporary linked list of peers we will pass back.
87
88 /*
89 * Why are these Ip::Address instead of CachePeer *? Because a
90 * CachePeer structure can become invalid during the CachePeer selection
91 * phase, specifically after a reconfigure. Thus we need to lookup
92 * the CachePeer * based on the address when we are finally ready to
93 * reference the CachePeer structure.
94 */
95
96 Ip::Address first_parent_miss;
97
98 Ip::Address closest_parent_miss;
99 /*
100 * ->hit can be CachePeer* because it should only be
101 * accessed during the thread when it is set
102 */
103 CachePeer *hit;
104 peer_t hit_type;
105 ping_data ping;
106 ACLChecklist *acl_checklist;
107 private:
108 CBDATA_CLASS(ps_state);
109 };
110
111 #endif /* SQUID_PEERSELECTSTATE_H */