Browse Source

Fix race condition in test

It caused distcheck to fail sometimes.

There's still a small race condition, but it is hopefully only
theoretical issue.

Reviewed in jabber room.

git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@3275 e5f2f494-b856-4b98-b285-d166d9295462
Michal Vaner 14 years ago
parent
commit
a6c76ef642
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/bin/zonemgr/zonemgr.py.in

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

@@ -323,7 +323,8 @@ class ZonemgrRefresh:
 
 
         return False
         return False
 
 
-    def _run_timer(self):
+    def _run_timer(self, start_event):
+        start_event.set()
         while self._running:
         while self._running:
             # If zonemgr has no zone, set timer timeout to LOWERBOUND_RETRY.
             # If zonemgr has no zone, set timer timeout to LOWERBOUND_RETRY.
             if self._zone_mgr_is_empty():
             if self._zone_mgr_is_empty():
@@ -371,12 +372,15 @@ class ZonemgrRefresh:
         # Prepare the launch
         # Prepare the launch
         self._running = True
         self._running = True
         (self._read_sock, self._write_sock) = socket.socketpair()
         (self._read_sock, self._write_sock) = socket.socketpair()
+        start_event = threading.Event()
 
 
         # Start the thread
         # Start the thread
-        self._thread = threading.Thread(target = self._run_timer, args = ())
+        self._thread = threading.Thread(target = self._run_timer,
+            args = (start_event,))
         if daemon:
         if daemon:
             self._thread.setDaemon(True)
             self._thread.setDaemon(True)
         self._thread.start()
         self._thread.start()
+        start_event.wait()
 
 
         # Return the thread to anyone interested
         # Return the thread to anyone interested
         return self._thread
         return self._thread