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