Browse Source

remove useless code line

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac335@3169 e5f2f494-b856-4b98-b285-d166d9295462
Jerry 14 years ago
parent
commit
b5fa0bf095
2 changed files with 14 additions and 16 deletions
  1. 12 12
      src/bin/zonemgr/tests/zonemgr_test.py
  2. 2 4
      src/bin/zonemgr/zonemgr.py.in

+ 12 - 12
src/bin/zonemgr/tests/zonemgr_test.py

@@ -57,6 +57,16 @@ class MyZonemgrRefresh(ZonemgrRefresh):
          'zone_soa_rdata': 'a.dns.cn. root.cnnic.cn. 2009073112 7200 3600 2419200 21600', 
          'zone_soa_rdata': 'a.dns.cn. root.cnnic.cn. 2009073112 7200 3600 2419200 21600', 
          'zone_state': 0}
          'zone_state': 0}
         } 
         } 
+
+    def stop_timer(self):
+        ''' Exit timer thread '''
+        self.shutdown()
+        main_thread = threading.currentThread()
+        for th in threading.enumerate():
+            if th is main_thread:
+                continue
+            th.join()
+
         
         
 class TestZonemgrRefresh(unittest.TestCase):
 class TestZonemgrRefresh(unittest.TestCase):
     def setUp(self):
     def setUp(self):
@@ -397,12 +407,7 @@ class TestZonemgrRefresh(unittest.TestCase):
         # Sleep 1 sec to ensure that the timer thread has enough time to run.
         # Sleep 1 sec to ensure that the timer thread has enough time to run.
         time.sleep(1)
         time.sleep(1)
         # Shut down the timer thread
         # Shut down the timer thread
-        self.zone_refresh.shutdown()
+        self.zone_refresh.stop_timer()
-        main_thread = threading.currentThread()
-        for th in threading.enumerate():
-            if th is main_thread:
-                continue
-            th.join()
         # After running timer, the zone's state should become "refreshing".
         # After running timer, the zone's state should become "refreshing".
         zone_state = self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["zone_state"]
         zone_state = self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["zone_state"]
         self.assertTrue("refresh_timeout" in self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN].keys())
         self.assertTrue("refresh_timeout" in self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN].keys())
@@ -414,12 +419,7 @@ class TestZonemgrRefresh(unittest.TestCase):
         listener.start()
         listener.start()
         self.assertTrue(listener.is_alive())
         self.assertTrue(listener.is_alive())
         # Shut down the timer thread
         # Shut down the timer thread
-        self.zone_refresh.shutdown()
+        self.zone_refresh.stop_timer()
-        main_thread = threading.currentThread()
-        for th in threading.enumerate():
-            if th is main_thread:
-                continue
-            th.join()
         self.assertFalse(listener.is_alive())
         self.assertFalse(listener.is_alive())
 
 
     def tearDown(self):
     def tearDown(self):

+ 2 - 4
src/bin/zonemgr/zonemgr.py.in

@@ -335,8 +335,7 @@ class ZonemgrRefresh:
         """Keep track of zone timers. The loop can be stopped by calling shutdown() in 
         """Keep track of zone timers. The loop can be stopped by calling shutdown() in 
         another thread.
         another thread.
         """
         """
-        runnable = True
+        while True:
-        while runnable:
             # Zonemgr has no zone.
             # Zonemgr has no zone.
             if self._zone_mgr_is_empty():
             if self._zone_mgr_is_empty():
                 time.sleep(LOWERBOUND_RETRY) # A better time?
                 time.sleep(LOWERBOUND_RETRY) # A better time?
@@ -367,8 +366,7 @@ class ZonemgrRefresh:
                 continue
                 continue
             if self._read_sock in rlist: # awaken by shutdown socket 
             if self._read_sock in rlist: # awaken by shutdown socket 
                 self._read_sock.recv(32)
                 self._read_sock.recv(32)
-                runnable = False
+                return
-                continue 
             if self._check_sock in rlist: # awaken by check socket
             if self._check_sock in rlist: # awaken by check socket
                 self._check_sock.recv(32)
                 self._check_sock.recv(32)