BIND 10 rrl, updated. d4699dd393108be654b17fb415fb7a7ce6d5fdf0 [rrl] Add comment about why bases_ is not a simple array

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Dec 16 10:20:15 UTC 2013


The branch, rrl has been updated
       via  d4699dd393108be654b17fb415fb7a7ce6d5fdf0 (commit)
       via  3936d199a7b9201030cde423fa5b0fe37c57cf22 (commit)
       via  a28d2e700e8f64de065e077f5dfcdd8058b1a96f (commit)
       via  faede0d7e6fc620e726b743b9b77d5677e699a36 (commit)
       via  31756efdb327aab7daa82b8f56aa60d9db20dd30 (commit)
       via  c1dd7f4488a7e0609c2bb1333b4fab3e8280e80b (commit)
      from  31fa468dd7124cdab67266263c8b1b39e418a189 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d4699dd393108be654b17fb415fb7a7ce6d5fdf0
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Dec 16 15:50:01 2013 +0530

    [rrl] Add comment about why bases_ is not a simple array

commit 3936d199a7b9201030cde423fa5b0fe37c57cf22
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Dec 16 15:47:54 2013 +0530

    [rrl] Use doxygen syntax

commit a28d2e700e8f64de065e077f5dfcdd8058b1a96f
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Dec 16 15:44:19 2013 +0530

    [rrl] Remove a (very) confusing comment
    
    It's simpler to just read the deltaTime() description.

commit faede0d7e6fc620e726b743b9b77d5677e699a36
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Dec 16 15:38:15 2013 +0530

    [rrl] Add API doc for RRLTimeStampBases

commit 31756efdb327aab7daa82b8f56aa60d9db20dd30
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Dec 16 15:37:52 2013 +0530

    [rrl] Indent code

commit c1dd7f4488a7e0609c2bb1333b4fab3e8280e80b
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Dec 16 15:37:33 2013 +0530

    [rrl] Simplify comparison

-----------------------------------------------------------------------

Summary of changes:
 src/bin/auth/rrl/rrl_entry.h      |    7 ++++---
 src/bin/auth/rrl/rrl_timestamps.h |   41 +++++++++++++++++++++----------------
 2 files changed, 27 insertions(+), 21 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/auth/rrl/rrl_entry.h b/src/bin/auth/rrl/rrl_entry.h
index 636ea74..c8931ab 100644
--- a/src/bin/auth/rrl/rrl_entry.h
+++ b/src/bin/auth/rrl/rrl_entry.h
@@ -69,7 +69,7 @@ public:
     /// Its template parameters highly depend on the internal constraints of
     /// the RRLEntry class, so it's defined here.
     typedef RRLTimeStampBases<TIMESTAMP_BASES_COUNT, TIMESTAMP_FOREVER>
-    TimestampBases;
+        TimestampBases;
 
     int getAge(const TimestampBases& bases, std::time_t now) const {
         if (!timestamp_valid_) {
@@ -83,9 +83,9 @@ public:
     void setAge(TimestampBases& bases, std::time_t now) {
         const std::pair<std::time_t, size_t> base_result =
             bases.getCurrentBase(now);
-        const int diff = now - base_result.first;
         timestamp_gen_ = base_result.second;
-        timestamp_ = diff >= 0 ? diff : 0;
+        const int diff = now - base_result.first;
+        timestamp_ = diff > 0 ? diff : 0;
         timestamp_valid_ = TIMESTAMP_VALID;
     }
 
@@ -102,6 +102,7 @@ public:
     /// or not, rather than to get the absolute balance value.
     int getResponseBalance(const RRLRate& rates, int age) const;
 
+    /// \brief Returns the \c RRLKey corresponding to this entry.
     const RRLKey& getKey() const { return (key_); }
 
     /// \brief Return true iff the entry is "free".
diff --git a/src/bin/auth/rrl/rrl_timestamps.h b/src/bin/auth/rrl/rrl_timestamps.h
index ae5c849..6a8523a 100644
--- a/src/bin/auth/rrl/rrl_timestamps.h
+++ b/src/bin/auth/rrl/rrl_timestamps.h
@@ -26,8 +26,10 @@ namespace auth {
 namespace rrl {
 namespace detail {
 
-/// This class maintains a set of reasonably recent value of absolute
-/// timestamps in a form of a ring buffer.
+/// This class maintains a set of timestamp bases in a form of a ring
+/// buffer. A "timestamp base" is a reasonably recent value of an
+/// absolute time that is used as a base time. A "generation ID" is the
+/// index into this ring buffer.
 ///
 /// Template parameter BASES_COUNT is the buffer size.
 /// TIMESTAMP_FOREVER specifies the range of time while a base is considered
@@ -44,6 +46,11 @@ public:
     /// Its parameter is the generation ID of the base to be updated.
     typedef boost::function<void(size_t)> BaseChangeCallback;
 
+    /// \brief Constructor.
+    ///
+    /// \param initial_ts The initial timestamp to use.
+    /// \param callback This callback is invoked when a subsequent
+    /// generation ID is set in the ring buffer to a new base timestamp.
     RRLTimeStampBases(std::time_t initial_ts, BaseChangeCallback callback) :
         current_(0), callback_(callback)
     {
@@ -55,17 +62,11 @@ public:
     /// \brief Returns the timestamp base appropriate for the given time.
     ///
     /// It basically returns the current base timestamp.  But if it's too old
-    /// or if it's in the "distant future" (see deltaTime()), make a new
+    /// or if it's in the "distant future" (see \c deltaTime()), make a new
     /// timestamp base and return it.  In the latter case it calls the callback
     /// given on construction with the generation ID of the base to be updated.
     ///
-    /// Note also that the current base is in (not distant) future than \c now
-    /// depending on how the caller get it and the timing the base is updated.
-    /// Unless it's in the "distant future", this method does not update the
-    /// base and returns the current base timestamp.
-    ///
-    /// This method returns a pair of the timestamp base and of its generation
-    /// ID.
+    /// \return pair of the timestamp base and of its generation ID.
     std::pair<std::time_t, size_t>
     getCurrentBase(std::time_t now) {
         const int ts = now - bases_[current_];
@@ -79,13 +80,20 @@ public:
         return (std::pair<std::time_t, size_t>(bases_[current_], current_));
     }
 
+    /// \brief Returns the timestamp base for the passed generation ID.
     std::time_t getBaseByGen(size_t gen) const {
         return (bases_.at(gen));
     }
 
-    // Utility for calculating difference between times.  The algorithm is
-    // independent from this class, but refers to its constants, so defined
-    // here as a static member function.
+    // Utility for calculating difference between times.  The algorithm
+    // is independent from this class, but refers to its constants, so
+    // it is defined here as a static member function.
+    //
+    // If the timestamp is in the future, it might have resulted from
+    // re-ordered requests because we use timestamps on requests instead
+    // of consulting a clock.  Timestamps in the distant future are
+    // assumed to result from clock changes.  When the clock changes to
+    // the past, make existing timestamps appear to be in the past.
     static int
     deltaTime(std::time_t timestamp, std::time_t now) {
         const int delta = now - timestamp;
@@ -93,17 +101,14 @@ public:
             return (delta);
         }
 
-        // The timestamp is in the future.  That future might result from
-        // re-ordered requests, because we use timestamps on requests
-        // instead of consulting a clock.  Timestamps in the distant future are
-        // assumed to result from clock changes.  When the clock changes to
-        // the past, make existing timestamps appear to be in the past.
         if (delta < -MAX_TIME_TRAVEL) {
             return (TIMESTAMP_FOREVER);
         }
         return (0);
     }
 private:
+    // Note that bases_ is a boost::array on purpose so that
+    // getBaseByGen() throws if a request is made out of bounds.
     boost::array<std::time_t, BASES_COUNT> bases_;
     size_t current_;
     const BaseChangeCallback callback_;



More information about the bind10-changes mailing list