2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_PEERDIGEST_H
10 #define SQUID_PEERDIGEST_H
15 #include "StatCounters.h"
20 short int current
; /* current version */
21 short int required
; /* minimal version that can safely handle current version */
24 /* digest control block; used for transmission and storage */
26 class StoreDigestCBlock
34 unsigned char bits_per_entry
;
35 unsigned char hash_func_count
;
36 short int reserved_short
;
44 class DigestFetchState
46 CBDATA_CLASS(DigestFetchState
);
49 DigestFetchState(PeerDigest
*,HttpRequest
*);
54 StoreEntry
*old_entry
;
69 char buf
[SM_PAGE_SIZE
];
71 digest_read_state_t state
;
76 CBDATA_CLASS(PeerDigest
);
79 PeerDigest(CachePeer
*);
82 CachePeer
*peer
= nullptr; /**< pointer back to peer structure, argh */
83 CacheDigest
*cd
= nullptr; /**< actual digest structure */
84 SBuf host
; ///< copy of peer->host
85 const char *req_result
= nullptr; /**< text status of the last request */
88 bool needed
= false; /**< there were requests for this digest */
89 bool usable
= false; /**< can be used for lookups */
90 bool requested
= false; /**< in process of receiving [fresh] digest */
94 /* all times are absolute unless augmented with _delay */
95 time_t initialized
= 0; /* creation */
96 time_t needed
= 0; /* first lookup/use by a peer */
97 time_t next_check
= 0; /* next scheduled check/refresh event */
98 time_t retry_delay
= 0; /* delay before re-checking _invalid_ digest */
99 time_t requested
= 0; /* requested a fresh copy of a digest */
100 time_t req_delay
= 0; /* last request response time */
101 time_t received
= 0; /* received the current copy of a digest */
102 time_t disabled
= 0; /* disabled for good */
106 CacheDigestGuessStats guess
;
116 extern const Version CacheDigestVer
;
118 void peerDigestCreate(CachePeer
* p
);
119 void peerDigestNeeded(PeerDigest
* pd
);
120 void peerDigestNotePeerGone(PeerDigest
* pd
);
121 void peerDigestStatsReport(const PeerDigest
* pd
, StoreEntry
* e
);
123 #endif /* USE_CACHE_DIGESTS */
125 #endif /* SQUID_PEERDIGEST_H */