-
/*
- * $Id: PeerDigest.h,v 1.3 2007/05/29 13:31:38 amosjeffries Exp $
- *
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
*
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
*/
#ifndef SQUID_PEERDIGEST_H
#define SQUID_PEERDIGEST_H
-#include "squid.h"
-
#if USE_CACHE_DIGESTS
#include "cbdata.h"
+#include "StatCounters.h"
-struct _Version
+class Version
{
- short int current; /* current version */
- short int required; /* minimal version that can safely handle current version */
+public:
+ short int current; /* current version */
+ short int required; /* minimal version that can safely handle current version */
};
/* digest control block; used for transmission and storage */
class StoreDigestCBlock
{
- public:
+public:
Version ver;
int capacity;
int count;
int reserved[32 - 6];
};
-struct _DigestFetchState
+class HttpRequest;
+class PeerDigest;
+class store_client;
+
+class DigestFetchState
{
+ CBDATA_CLASS(DigestFetchState);
+
+public:
+ DigestFetchState(PeerDigest *,HttpRequest *);
+ ~DigestFetchState();
+
PeerDigest *pd;
StoreEntry *entry;
StoreEntry *old_entry;
store_client *old_sc;
HttpRequest *request;
int offset;
- int mask_offset;
+ uint32_t mask_offset;
time_t start_time;
time_t resp_time;
time_t expires;
- struct
- {
+ struct {
int msg;
int bytes;
- }
+ } sent, recv;
- sent, recv;
char buf[SM_PAGE_SIZE];
ssize_t bufofs;
digest_read_state_t state;
class PeerDigest
{
+ CBDATA_CLASS(PeerDigest);
public:
- void *operator new (size_t);
- void operator delete(void *);
-
- struct _peer *peer; /* pointer back to peer structure, argh */
- CacheDigest *cd; /* actual digest structure */
- String host; /* copy of peer->host */
- const char *req_result; /* text status of the last request */
-
- struct
- {
-
-unsigned int needed:
- 1; /* there were requests for this digest */
-
-unsigned int usable:
- 1; /* can be used for lookups */
-
-unsigned int requested:
- 1; /* in process of receiving [fresh] digest */
- }
-
- flags;
-
- struct
- {
+ CachePeer *peer; /**< pointer back to peer structure, argh */
+ CacheDigest *cd; /**< actual digest structure */
+ String host; /**< copy of peer->host */
+ const char *req_result; /**< text status of the last request */
+
+ struct {
+ bool needed; /**< there were requests for this digest */
+ bool usable; /**< can be used for lookups */
+ bool requested; /**< in process of receiving [fresh] digest */
+ } flags;
+
+ struct {
/* all times are absolute unless augmented with _delay */
- time_t initialized; /* creation */
- time_t needed; /* first lookup/use by a peer */
- time_t next_check; /* next scheduled check/refresh event */
- time_t retry_delay; /* delay before re-checking _invalid_ digest */
- time_t requested; /* requested a fresh copy of a digest */
- time_t req_delay; /* last request response time */
- time_t received; /* received the current copy of a digest */
- time_t disabled; /* disabled for good */
- }
-
- times;
-
- struct
- {
- cd_guess_stats guess;
+ time_t initialized; /* creation */
+ time_t needed; /* first lookup/use by a peer */
+ time_t next_check; /* next scheduled check/refresh event */
+ time_t retry_delay; /* delay before re-checking _invalid_ digest */
+ time_t requested; /* requested a fresh copy of a digest */
+ time_t req_delay; /* last request response time */
+ time_t received; /* received the current copy of a digest */
+ time_t disabled; /* disabled for good */
+ } times;
+
+ struct {
+ CacheDigestGuessStats guess;
int used_count;
- struct
- {
+ struct {
int msgs;
- kb_t kbytes;
- }
-
- sent, recv;
- }
-
- stats;
-
-private:
- CBDATA_CLASS(PeerDigest);
+ ByteCounter kbytes;
+ } sent, recv;
+ } stats;
};
extern const Version CacheDigestVer;
-#endif
+
+PeerDigest *peerDigestCreate(CachePeer * p);
+void peerDigestNeeded(PeerDigest * pd);
+void peerDigestNotePeerGone(PeerDigest * pd);
+void peerDigestStatsReport(const PeerDigest * pd, StoreEntry * e);
+
+#endif /* USE_CACHE_DIGESTS */
#endif /* SQUID_PEERDIGEST_H */
+