BIND 10 master, updated. 6f6f5892046cb552bf334d2e5f84cf575dde3da5 [trac420] Fix some portability issues

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Jan 25 21:37:46 UTC 2011


The branch, master has been updated
       via  6f6f5892046cb552bf334d2e5f84cf575dde3da5 (commit)
      from  a2a812ede6d3df4a70d6309437c6715cb09a7670 (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 6f6f5892046cb552bf334d2e5f84cf575dde3da5
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Tue Jan 25 22:35:13 2011 +0100

    [trac420] Fix some portability issues
    
    * kqueue maybe doesn't survive fork on MacOS
    * add_kqueue_socket wanted socket, not fileno
    * Some systems don't have MSG_DONTWAIT, so we set the socket nonblocking

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

Summary of changes:
 src/bin/msgq/msgq.py.in         |   12 +++++++++---
 src/bin/msgq/tests/msgq_test.py |    2 +-
 2 files changed, 10 insertions(+), 4 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/msgq/msgq.py.in b/src/bin/msgq/msgq.py.in
index c5affbf..deaea6c 100644
--- a/src/bin/msgq/msgq.py.in
+++ b/src/bin/msgq/msgq.py.in
@@ -323,12 +323,18 @@ class MsgQ:
 
     def __send_data(self, sock, data):
         try:
-            return sock.send(data, socket.MSG_DONTWAIT)
+            # We set the socket nonblocking, MSG_DONTWAIT doesn't exist
+            # on some OSes
+            sock.setblocking(0)
+            return sock.send(data)
         except socket.error as e:
             if e.errno == errno.EAGAIN or e.errno == errno.EWOULDBLOCK:
                 return 0
             else:
                 raise e
+        finally:
+            # And set it back again
+            sock.setblocking(1)
 
     def send_prepared_msg(self, sock, msg):
         # Try to send the data, but only if there's nothing waiting
@@ -355,7 +361,7 @@ class MsgQ:
                     self.poller.register(fileno, select.POLLIN |
                         select.POLLOUT)
                 else:
-                    self.add_kqueue_socket(fileno, True)
+                    self.add_kqueue_socket(sock, True)
             self.sendbuffs[fileno] = (last_sent, buff)
 
     def __process_write(self, fileno):
@@ -370,7 +376,7 @@ class MsgQ:
             if self.poller:
                 self.poller.register(fileno, select.POLLIN)
             else:
-                self.add_kqueue_socket(fileno)
+                self.add_kqueue_socket(sock)
             del self.sendbuffs[fileno]
         else:
             self.sendbuffs[fileno] = (time.clock(), msg)
diff --git a/src/bin/msgq/tests/msgq_test.py b/src/bin/msgq/tests/msgq_test.py
index d8038d8..efae151 100644
--- a/src/bin/msgq/tests/msgq_test.py
+++ b/src/bin/msgq/tests/msgq_test.py
@@ -183,7 +183,6 @@ class SendNonblock(unittest.TestCase):
         Tries that sending a command many times and getting an answer works.
         """
         msgq = MsgQ()
-        msgq.setup_poller()
         # msgq.run needs to compare with the listen_socket, so we provide
         # a replacement
         class DummySocket:
@@ -196,6 +195,7 @@ class SendNonblock(unittest.TestCase):
             queue_pid = os.fork()
             if queue_pid == 0:
                 signal.alarm(30)
+                msgq.setup_poller()
                 msgq.register_socket(queue)
                 msgq.run()
             else:




More information about the bind10-changes mailing list