]>
Commit | Line | Data |
---|---|---|
aa839030 | 1 | /* |
b8ae064d | 2 | * Copyright (C) 1996-2023 The Squid Software Foundation and contributors |
aa839030 | 3 | * |
bbc27441 AJ |
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. | |
aa839030 | 7 | */ |
8 | ||
ff9d9458 FC |
9 | #ifndef SQUID_SRC_PEERDIGEST_H |
10 | #define SQUID_SRC_PEERDIGEST_H | |
aa839030 | 11 | |
aa839030 | 12 | #if USE_CACHE_DIGESTS |
13 | ||
14 | #include "cbdata.h" | |
e8baef82 | 15 | #include "StatCounters.h" |
aa839030 | 16 | |
1b2f0924 FC |
17 | class Version |
18 | { | |
4d5904f7 | 19 | public: |
f53969cc SM |
20 | short int current; /* current version */ |
21 | short int required; /* minimal version that can safely handle current version */ | |
aa839030 | 22 | }; |
23 | ||
24 | /* digest control block; used for transmission and storage */ | |
25 | ||
26 | class StoreDigestCBlock | |
27 | { | |
26ac0430 | 28 | public: |
aa839030 | 29 | Version ver; |
30 | int capacity; | |
31 | int count; | |
32 | int del_count; | |
33 | int mask_size; | |
34 | unsigned char bits_per_entry; | |
35 | unsigned char hash_func_count; | |
36 | short int reserved_short; | |
37 | int reserved[32 - 6]; | |
38 | }; | |
39 | ||
73a4878a | 40 | class HttpRequest; |
c6983ec7 | 41 | class PeerDigest; |
73a4878a AJ |
42 | class store_client; |
43 | ||
1b2f0924 FC |
44 | class DigestFetchState |
45 | { | |
a44986dc AJ |
46 | CBDATA_CLASS(DigestFetchState); |
47 | ||
efdc32f4 | 48 | public: |
a44986dc AJ |
49 | DigestFetchState(PeerDigest *,HttpRequest *); |
50 | ~DigestFetchState(); | |
51 | ||
f036532e | 52 | CbcPointer<PeerDigest> pd; |
aa839030 | 53 | StoreEntry *entry; |
54 | StoreEntry *old_entry; | |
55 | store_client *sc; | |
56 | store_client *old_sc; | |
57 | HttpRequest *request; | |
58 | int offset; | |
831e953c | 59 | uint32_t mask_offset; |
aa839030 | 60 | time_t start_time; |
61 | time_t resp_time; | |
62 | time_t expires; | |
63 | ||
26ac0430 | 64 | struct { |
aa839030 | 65 | int msg; |
66 | int bytes; | |
a44986dc | 67 | } sent, recv; |
aa839030 | 68 | |
aa839030 | 69 | char buf[SM_PAGE_SIZE]; |
70 | ssize_t bufofs; | |
71 | digest_read_state_t state; | |
72 | }; | |
73 | ||
74 | class PeerDigest | |
75 | { | |
5c2f68b7 | 76 | CBDATA_CLASS(PeerDigest); |
aa839030 | 77 | |
78 | public: | |
b56b37cf AJ |
79 | PeerDigest(CachePeer *); |
80 | ~PeerDigest(); | |
81 | ||
f036532e EB |
82 | /// reacts to digest transfer completion |
83 | /// \prec DigestFetchState stats were finalized (by calling peerDigestFetchSetStats()) | |
84 | void noteFetchFinished(const DigestFetchState &, const char *outcomeDescription, bool sawError); | |
85 | ||
0f783794 | 86 | CbcPointer<CachePeer> peer; ///< pointer back to peer structure, argh |
b56b37cf | 87 | CacheDigest *cd = nullptr; /**< actual digest structure */ |
0f783794 | 88 | const SBuf host; ///< copy of peer->host |
b56b37cf | 89 | const char *req_result = nullptr; /**< text status of the last request */ |
aa839030 | 90 | |
26ac0430 | 91 | struct { |
b56b37cf AJ |
92 | bool needed = false; /**< there were requests for this digest */ |
93 | bool usable = false; /**< can be used for lookups */ | |
94 | bool requested = false; /**< in process of receiving [fresh] digest */ | |
3d0ac046 | 95 | } flags; |
aa839030 | 96 | |
26ac0430 | 97 | struct { |
aa839030 | 98 | /* all times are absolute unless augmented with _delay */ |
b56b37cf AJ |
99 | time_t initialized = 0; /* creation */ |
100 | time_t needed = 0; /* first lookup/use by a peer */ | |
101 | time_t next_check = 0; /* next scheduled check/refresh event */ | |
102 | time_t retry_delay = 0; /* delay before re-checking _invalid_ digest */ | |
103 | time_t requested = 0; /* requested a fresh copy of a digest */ | |
104 | time_t req_delay = 0; /* last request response time */ | |
105 | time_t received = 0; /* received the current copy of a digest */ | |
106 | time_t disabled = 0; /* disabled for good */ | |
3d0ac046 | 107 | } times; |
aa839030 | 108 | |
26ac0430 | 109 | struct { |
e8baef82 | 110 | CacheDigestGuessStats guess; |
b56b37cf | 111 | int used_count = 0; |
aa839030 | 112 | |
26ac0430 | 113 | struct { |
b56b37cf | 114 | int msgs = 0; |
a0864754 | 115 | ByteCounter kbytes; |
3d0ac046 HN |
116 | } sent, recv; |
117 | } stats; | |
aa839030 | 118 | }; |
119 | ||
120 | extern const Version CacheDigestVer; | |
e1f7507e | 121 | |
8a648e8d FC |
122 | void peerDigestNeeded(PeerDigest * pd); |
123 | void peerDigestNotePeerGone(PeerDigest * pd); | |
124 | void peerDigestStatsReport(const PeerDigest * pd, StoreEntry * e); | |
fc54b8d2 | 125 | |
e1f7507e | 126 | #endif /* USE_CACHE_DIGESTS */ |
aa839030 | 127 | |
ff9d9458 | 128 | #endif /* SQUID_SRC_PEERDIGEST_H */ |
f53969cc | 129 |