BIND 10 trac1175, updated. eba0a7ad6baa192f4451be9072935ffbb9bb8fff [1175] - A hostname (canonical name of host) is not acceptable in listen_on configuration. - A default port number(starting number for search) is added in args of the function get_availaddr.

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Aug 23 07:42:03 UTC 2011


The branch, trac1175 has been updated
       via  eba0a7ad6baa192f4451be9072935ffbb9bb8fff (commit)
       via  d108c74508c2cc31bf8ea4c181e59ad5361e3232 (commit)
      from  a001d339b3bdc5eac0082f6ed6374043705dcb9b (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 eba0a7ad6baa192f4451be9072935ffbb9bb8fff
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Tue Aug 23 16:42:18 2011 +0900

    [1175]
     - A hostname (canonical name of host) is not acceptable in listen_on
       configuration.
     - A default port number(starting number for search) is added in args of the
       function get_availaddr.

commit d108c74508c2cc31bf8ea4c181e59ad5361e3232
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Tue Aug 23 11:22:03 2011 +0900

    [1175] set msgq verbose off

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

Summary of changes:
 src/bin/stats/stats_httpd.py.in             |    8 ++++++--
 src/bin/stats/tests/b10-stats-httpd_test.py |   24 +++++++++++-------------
 src/bin/stats/tests/test_utils.py           |    2 +-
 3 files changed, 18 insertions(+), 16 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/stats/stats_httpd.py.in b/src/bin/stats/stats_httpd.py.in
index f8d80a5..58fadc6 100644
--- a/src/bin/stats/stats_httpd.py.in
+++ b/src/bin/stats/stats_httpd.py.in
@@ -209,8 +209,12 @@ class StatsHttpd:
         httpd = None
         try:
             # get address family for the server_address before
-            # creating HttpServer object
-            address_family = socket.getaddrinfo(*server_address)[0][0]
+            # creating HttpServer object. If a specified address is
+            # not numerical, gaierror may be thrown.
+            address_family = socket.getaddrinfo(
+                server_address[0], server_address[1], 0,
+                socket.SOCK_STREAM, socket.IPPROTO_TCP, socket.AI_NUMERICHOST
+                )[0][0]
             HttpServer.address_family = address_family
             httpd = HttpServer(
                 server_address, HttpHandler,
diff --git a/src/bin/stats/tests/b10-stats-httpd_test.py b/src/bin/stats/tests/b10-stats-httpd_test.py
index 79631f4..de074bf 100644
--- a/src/bin/stats/tests/b10-stats-httpd_test.py
+++ b/src/bin/stats/tests/b10-stats-httpd_test.py
@@ -58,10 +58,11 @@ DUMMY_DATA = {
         }
     }
 
-def get_availaddr(address='127.0.0.1'):
-    """returns tuple of address and port available on the
-    platform. default range of port is from 65535 to 50000"""
-    for port in range(65535, 50000, -1):
+def get_availaddr(address='127.0.0.1', port=8001):
+    """returns tuple of address and port available to listen on the
+    platform. Default port range is between 8001 and 65535. If port is
+    over flow(greater than 65535), OverflowError is thrown"""
+    while True:
         try:
             if is_ipv6_enabled(address):
                 sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
@@ -71,7 +72,9 @@ def get_availaddr(address='127.0.0.1'):
             sock.close()
             return (address, port)
         except socket.error:
-            pass
+            # This address and port number are already in use.
+            # next port number is added
+            port = port + 1
 
 def is_ipv6_enabled(address='::1', port=8000):
     """checks IPv6 enabled on the platform"""
@@ -403,14 +406,9 @@ class TestStatsHttpd(unittest.TestCase):
                 self.assertTrue(isinstance(ht.socket, socket.socket))
             self.stats_httpd.stop()
 
-        # hostname
-        server_addresses = get_availaddr(address='localhost')
-        self.stats_httpd = MyStatsHttpd(server_addresses)
-        for ht in self.stats_httpd.httpd:
-            self.assertTrue(isinstance(ht, stats_httpd.HttpServer))
-            self.assertTrue(ht.address_family in set([socket.AF_INET, socket.AF_INET6]))
-            self.assertTrue(isinstance(ht.socket, socket.socket))
-        self.stats_httpd.stop()
+        # existent hostname
+        self.assertRaises(stats_httpd.HttpServerError, MyStatsHttpd,
+                          get_availaddr(address='localhost'))
 
         # nonexistent hostname
         self.assertRaises(stats_httpd.HttpServerError, MyStatsHttpd, ('my.host.domain', 8000))
diff --git a/src/bin/stats/tests/test_utils.py b/src/bin/stats/tests/test_utils.py
index e3c8cdc..44cf7c5 100644
--- a/src/bin/stats/tests/test_utils.py
+++ b/src/bin/stats/tests/test_utils.py
@@ -60,7 +60,7 @@ class ThreadingServerManager:
 class MockMsgq:
     def __init__(self):
         self._started = threading.Event()
-        self.msgq = msgq.MsgQ(verbose=True)
+        self.msgq = msgq.MsgQ(verbose=False)
         result = self.msgq.setup()
         if result:
             sys.exit("Error on Msgq startup: %s" % result)




More information about the bind10-changes mailing list