BIND 10 trac2855, updated. 920fc86fa7ff94910ca919a1b2d225b648e12139 [2855] Notify on the socket if a response is ready

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Jun 27 01:59:42 UTC 2013


The branch, trac2855 has been updated
       via  920fc86fa7ff94910ca919a1b2d225b648e12139 (commit)
      from  62db4f0c3740f86b49d51f1f7f577857abaa7f3c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 920fc86fa7ff94910ca919a1b2d225b648e12139
Author: Mukund Sivaraman <muks at isc.org>
Date:   Thu Jun 27 07:29:16 2013 +0530

    [2855] Notify on the socket if a response is ready

-----------------------------------------------------------------------

Summary of changes:
 src/lib/python/isc/memmgr/builder.py             |   12 ++++++++----
 src/lib/python/isc/memmgr/tests/builder_tests.py |   12 ++++++++++++
 2 files changed, 20 insertions(+), 4 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/memmgr/builder.py b/src/lib/python/isc/memmgr/builder.py
index 6b1b193..ae38f1e 100644
--- a/src/lib/python/isc/memmgr/builder.py
+++ b/src/lib/python/isc/memmgr/builder.py
@@ -92,9 +92,13 @@ class MemorySegmentBuilder:
                         # queue.
                         with self._lock:
                             self._response_queue.append(('bad_command',))
-                        # In this case, we do not notify the main
-                        # thread about a response on the socket, as
-                        # we quit the main loop here anyway (and any
-                        # enclosing thread).
+
                         self._shutdown = True
                         break
+
+                # Notify (any main thread) on the socket about a
+                # response. Otherwise, the main thread may wait in its
+                # loop without knowing there was a problem.
+                if len(self._response_queue) > 0:
+                    while self._sock.send(b'x') != 1:
+                        continue
diff --git a/src/lib/python/isc/memmgr/tests/builder_tests.py b/src/lib/python/isc/memmgr/tests/builder_tests.py
index 4234b91..1fae179 100644
--- a/src/lib/python/isc/memmgr/tests/builder_tests.py
+++ b/src/lib/python/isc/memmgr/tests/builder_tests.py
@@ -15,6 +15,7 @@
 
 import unittest
 import socket
+import select
 import threading
 
 import isc.log
@@ -63,6 +64,17 @@ class TestMemorySegmentBuilder(unittest.TestCase):
                 self._builder_command_queue.append('bad_command')
             self._builder_cv.notify_all()
 
+        # Wait 5 seconds to receive a notification on the socket from
+        # the builder.
+        (reads, _, _) = select.select([self._master_sock], [], [], 5)
+        self.assertTrue(self._master_sock in reads)
+
+        # Reading 1 byte should not block us here, especially as the
+        # socket is ready to read. It's a hack, but this is just a
+        # testcase.
+        got = self._master_sock.recv(1)
+        self.assertEqual(got, b'x')
+
         # Wait 5 seconds at most for the main loop of the builder to
         # exit.
         self._builder_thread.join(5)



More information about the bind10-changes mailing list