Browse Source

Nameserver entry has expiration time again

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac408@3692 e5f2f494-b856-4b98-b285-d166d9295462
Michal Vaner 14 years ago
parent
commit
95a25728ac
2 changed files with 13 additions and 7 deletions
  1. 10 4
      src/lib/nsas/nameserver_entry.cc
  2. 3 3
      src/lib/nsas/nameserver_entry.h

+ 10 - 4
src/lib/nsas/nameserver_entry.cc

@@ -187,6 +187,8 @@ class NameserverEntry::ResolverCallback : public ResolverInterface::Callback {
             type_(type)
             type_(type)
         { }
         { }
         virtual void success(shared_ptr<AbstractRRset> response) {
         virtual void success(shared_ptr<AbstractRRset> response) {
+            time_t now = time(NULL);
+
             Lock lock(entry_->mutex_);
             Lock lock(entry_->mutex_);
 
 
             vector<AddressEntry> entries;
             vector<AddressEntry> entries;
@@ -199,10 +201,6 @@ class NameserverEntry::ResolverCallback : public ResolverInterface::Callback {
                 return;
                 return;
             }
             }
 
 
-            /**
-             * TODO Move to common function, this is similar to
-             * what is in constructor.
-             */
             RdataIteratorPtr i(response->getRdataIterator());
             RdataIteratorPtr i(response->getRdataIterator());
             // TODO Remove at merge with trunk
             // TODO Remove at merge with trunk
             i->first();
             i->first();
@@ -230,6 +228,14 @@ class NameserverEntry::ResolverCallback : public ResolverInterface::Callback {
                 // Put the addresses there
                 // Put the addresses there
                 entry_->address_.insert(entry_->address_.end(),
                 entry_->address_.insert(entry_->address_.end(),
                     entries.begin(), entries.end());
                     entries.begin(), entries.end());
+                // Update the expiration time. If it is 0, it means we
+                // did not set it yet, so reset
+                time_t expiration(now + response->getTTL().getValue());
+                if (entry_->expiration_) {
+                    entry_->expiration_ = min(entry_->expiration_, expiration);
+                } else {
+                    entry_->expiration_ = expiration;
+                }
                 // Run the right callbacks
                 // Run the right callbacks
                 dispatchCallbacks(lock);
                 dispatchCallbacks(lock);
             }
             }

+ 3 - 3
src/lib/nsas/nameserver_entry.h

@@ -97,7 +97,8 @@ public:
     NameserverEntry(const std::string& name,
     NameserverEntry(const std::string& name,
         const isc::dns::RRClass& class_code) :
         const isc::dns::RRClass& class_code) :
         name_(name),
         name_(name),
-        classCode_(class_code)
+        classCode_(class_code),
+        expiration_(0)
     {}
     {}
 
 
     /// \brief Return Address
     /// \brief Return Address
@@ -222,8 +223,7 @@ private:
     std::string     name_;              ///< Canonical name of the nameserver
     std::string     name_;              ///< Canonical name of the nameserver
     isc::dns::RRClass classCode_;       ///< Class of the nameserver
     isc::dns::RRClass classCode_;       ///< Class of the nameserver
     std::vector<AddressEntry> address_; ///< Set of V4/V6 addresses
     std::vector<AddressEntry> address_; ///< Set of V4/V6 addresses
-    time_t          expiration_;        ///< Summary expiration time
-    time_t          last_access_;       ///< Last access time to the structure
+    time_t          expiration_;        ///< Summary expiration time. 0 = unset
     // Do we have some addresses already? Do we expect some to come?
     // Do we have some addresses already? Do we expect some to come?
     // These are set after asking for IP, if NOT_ASKED, they are uninitialized
     // These are set after asking for IP, if NOT_ASKED, they are uninitialized
     bool has_address_[ADDR_REQ_MAX], expect_address_[ADDR_REQ_MAX];
     bool has_address_[ADDR_REQ_MAX], expect_address_[ADDR_REQ_MAX];