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_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):
     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.
         time.sleep(1)
         # Shut down the timer thread
-        self.zone_refresh.shutdown()
-        main_thread = threading.currentThread()
-        for th in threading.enumerate():
-            if th is main_thread:
-                continue
-            th.join()
+        self.zone_refresh.stop_timer()
         # After running timer, the zone's state should become "refreshing".
         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())
@@ -414,12 +419,7 @@ class TestZonemgrRefresh(unittest.TestCase):
         listener.start()
         self.assertTrue(listener.is_alive())
         # Shut down the timer thread
-        self.zone_refresh.shutdown()
-        main_thread = threading.currentThread()
-        for th in threading.enumerate():
-            if th is main_thread:
-                continue
-            th.join()
+        self.zone_refresh.stop_timer()
         self.assertFalse(listener.is_alive())
 
     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 
         another thread.
         """
-        runnable = True
-        while runnable:
+        while True:
             # Zonemgr has no zone.
             if self._zone_mgr_is_empty():
                 time.sleep(LOWERBOUND_RETRY) # A better time?
@@ -367,8 +366,7 @@ class ZonemgrRefresh:
                 continue
             if self._read_sock in rlist: # awaken by shutdown socket 
                 self._read_sock.recv(32)
-                runnable = False
-                continue 
+                return
             if self._check_sock in rlist: # awaken by check socket
                 self._check_sock.recv(32)