Fix potential deadlock
- alreadyAttemptedConnectionsListLock probably deadlocked - removed locking where unnecessary and rewrote the important part with proper locking
This commit is contained in:
parent
af8957ed72
commit
d0b0d15dc3
|
@ -85,9 +85,7 @@ class outgoingSynSender(threading.Thread, StoppableThread):
|
|||
break
|
||||
random.seed()
|
||||
peer = self._getPeer()
|
||||
shared.alreadyAttemptedConnectionsListLock.acquire()
|
||||
while peer in shared.alreadyAttemptedConnectionsList or peer.host in shared.connectedHostsList:
|
||||
shared.alreadyAttemptedConnectionsListLock.release()
|
||||
# print 'choosing new sample'
|
||||
random.seed()
|
||||
peer = self._getPeer()
|
||||
|
@ -97,16 +95,12 @@ class outgoingSynSender(threading.Thread, StoppableThread):
|
|||
# Clear out the shared.alreadyAttemptedConnectionsList every half
|
||||
# hour so that this program will again attempt a connection
|
||||
# to any nodes, even ones it has already tried.
|
||||
with shared.alreadyAttemptedConnectionsListLock:
|
||||
if (time.time() - shared.alreadyAttemptedConnectionsListResetTime) > 1800:
|
||||
shared.alreadyAttemptedConnectionsList.clear()
|
||||
shared.alreadyAttemptedConnectionsListResetTime = int(
|
||||
time.time())
|
||||
shared.alreadyAttemptedConnectionsListLock.acquire()
|
||||
shared.alreadyAttemptedConnectionsList[peer] = 0
|
||||
try:
|
||||
shared.alreadyAttemptedConnectionsListLock.release()
|
||||
except threading.ThreadError as e:
|
||||
pass
|
||||
if self._stopped:
|
||||
break
|
||||
self.name = "outgoingSynSender-" + peer.host.replace(":", ".") # log parser field separator
|
||||
|
|
Loading…
Reference in New Issue
Block a user