]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/PeerDigest.h
Docs: Copyright updates for 2018 (#114)
[thirdparty/squid.git] / src / PeerDigest.h
index b6b9025a0a351e3714e0c3ae53a5e2a631ce67db..442e90542e34643ede382e579f5d0c5fe24a4fdc 100644 (file)
@@ -1,32 +1,9 @@
-
 /*
+ * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
  *
- * 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.
- *
+ * 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
 #if USE_CACHE_DIGESTS
 
 #include "cbdata.h"
-/* for CacheDigestGuessStats */
 #include "StatCounters.h"
 
-struct _Version {
-    short int current;         /* current version */
-    short int required;                /* minimal version that can safely handle current version */
+class 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 */
@@ -59,7 +37,18 @@ public:
     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;
@@ -67,7 +56,7 @@ struct _DigestFetchState {
     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;
@@ -75,9 +64,8 @@ struct _DigestFetchState {
     struct {
         int msg;
         int bytes;
-    }
+    } sent, recv;
 
-    sent, recv;
     char buf[SM_PAGE_SIZE];
     ssize_t bufofs;
     digest_read_state_t state;
@@ -85,32 +73,30 @@ struct _DigestFetchState {
 
 class PeerDigest
 {
+    CBDATA_CLASS(PeerDigest);
 
 public:
-    void *operator new (size_t);
-    void operator delete(void *);
-
-    struct peer *peer;          /**< pointer back to peer structure, argh */
+    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 {
-        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 */
+        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 */
+        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 {
@@ -119,21 +105,19 @@ public:
 
         struct {
             int msgs;
-            kb_t kbytes;
+            ByteCounter kbytes;
         } sent, recv;
     } stats;
-
-private:
-    CBDATA_CLASS(PeerDigest);
 };
 
 extern const Version CacheDigestVer;
 
-extern PeerDigest *peerDigestCreate(peer * p);
-extern void peerDigestNeeded(PeerDigest * pd);
-extern void peerDigestNotePeerGone(PeerDigest * pd);
-extern void peerDigestStatsReport(const PeerDigest * pd, StoreEntry * e);
+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 */
+