Browse Source

Fix missing callback

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac408@3714 e5f2f494-b856-4b98-b285-d166d9295462
Michal Vaner 14 years ago
parent
commit
1bd7db1b75
2 changed files with 23 additions and 4 deletions
  1. 1 1
      src/lib/nsas/tests/zone_entry_unittest.cc
  2. 22 3
      src/lib/nsas/zone_entry.cc

+ 1 - 1
src/lib/nsas/tests/zone_entry_unittest.cc

@@ -160,9 +160,9 @@ TEST_F(ZoneEntryTest, CallbacksAnswered) {
     EXPECT_NO_THROW(resolver_->answer(2, ns_name_, RRType::AAAA(),
     EXPECT_NO_THROW(resolver_->answer(2, ns_name_, RRType::AAAA(),
         rdata::in::AAAA("2001:db8::1")));
         rdata::in::AAAA("2001:db8::1")));
     // This should answer the third callback
     // This should answer the third callback
+    EXPECT_EQ(0, callback_->unreachable_count_);
     ASSERT_EQ(3, callback_->successes_.size());
     ASSERT_EQ(3, callback_->successes_.size());
     EXPECT_TRUE(IOAddress("2001:db8::1").equal(callback_->successes_[2]));
     EXPECT_TRUE(IOAddress("2001:db8::1").equal(callback_->successes_[2]));
-    EXPECT_EQ(0, callback_->unreachable_count_);
     // It should think it is ready
     // It should think it is ready
     EXPECT_EQ(Fetchable::READY, zone->getState());
     EXPECT_EQ(Fetchable::READY, zone->getState());
     // When we ask something more, it should be answered right away
     // When we ask something more, it should be answered right away

+ 22 - 3
src/lib/nsas/zone_entry.cc

@@ -296,6 +296,10 @@ ZoneEntry::process(CallbackPtr callback, AddressFamily family,
                 process(CallbackPtr(), V4_ONLY, nameserver, self, lock);
                 process(CallbackPtr(), V4_ONLY, nameserver, self, lock);
                 process(CallbackPtr(), V6_ONLY, nameserver, self, lock);
                 process(CallbackPtr(), V6_ONLY, nameserver, self, lock);
             } else {
             } else {
+                // Nothing to do anyway for this family, be dormant
+                if (callbacks_[family].empty()) {
+                    return;
+                }
                 /*
                 /*
                  * Check that we are only in one process call on stack.
                  * Check that we are only in one process call on stack.
                  * It eliminates the problem when there are multiple nameserver
                  * It eliminates the problem when there are multiple nameserver
@@ -341,8 +345,13 @@ ZoneEntry::process(CallbackPtr callback, AddressFamily family,
                     // We should not be locked, because this function can
                     // We should not be locked, because this function can
                     // be called directly from the askIP again
                     // be called directly from the askIP again
                     lock->unlock();
                     lock->unlock();
-                    shared_ptr<NameserverCallback> ns_callback(new
-                        NameserverCallback(self, family));
+                    shared_ptr<NameserverCallback> ns_callbacks[ADDR_REQ_MAX];;
+                    ns_callbacks[ANY_OK].reset(new NameserverCallback(self,
+                        ANY_OK));
+                    ns_callbacks[V4_ONLY].reset(new NameserverCallback(self,
+                        V4_ONLY));
+                    ns_callbacks[V6_ONLY].reset(new NameserverCallback(self,
+                        V6_ONLY));
                     /*
                     /*
                      * TODO: Possible place for an optimisation. We now ask
                      * TODO: Possible place for an optimisation. We now ask
                      * everything we can. We should limit this to something like
                      * everything we can. We should limit this to something like
@@ -351,7 +360,17 @@ ZoneEntry::process(CallbackPtr callback, AddressFamily family,
                      * away is simpler.
                      * away is simpler.
                      */
                      */
                     BOOST_FOREACH(const NameserverPtr& ns, to_ask) {
                     BOOST_FOREACH(const NameserverPtr& ns, to_ask) {
-                        ns->askIP(resolver_, ns_callback, family, ns);
+                        // Put all 3 callbacks there. If we put just the
+                        // current family, it might not work due to missing
+                        // callback for different one.
+                        // If they recurse back to us (call directly), we kill
+                        // it by the in_process_
+                        ns->askIP(resolver_, ns_callbacks[V4_ONLY], V4_ONLY,
+                            ns);
+                        ns->askIP(resolver_, ns_callbacks[V6_ONLY], V6_ONLY,
+                            ns);
+                        ns->askIP(resolver_, ns_callbacks[ANY_OK], ANY_OK,
+                            ns);
                     }
                     }
                     // Retry with all the data that might have arrived
                     // Retry with all the data that might have arrived
                     in_process_[family] = false;
                     in_process_[family] = false;