[svn] commit: r3165 - in /branches/trac335/src/bin/zonemgr: tests/zonemgr_test.py zonemgr.py.in

BIND 10 source code commits bind10-changes at lists.isc.org
Sun Oct 10 13:50:02 UTC 2010


Author: chenzhengzhang
Date: Sun Oct 10 13:50:02 2010
New Revision: 3165

Log:
fix a zonemgr test case issue(issue on exiting thread)

Modified:
    branches/trac335/src/bin/zonemgr/tests/zonemgr_test.py
    branches/trac335/src/bin/zonemgr/zonemgr.py.in

Modified: branches/trac335/src/bin/zonemgr/tests/zonemgr_test.py
==============================================================================
--- branches/trac335/src/bin/zonemgr/tests/zonemgr_test.py (original)
+++ branches/trac335/src/bin/zonemgr/tests/zonemgr_test.py Sun Oct 10 13:50:02 2010
@@ -396,7 +396,13 @@
         listener.start()
         # 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()
         # 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())
@@ -404,12 +410,16 @@
 
     def test_shutdown(self):
         self.zone_refresh._check_sock = self.zone_refresh._master_socket 
-        listener = threading.Thread(target=self.zone_refresh.run_timer)
+        listener = threading.Thread(target = self.zone_refresh.run_timer)
         listener.start()
         self.assertTrue(listener.is_alive())
+        # Shut down the timer thread
         self.zone_refresh.shutdown()
-        # Sleep 1 sec to ensure that the timer thread has enough time to exit.
-        time.sleep(1)
+        main_thread = threading.currentThread()
+        for th in threading.enumerate():
+            if th is main_thread:
+                continue
+            th.join()
         self.assertFalse(listener.is_alive())
 
     def tearDown(self):

Modified: branches/trac335/src/bin/zonemgr/zonemgr.py.in
==============================================================================
--- branches/trac335/src/bin/zonemgr/zonemgr.py.in (original)
+++ branches/trac335/src/bin/zonemgr/zonemgr.py.in Sun Oct 10 13:50:02 2010
@@ -369,9 +369,10 @@
             if not rlist: # timer timeout 
                 continue
             if self._read_sock in rlist: # awaken by shutdown socket 
+                self._read_sock.recv(32)
                 continue 
             if self._check_sock in rlist: # awaken by check socket
-                self._check_sock.recv(5)
+                self._check_sock.recv(32)
 
         self._is_shut_down.set()
 
@@ -389,7 +390,7 @@
         self._db_file = self.get_db_file()
         # Create socket pair for communicating between main thread and zonemgr timer thread 
         self._master_socket, self._slave_socket = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM)
-        self._zone_refresh= ZonemgrRefresh(self._cc, self._db_file, self._slave_socket)
+        self._zone_refresh = ZonemgrRefresh(self._cc, self._db_file, self._slave_socket)
         self._start_zone_refresh_timer()
 
         self._lock = threading.Lock()




More information about the bind10-changes mailing list