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