Rev 4736: Merge back the fix for #405745. in file:///home/vila/src/bzr/bugs/392127-thread-leak/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu Oct 8 09:53:34 BST 2009
At file:///home/vila/src/bzr/bugs/392127-thread-leak/
------------------------------------------------------------
revno: 4736 [merge]
revision-id: v.ladeuil+lp at free.fr-20091008085334-zrop9mam5nn6m87h
parent: v.ladeuil+lp at free.fr-20091007151748-lcg3ehht39963izr
parent: v.ladeuil+lp at free.fr-20091008082947-avilzu93drofi82n
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 392127-thread-leak
timestamp: Thu 2009-10-08 10:53:34 +0200
message:
Merge back the fix for #405745.
modified:
bzrlib/tests/http_server.py httpserver.py-20061012142527-m1yxdj1xazsf8d7s-1
-------------- next part --------------
=== modified file 'bzrlib/tests/http_server.py'
--- a/bzrlib/tests/http_server.py 2009-10-07 15:17:48 +0000
+++ b/bzrlib/tests/http_server.py 2009-10-08 08:53:34 +0000
@@ -345,6 +345,21 @@
self.server_close()
self.is_shut_down.set()
+ def connect_socket(self):
+ msg = "getaddrinfo returns an empty list"
+ for res in socket.getaddrinfo(*self.server_address):
+ af, socktype, proto, canonname, sa = res
+ sock = None
+ try:
+ sock = socket.socket(af, socktype, proto)
+ sock.connect(sa)
+ return sock
+
+ except socket.error, msg:
+ if sock is not None:
+ sock.close()
+ raise socket.error, msg
+
def shutdown(self):
"""Stops the serve() loop.
@@ -356,7 +371,7 @@
self.serving = False
# The server is listening for a last connection, let's give it:
try:
- fake_conn = socket.create_connection(self.server_address)
+ fake_conn = self.connect_socket()
fake_conn.close()
except socket.error, e:
# But ignore connection errors as the point is to unblock the
@@ -398,6 +413,11 @@
SocketServer.TCPServer.__init__(self, server_address,
request_handler_class)
+ def server_bind(self):
+ SocketServer.TCPServer.server_bind(self)
+ if sys.version < (2, 5):
+ self.server_address = self.socket.getsockname()
+
class TestingThreadingHTTPServer(TestingHTTPServerMixin,
SocketServer.ThreadingTCPServer,
@@ -440,6 +460,11 @@
t.join()
del t
+ def server_bind(self):
+ SocketServer.ThreadingTCPServer.server_bind(self)
+ if sys.version < (2, 5):
+ self.server_address = self.socket.getsockname()
+
class HttpServer(transport.Server):
"""A test server for http transports.
More information about the bazaar-commits
mailing list