BIND 10 trac1599, updated. d6d42bcdfcc80b450b89937ffd5ba39b071b3f37 [1599] Don't send after being stopped

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Feb 22 15:32:45 UTC 2012


The branch, trac1599 has been updated
       via  d6d42bcdfcc80b450b89937ffd5ba39b071b3f37 (commit)
      from  0c0161c6e555e2c8b33b3291043727bc07324dc2 (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 d6d42bcdfcc80b450b89937ffd5ba39b071b3f37
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Feb 22 16:32:33 2012 +0100

    [1599] Don't send after being stopped

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

Summary of changes:
 src/lib/asiodns/sync_udp_server.cc |   16 ++++++++++++++--
 src/lib/asiodns/sync_udp_server.h  |    2 +-
 2 files changed, 15 insertions(+), 3 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/asiodns/sync_udp_server.cc b/src/lib/asiodns/sync_udp_server.cc
index 4974882..00d43fe 100644
--- a/src/lib/asiodns/sync_udp_server.cc
+++ b/src/lib/asiodns/sync_udp_server.cc
@@ -47,7 +47,7 @@ SyncUDPServer::SyncUDPServer(asio::io_service& io_service,
                              asiolink::SimpleCallback* checkin,
                              DNSLookup* lookup, DNSAnswer* answer) :
     io_(io_service), checkin_callback_(checkin), lookup_callback_(lookup),
-    answer_callback_(answer)
+    answer_callback_(answer), stopped_(false)
 {
     // We must use different instantiations for v4 and v6;
     // otherwise ASIO will bind to both
@@ -65,7 +65,7 @@ SyncUDPServer::SyncUDPServer(asio::io_service& io_service, const int fd,
                              const int af, asiolink::SimpleCallback* checkin,
                              DNSLookup* lookup, DNSAnswer* answer) :
     io_(io_service), checkin_callback_(checkin), lookup_callback_(lookup),
-    answer_callback_(answer)
+    answer_callback_(answer), stopped_(false)
 {
     if (af != AF_INET && af != AF_INET6) {
         isc_throw(InvalidParameter, "Address family must be either AF_INET "
@@ -122,6 +122,9 @@ SyncUDPServer::handleRead(const asio::error_code& ec, const size_t length) {
     IOMessage message(data_, length, socket, endpoint);
     if (checkin_callback_ != NULL) {
         (*checkin_callback_)(message);
+        if (stopped_) {
+            return;
+        }
     }
 
     // If we don't have a DNS Lookup provider, there's no point in
@@ -150,11 +153,19 @@ SyncUDPServer::handleRead(const asio::error_code& ec, const size_t length) {
                   "No resume called from the lookup callback");
     }
 
+    if (stopped_) {
+        return;
+    }
+
     if (done_) {
         // Good, there's an answer.
         // Call the answer callback to render it.
         (*answer_callback_)(message, query, answer, output);
 
+        if (stopped_) {
+            return;
+        }
+
         socket_->send_to(asio::buffer(output->getData(), output->getLength()),
                          sender_);
     }
@@ -182,6 +193,7 @@ SyncUDPServer::stop() {
     /// submit to io serice before or after close call. And we will
     //. get bad_descriptor error
     socket_->close();
+    stopped_ = true;
 }
 
 /// Post this coroutine on the ASIO service queue so that it will
diff --git a/src/lib/asiodns/sync_udp_server.h b/src/lib/asiodns/sync_udp_server.h
index 57aecdf..84a5c2c 100644
--- a/src/lib/asiodns/sync_udp_server.h
+++ b/src/lib/asiodns/sync_udp_server.h
@@ -115,7 +115,7 @@ private:
     const asiolink::SimpleCallback* checkin_callback_;
     const DNSLookup* lookup_callback_;
     const DNSAnswer* answer_callback_;
-    bool resume_called_, done_;
+    bool resume_called_, done_, stopped_;
 
     void scheduleRead();
     void handleRead(const asio::error_code& ec, const size_t length);



More information about the bind10-changes mailing list