[svn] commit: r3784 - /branches/trac327/src/lib/asiolink/asiolink.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Dec 9 15:05:57 UTC 2010


Author: jelte
Date: Thu Dec  9 15:05:57 2010
New Revision: 3784

Log:
don't % 0 if there are no upstreams configured

Modified:
    branches/trac327/src/lib/asiolink/asiolink.cc

Modified: branches/trac327/src/lib/asiolink/asiolink.cc
==============================================================================
--- branches/trac327/src/lib/asiolink/asiolink.cc (original)
+++ branches/trac327/src/lib/asiolink/asiolink.cc Thu Dec  9 15:05:57 2010
@@ -144,7 +144,6 @@
                 address, port, checkin_, lookup_, answer_));
             (*tcpServer)();
             servers_.push_back(tcpServer);
-
             UDPServerPtr udpServer(new UDPServer(io_service_.get_io_service(),
                 address, port, checkin_, lookup_, answer_));
             (*udpServer)();
@@ -313,14 +312,19 @@
             unsigned retries_;
             // (re)send the query to the server.
             void send() {
-                int serverIndex(random() % upstream_->size());
-                dlog("Sending upstream query (" + question_.toText() +
-                    ") to " + upstream_->at(serverIndex).first);
-                UDPQuery query(io_, question_,
-                    upstream_->at(serverIndex).first,
-                    upstream_->at(serverIndex).second, buffer_, this,
-                    timeout_);
-                io_.post(query);
+                const int uc = upstream_->size();
+                if (uc > 0) {
+                    int serverIndex(random() % uc);
+                    dlog("Sending upstream query (" + question_.toText() +
+                        ") to " + upstream_->at(serverIndex).first);
+                    UDPQuery query(io_, question_,
+                        upstream_->at(serverIndex).first,
+                        upstream_->at(serverIndex).second, buffer_, this,
+                        timeout_);
+                    io_.post(query);
+                } else {
+                    dlog("Error, no upstream servers to send to.");
+                }
             }
         public:
             RunningQuery(asio::io_service& io, const Question &question,




More information about the bind10-changes mailing list