Improve exception handling
- there were reports of errors in FreeBSD (I could only reproduce some) and Gentoo without IPv4 support (I don't have a VM for testing ready) - adds an exception handler for double task_done in case sender thread has to close prematurely (I saw this triggered on FreeBSD 11) - listening socket opening error handler was broken (triggered if you can't open a socket with both IPv4 and IPv6 support) - error handler for socket.accept. Reported on FreeBSD 10.3 - fixes #854
This commit is contained in:
parent
74c85b4a9e
commit
b1b0c46555
|
@ -201,7 +201,11 @@ class sendDataThread(threading.Thread):
|
|||
elif self.connectionIsOrWasFullyEstablished:
|
||||
logger.error('sendDataThread ID: ' + str(id(self)) + ' ignoring command ' + command + ' because the thread is not in stream ' + str(deststream) + ' but in streams ' + ', '.join(str(x) for x in self.streamNumber))
|
||||
self.sendDataThreadQueue.task_done()
|
||||
# Flush if the cycle ended with break
|
||||
try:
|
||||
self.sendDataThreadQueue.task_done()
|
||||
except ValueError
|
||||
pass
|
||||
|
||||
try:
|
||||
self.sock.shutdown(socket.SHUT_RDWR)
|
||||
|
|
|
@ -86,7 +86,7 @@ class singleListener(threading.Thread, StoppableThread):
|
|||
# we'll fall back to IPv4-only.
|
||||
try:
|
||||
sock = self._createListenSocket(socket.AF_INET6)
|
||||
except socket.error, e:
|
||||
except socket.error as e:
|
||||
if (isinstance(e.args, tuple) and
|
||||
e.args[0] in (errno.EAFNOSUPPORT,
|
||||
errno.EPFNOSUPPORT,
|
||||
|
@ -112,7 +112,15 @@ class singleListener(threading.Thread, StoppableThread):
|
|||
self.stop.wait(10)
|
||||
|
||||
while state.shutdown == 0:
|
||||
try:
|
||||
socketObject, sockaddr = sock.accept()
|
||||
except socket.error as e:
|
||||
if isinstance(e.args, tuple) and
|
||||
e.args[0] in (errno.EINTR,):
|
||||
continue
|
||||
time.wait(1)
|
||||
continue
|
||||
|
||||
(HOST, PORT) = sockaddr[0:2]
|
||||
|
||||
# If the address is an IPv4-mapped IPv6 address then
|
||||
|
|
Reference in New Issue
Block a user