forked from p15670423/monkey
Oppertunistic wait
This commit is contained in:
parent
7fc25adf47
commit
7a523bdd75
|
@ -117,6 +117,13 @@ def check_tcp_ports(ip, ports, timeout=DEFAULT_TIMEOUT, get_banner=False):
|
||||||
good_ports.append((port, sock))
|
good_ports.append((port, sock))
|
||||||
|
|
||||||
if len(good_ports) != 0:
|
if len(good_ports) != 0:
|
||||||
|
read_sockets, write_sockets, _ = \
|
||||||
|
select.select(
|
||||||
|
[s[1] for s in good_ports],
|
||||||
|
[s[1] for s in good_ports],
|
||||||
|
[s[1] for s in good_ports],
|
||||||
|
timeout) # wait max timeout
|
||||||
|
if len(write_sockets) != len(good_ports):
|
||||||
time.sleep(timeout)
|
time.sleep(timeout)
|
||||||
read_sockets, write_sockets, _ = \
|
read_sockets, write_sockets, _ = \
|
||||||
select.select(
|
select.select(
|
||||||
|
@ -124,6 +131,7 @@ def check_tcp_ports(ip, ports, timeout=DEFAULT_TIMEOUT, get_banner=False):
|
||||||
[s[1] for s in good_ports],
|
[s[1] for s in good_ports],
|
||||||
[s[1] for s in good_ports],
|
[s[1] for s in good_ports],
|
||||||
0) # no timeout because we've already slept
|
0) # no timeout because we've already slept
|
||||||
|
|
||||||
connected_ports_sockets = [x for x in good_ports if x[1] in write_sockets]
|
connected_ports_sockets = [x for x in good_ports if x[1] in write_sockets]
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"On host %s discovered the following ports %s" %
|
"On host %s discovered the following ports %s" %
|
||||||
|
|
Loading…
Reference in New Issue