]> git.ipfire.org Git - thirdparty/squid.git/blob - src/StoreMetaMD5.cc
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / StoreMetaMD5.cc
1 /*
2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9 /* DEBUG: section 20 Storage Manager Swapfile Metadata */
10
11 #include "squid.h"
12 #include "int.h"
13 #include "md5.h"
14 #include "MemObject.h"
15 #include "Store.h"
16 #include "StoreMetaMD5.h"
17
18 bool
19 StoreMetaMD5::validLength(int len) const
20 {
21 return len == SQUID_MD5_DIGEST_LENGTH;
22 }
23
24 int StoreMetaMD5::md5_mismatches = 0;
25
26 bool
27 StoreMetaMD5::checkConsistency(StoreEntry *e) const
28 {
29 assert (getType() == STORE_META_KEY_MD5);
30 assert(length == SQUID_MD5_DIGEST_LENGTH);
31
32 if (!EBIT_TEST(e->flags, KEY_PRIVATE) &&
33 memcmp(value, e->key, SQUID_MD5_DIGEST_LENGTH)) {
34 debugs(20, 2, "storeClientReadHeader: swapin MD5 mismatch");
35 // debugs(20, 2, "\t" << storeKeyText((const cache_key *)value));
36 debugs(20, 2, "\t" << e->getMD5Text());
37
38 if (isPowTen(++md5_mismatches))
39 debugs(20, DBG_IMPORTANT, "WARNING: " << md5_mismatches << " swapin MD5 mismatches");
40
41 return false;
42 }
43
44 return true;
45 }
46