Check if self._sock exists before trying to close it. Fixes #2839.
This commit is contained in:
parent
5f16eb633b
commit
e816b38a0f
|
@ -366,12 +366,14 @@ class NonBlockingTcp(PlugIn, IdleObject):
|
|||
self.remove_timeout()
|
||||
self._owner.disconnected()
|
||||
self.idlequeue.unplug_idle(self.fd)
|
||||
sock = getattr(self, '_sock', None)
|
||||
if sock:
|
||||
try:
|
||||
self._sock.shutdown(socket.SHUT_RDWR)
|
||||
sock.shutdown(socket.SHUT_RDWR)
|
||||
except socket.error, e:
|
||||
if e[0] != errno.ENOTCONN:
|
||||
log.error("Error shutting down socket for %s:", self.getName(), exc_info=True)
|
||||
try: self._sock.close()
|
||||
try: sock.close()
|
||||
except: log.error("Error closing socket for %s:", self.getName(), exc_info=True)
|
||||
# socket descriptor cannot be (un)plugged anymore
|
||||
self.fd = -1
|
||||
|
|
Loading…
Reference in New Issue