SSL disconnect fix
- sometimes SSL connections unnecessarily disconnected on non-fatal errors. This should fix that. This is however a short term solution because of migrating to asyncore which has its own error handling
This commit is contained in:
parent
1d3757ddc8
commit
5cea1e04d1
|
@ -90,9 +90,11 @@ class receiveDataThread(threading.Thread):
|
||||||
shared.numberOfBytesReceivedLastSecond = 0
|
shared.numberOfBytesReceivedLastSecond = 0
|
||||||
dataLen = len(self.data)
|
dataLen = len(self.data)
|
||||||
try:
|
try:
|
||||||
|
ssl = False
|
||||||
if ((self.services & shared.NODE_SSL == shared.NODE_SSL) and
|
if ((self.services & shared.NODE_SSL == shared.NODE_SSL) and
|
||||||
self.connectionIsOrWasFullyEstablished and
|
self.connectionIsOrWasFullyEstablished and
|
||||||
shared.haveSSL(not self.initiatedConnection)):
|
shared.haveSSL(not self.initiatedConnection)):
|
||||||
|
ssl = True
|
||||||
dataRecv = self.sslSock.recv(1024)
|
dataRecv = self.sslSock.recv(1024)
|
||||||
else:
|
else:
|
||||||
dataRecv = self.sock.recv(1024)
|
dataRecv = self.sock.recv(1024)
|
||||||
|
@ -103,8 +105,11 @@ class receiveDataThread(threading.Thread):
|
||||||
logger.error ('Timeout occurred waiting for data from ' + str(self.peer) + '. Closing receiveData thread. (ID: ' + str(id(self)) + ')')
|
logger.error ('Timeout occurred waiting for data from ' + str(self.peer) + '. Closing receiveData thread. (ID: ' + str(id(self)) + ')')
|
||||||
break
|
break
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
if (sys.platform == 'win32' and err.errno in ([2, 10035])) or (sys.platform != 'win32' and err.errno == errno.EWOULDBLOCK):
|
if err.errno == 2 or (sys.platform == 'win32' and err.errno == 10035) or (sys.platform != 'win32' and err.errno == errno.EWOULDBLOCK):
|
||||||
select.select([self.sslSock], [], [])
|
if ssl:
|
||||||
|
select.select([self.sslSock], [], [])
|
||||||
|
else:
|
||||||
|
select.select([self.sock], [], [])
|
||||||
continue
|
continue
|
||||||
logger.error('sock.recv error. Closing receiveData thread (' + str(self.peer) + ', Thread ID: ' + str(id(self)) + ').' + str(err.errno) + "/" + str(err))
|
logger.error('sock.recv error. Closing receiveData thread (' + str(self.peer) + ', Thread ID: ' + str(id(self)) + ').' + str(err.errno) + "/" + str(err))
|
||||||
if self.initiatedConnection and not self.connectionIsOrWasFullyEstablished:
|
if self.initiatedConnection and not self.connectionIsOrWasFullyEstablished:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user