]> git.ipfire.org Git - thirdparty/squid.git/blob - src/PeerDigest.h
Cleanup: zap CVS Id tags
[thirdparty/squid.git] / src / PeerDigest.h
1
2 /*
3 * $Id$
4 *
5 *
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
8 *
9 * Squid is the result of efforts by numerous individuals from
10 * the Internet community; see the CONTRIBUTORS file for full
11 * details. Many organizations have provided support for Squid's
12 * development; see the SPONSORS file for full details. Squid is
13 * Copyrighted (C) 2001 by the Regents of the University of
14 * California; see the COPYRIGHT file for full details. Squid
15 * incorporates software developed and/or copyrighted by other
16 * sources; see the CREDITS file for full details.
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
31 *
32 */
33
34 #ifndef SQUID_PEERDIGEST_H
35 #define SQUID_PEERDIGEST_H
36
37 #include "squid.h"
38
39 #if USE_CACHE_DIGESTS
40
41 #include "cbdata.h"
42
43 struct _Version {
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 struct _DigestFetchState {
65 PeerDigest *pd;
66 StoreEntry *entry;
67 StoreEntry *old_entry;
68 store_client *sc;
69 store_client *old_sc;
70 HttpRequest *request;
71 int offset;
72 int mask_offset;
73 time_t start_time;
74 time_t resp_time;
75 time_t expires;
76
77 struct {
78 int msg;
79 int bytes;
80 }
81
82 sent, recv;
83 char buf[SM_PAGE_SIZE];
84 ssize_t bufofs;
85 digest_read_state_t state;
86 };
87
88 class PeerDigest
89 {
90
91 public:
92 void *operator new (size_t);
93 void operator delete(void *);
94
95 struct peer *peer; /**< pointer back to peer structure, argh */
96 CacheDigest *cd; /**< actual digest structure */
97 String host; /**< copy of peer->host */
98 const char *req_result; /**< text status of the last request */
99
100 struct {
101 unsigned int needed:1; /**< there were requests for this digest */
102 unsigned int usable:1; /**< can be used for lookups */
103 unsigned int requested:1; /**< in process of receiving [fresh] digest */
104 } flags;
105
106 struct {
107 /* all times are absolute unless augmented with _delay */
108 time_t initialized; /* creation */
109 time_t needed; /* first lookup/use by a peer */
110 time_t next_check; /* next scheduled check/refresh event */
111 time_t retry_delay; /* delay before re-checking _invalid_ digest */
112 time_t requested; /* requested a fresh copy of a digest */
113 time_t req_delay; /* last request response time */
114 time_t received; /* received the current copy of a digest */
115 time_t disabled; /* disabled for good */
116 } times;
117
118 struct {
119 cd_guess_stats guess;
120 int used_count;
121
122 struct {
123 int msgs;
124 kb_t kbytes;
125 } sent, recv;
126 } stats;
127
128 private:
129 CBDATA_CLASS(PeerDigest);
130 };
131
132 extern const Version CacheDigestVer;
133
134 #endif /* USE_CACHE_DIGESTS */
135
136 #endif /* SQUID_PEERDIGEST_H */