BIND 10 trac1828, updated. fdb3dfbe8b71bb9a4d5414f7feb3307a8fd1cda6 [1828] Close open handles when done using them (contd.)

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Apr 10 14:00:18 UTC 2012


The branch, trac1828 has been updated
       via  fdb3dfbe8b71bb9a4d5414f7feb3307a8fd1cda6 (commit)
      from  eae421b4814a766ff14199a72e489768287654db (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 fdb3dfbe8b71bb9a4d5414f7feb3307a8fd1cda6
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Apr 10 12:51:49 2012 +0530

    [1828] Close open handles when done using them (contd.)

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

Summary of changes:
 src/bin/xfrout/tests/xfrout_test.py.in             |    7 ++++++-
 src/bin/xfrout/xfrout.py.in                        |    5 +++++
 .../isc/util/cio/tests/socketsession_test.py       |    3 +++
 3 files changed, 14 insertions(+), 1 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/xfrout/tests/xfrout_test.py.in b/src/bin/xfrout/tests/xfrout_test.py.in
index b60535c..ab463d2 100644
--- a/src/bin/xfrout/tests/xfrout_test.py.in
+++ b/src/bin/xfrout/tests/xfrout_test.py.in
@@ -1201,6 +1201,7 @@ class TestUnixSockServer(unittest.TestCase):
         self.assertEqual((socket.AF_INET, socket.SOCK_STREAM,
                           ('127.0.0.1', 12345)),
                          self.unix._guess_remote(sock.fileno()))
+        sock.close()
         if socket.has_ipv6:
             # Don't check IPv6 address on hosts not supporting them
             sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
@@ -1208,6 +1209,7 @@ class TestUnixSockServer(unittest.TestCase):
             self.assertEqual((socket.AF_INET6, socket.SOCK_STREAM,
                               ('::1', 12345, 0, 0)),
                              self.unix._guess_remote(sock.fileno()))
+            sock.close()
             # Try when pretending there's no IPv6 support
             # (No need to pretend when there's really no IPv6)
             xfrout.socket.has_ipv6 = False
@@ -1218,6 +1220,7 @@ class TestUnixSockServer(unittest.TestCase):
                              self.unix._guess_remote(sock.fileno()))
             # Return it back
             xfrout.socket.has_ipv6 = True
+            sock.close()
 
     def test_receive_query_message(self):
         send_msg = b"\xd6=\x00\x00\x00\x01\x00"
@@ -1379,6 +1382,7 @@ class TestUnixSockServer(unittest.TestCase):
         old_stdout = sys.stdout
         sys.stdout = open(os.devnull, 'w')
         self.assertTrue(self.unix._sock_file_in_use(sock_file))
+        sys.stdout.close()
         sys.stdout = old_stdout
 
     def test_remove_unused_sock_file_in_use(self):
@@ -1395,7 +1399,7 @@ class TestUnixSockServer(unittest.TestCase):
         else:
             # This should never happen
             self.assertTrue(False)
-
+        sys.stdout.close()
         sys.stdout = old_stdout
 
     def test_remove_unused_sock_file_dir(self):
@@ -1411,6 +1415,7 @@ class TestUnixSockServer(unittest.TestCase):
             # This should never happen
             self.assertTrue(False)
 
+        sys.stdout.close()
         sys.stdout = old_stdout
         os.rmdir(dir_name)
 
diff --git a/src/bin/xfrout/xfrout.py.in b/src/bin/xfrout/xfrout.py.in
index 8f236ec..bbc6081 100755
--- a/src/bin/xfrout/xfrout.py.in
+++ b/src/bin/xfrout/xfrout.py.in
@@ -755,6 +755,9 @@ class UnixSockServer(socketserver_mixin.NoPollMixIn,
             socket.inet_pton(socket.AF_INET6, peer[0])
         except socket.error:
             family = socket.AF_INET
+
+        sock.close()
+
         return (family, socket.SOCK_STREAM, peer)
 
     def finish_request(self, sock_fd, request_data):
@@ -799,8 +802,10 @@ class UnixSockServer(socketserver_mixin.NoPollMixIn,
             sock = socket.socket(socket.AF_UNIX)
             sock.connect(sock_file)
         except socket.error as err:
+            sock.close()
             return False
         else:
+            sock.close()
             return True
 
     def shutdown(self):
diff --git a/src/lib/python/isc/util/cio/tests/socketsession_test.py b/src/lib/python/isc/util/cio/tests/socketsession_test.py
index 66b43d5..ab66e1a 100644
--- a/src/lib/python/isc/util/cio/tests/socketsession_test.py
+++ b/src/lib/python/isc/util/cio/tests/socketsession_test.py
@@ -177,6 +177,9 @@ class TestForwarder(unittest.TestCase):
             client_sock.setblocking(True)
             client_sock.settimeout(10)
             self.assertEqual(TEST_DATA, client_sock.recv(len(TEST_DATA)))
+            client_sock.close()
+
+        sock.close()
 
     def test_push_and_pop(self):
         # This is a straightforward port of C++ pushAndPop test.



More information about the bind10-changes mailing list