SocketPipe shouldn't close the socket.
This is a layering violation - the SocketPipe doesn't own the socket and provides no other way to close the socket, leading to unnecessary complexity like that in interface.py. I looked at deamon.py and NetworkProxy - the two other users, and they don't close the sockets explicitly, just let them be garbage collected.
This commit is contained in:
parent
90d7179d73
commit
2f2e468d0a
|
@ -61,7 +61,6 @@ class TcpInterface(threading.Thread):
|
|||
# closing the socket
|
||||
self.disconnect = False
|
||||
self._status = CS_OPENING
|
||||
self.needs_shutdown = True
|
||||
self.debug = False # dump network messages. can be changed at runtime using the console
|
||||
self.message_id = 0
|
||||
self.response_queue = response_queue
|
||||
|
@ -304,7 +303,6 @@ class TcpInterface(threading.Thread):
|
|||
return
|
||||
# If remote side closed the socket, SocketPipe closes our socket and returns None
|
||||
if response is None:
|
||||
self.needs_shutdown = False # Don't re-close the socket
|
||||
self.disconnect = True
|
||||
self.print_error("connection closed remotely")
|
||||
else:
|
||||
|
@ -323,7 +321,6 @@ class TcpInterface(threading.Thread):
|
|||
self.maybe_ping()
|
||||
self.send_requests()
|
||||
self.get_and_process_response()
|
||||
if self.needs_shutdown:
|
||||
s.shutdown(socket.SHUT_RDWR)
|
||||
s.close()
|
||||
|
||||
|
|
|
@ -360,8 +360,7 @@ class SocketPipe:
|
|||
traceback.print_exc(file=sys.stderr)
|
||||
data = ''
|
||||
|
||||
if not data:
|
||||
self.socket.close()
|
||||
if not data: # Connection closed remotely
|
||||
return None
|
||||
self.message += data
|
||||
self.recv_time = time.time()
|
||||
|
|
Loading…
Reference in New Issue