]> git.ipfire.org Git - thirdparty/squid.git/blob - src/PeerDigest.h
Prep for 3.3.12 and 3.4.4
[thirdparty/squid.git] / src / PeerDigest.h
1
2 /*
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 */
31
32 #ifndef SQUID_PEERDIGEST_H
33 #define SQUID_PEERDIGEST_H
34
35 #if USE_CACHE_DIGESTS
36
37 #include "cbdata.h"
38 /* for CacheDigestGuessStats */
39 #include "StatCounters.h"
40
41 class Version
42 {
43 public:
44 short int current; /* current version */
45 short int required; /* minimal version that can safely handle current version */
46 };
47
48 /* digest control block; used for transmission and storage */
49
50 class StoreDigestCBlock
51 {
52 public:
53 Version ver;
54 int capacity;
55 int count;
56 int del_count;
57 int mask_size;
58 unsigned char bits_per_entry;
59 unsigned char hash_func_count;
60 short int reserved_short;
61 int reserved[32 - 6];
62 };
63
64 class HttpRequest;
65 class PeerDigest;
66 class store_client;
67
68 class DigestFetchState
69 {
70 public:
71 PeerDigest *pd;
72 StoreEntry *entry;
73 StoreEntry *old_entry;
74 store_client *sc;
75 store_client *old_sc;
76 HttpRequest *request;
77 int offset;
78 int mask_offset;
79 time_t start_time;
80 time_t resp_time;
81 time_t expires;
82
83 struct {
84 int msg;
85 int bytes;
86 }
87
88 sent, recv;
89 char buf[SM_PAGE_SIZE];
90 ssize_t bufofs;
91 digest_read_state_t state;
92 };
93
94 class PeerDigest
95 {
96
97 public:
98 CachePeer *peer; /**< pointer back to peer structure, argh */
99 CacheDigest *cd; /**< actual digest structure */
100 String host; /**< copy of peer->host */
101 const char *req_result; /**< text status of the last request */
102
103 struct {
104 bool needed; /**< there were requests for this digest */
105 bool usable; /**< can be used for lookups */
106 bool requested; /**< in process of receiving [fresh] digest */
107 } flags;
108
109 struct {
110 /* all times are absolute unless augmented with _delay */
111 time_t initialized; /* creation */
112 time_t needed; /* first lookup/use by a peer */
113 time_t next_check; /* next scheduled check/refresh event */
114 time_t retry_delay; /* delay before re-checking _invalid_ digest */
115 time_t requested; /* requested a fresh copy of a digest */
116 time_t req_delay; /* last request response time */
117 time_t received; /* received the current copy of a digest */
118 time_t disabled; /* disabled for good */
119 } times;
120
121 struct {
122 CacheDigestGuessStats guess;
123 int used_count;
124
125 struct {
126 int msgs;
127 kb_t kbytes;
128 } sent, recv;
129 } stats;
130
131 private:
132 CBDATA_CLASS2(PeerDigest);
133 };
134
135 extern const Version CacheDigestVer;
136
137 PeerDigest *peerDigestCreate(CachePeer * p);
138 void peerDigestNeeded(PeerDigest * pd);
139 void peerDigestNotePeerGone(PeerDigest * pd);
140 void peerDigestStatsReport(const PeerDigest * pd, StoreEntry * e);
141
142 #endif /* USE_CACHE_DIGESTS */
143
144 #endif /* SQUID_PEERDIGEST_H */