Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a548951

Browse files
committed
Fixes #1550
1 parent 7fa9c8e commit a548951

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

lib/core/option.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,24 +1027,26 @@ def _setSocketPreConnect():
10271027
def _():
10281028
while kb.threadContinue:
10291029
try:
1030-
for address in socket._ready:
1031-
if len(socket._ready[address]) < SOCKET_PRE_CONNECT_QUEUE_SIZE:
1032-
s = socket.socket()
1030+
for key in socket._ready:
1031+
if len(socket._ready[key]) < SOCKET_PRE_CONNECT_QUEUE_SIZE:
1032+
family, type, proto, address = key
1033+
s = socket.socket(family, type, proto)
10331034
s._connect(address)
10341035
with kb.locks.socket:
1035-
socket._ready[address].append(s._sock)
1036+
socket._ready[key].append(s._sock)
10361037
except socket.error:
10371038
pass
10381039
finally:
10391040
time.sleep(0.01)
10401041

10411042
def connect(self, address):
10421043
found = False
1044+
key = (self.family, self.type, self.proto, address)
10431045
with kb.locks.socket:
1044-
if address not in socket._ready:
1045-
socket._ready[address] = []
1046-
if len(socket._ready[address]) > 0:
1047-
self._sock = socket._ready[address].pop(0)
1046+
if key not in socket._ready:
1047+
socket._ready[key] = []
1048+
if len(socket._ready[key]) > 0:
1049+
self._sock = socket._ready[key].pop(0)
10481050
found = True
10491051
if not found:
10501052
self._connect(address)

0 commit comments

Comments
 (0)