Browse Source

[trac388] add check to avoid stop server twice

hanfeng 14 years ago
parent
commit
354ca192db
3 changed files with 12 additions and 0 deletions
  1. 5 0
      ChangeLog
  2. 4 0
      src/lib/asiolink/tcp_server.cc
  3. 3 0
      src/lib/asiolink/udp_server.cc

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+	172.  [func] 	feng
+	Add stop interface into dns server, so we can stop each running
+	server individually.With it, user can reconfigure its running server
+	with different ip address or port.
+
   171.  [func]      feng, jerry, jinmei, vorner
 	b10-auth, src/lib/datasrc: in memory data source now works as a
 	complete data source for authoritative DNS servers and b10-auth

+ 4 - 0
src/lib/asiolink/tcp_server.cc

@@ -189,6 +189,10 @@ TCPServer::asyncLookup() {
 }
 
 void TCPServer::stop() {
+    //server should not be stopped twice
+    if (stopped_by_hand_)
+        return;
+
     stopped_by_hand_ = true;
     acceptor_->close();
     socket_->close();

+ 3 - 0
src/lib/asiolink/udp_server.cc

@@ -281,6 +281,9 @@ UDPServer::asyncLookup() {
 /// Stop the UDPServer
 void
 UDPServer::stop() {
+    //server should not be stopped twice
+    if (data_->stopped_by_hand_)
+        return;
     data_->stopped_by_hand_ = true;
     data_->socket_->close();
 }