From: JINMEI Tatuya Date: Wed, 20 Feb 2013 21:48:08 +0000 (-0800) Subject: [2689] fake socket.gethostbyaddr() to avoid unexpected blocking X-Git-Tag: bind10-1.1.0beta1-release~76^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5adf1f39d4b8060cd5cc7ab764f94ec6faaf5193;p=thirdparty%2Fkea.git [2689] fake socket.gethostbyaddr() to avoid unexpected blocking --- diff --git a/src/bin/stats/tests/b10-stats-httpd_test.py b/src/bin/stats/tests/b10-stats-httpd_test.py index 6a035687da..466e448437 100644 --- a/src/bin/stats/tests/b10-stats-httpd_test.py +++ b/src/bin/stats/tests/b10-stats-httpd_test.py @@ -609,8 +609,16 @@ class TestStatsHttpd(unittest.TestCase): self.stats_server.run() # checking IPv6 enabled on this platform self.ipv6_enabled = is_ipv6_enabled() + # instantiation of StatsHttpd indirectly calls gethostbyaddr(), which + # can block for an uncontrollable period, leading many undesirable + # results. We should rather eliminate the reliance, but until we + # can make such fundamental cleanup we replace it with a faked method; + # in our test scenario the return value doesn't matter. + self.__gethostbyaddr_orig = socket.gethostbyaddr + socket.gethostbyaddr = lambda x: ('test.example.', [], None) def tearDown(self): + socket.gethostbyaddr = self.__gethostbyaddr_orig if hasattr(self, "stats_httpd"): self.stats_httpd.stop() self.stats_server.shutdown()