Reduce the size of the window between opening a socket and setting it uninheritable.

This commit is contained in:
Charles Haley 2014-04-20 11:56:32 +02:00
parent 7af2683b7d
commit e432dc6104

View File

@ -130,17 +130,17 @@ class ConnectionListener(Thread):
getattr(self.driver, 'listen_socket', None) is not None:
ans = select.select((self.driver.listen_socket,), (), (), 0)
if len(ans[0]) > 0:
# timeout in 10 ms to detect rare case where the socket went
# way between the select and the accept
# timeout in 10 ms to detect rare case where the socket goes
# away between the select and the accept
try:
self.driver._debug('attempt to open device socket')
device_socket = None
self.driver.listen_socket.settimeout(0.010)
device_socket, ign = eintr_retry_call(
self.driver.listen_socket.accept)
set_socket_inherit(device_socket, False)
self.driver.listen_socket.settimeout(None)
device_socket.settimeout(None)
set_socket_inherit(device_socket, False)
try:
self.driver.connection_queue.put_nowait(device_socket)