Skip to content

Commit

Permalink
Allow customisable timeouts on plugins that support them
Browse files Browse the repository at this point in the history
  • Loading branch information
irl committed Oct 18, 2016
1 parent ed181a9 commit 7ff9889
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pathspider/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def __init__(self, worker_count, libtrace_uri, args):
self.lock = threading.Lock()
self.exception = None

self.conn_timeout = 0
self.conn_timeout = None

def config_zero(self):
"""
Expand Down Expand Up @@ -629,7 +629,7 @@ def tcp_connect(self, job):
"""

if self.conn_timeout is None:
self.conn_timeout = 3
raise RuntimeError("Plugin did not set TCP connect timeout.")

tstart = str(datetime.utcnow())

Expand Down
4 changes: 2 additions & 2 deletions pathspider/plugins/ecn.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ def __init__(self, worker_count, libtrace_uri, args):
super().__init__(worker_count=worker_count,
libtrace_uri=libtrace_uri,
args=args)
self.tos = None # set by configurator
self.conn_timeout = 10
self.conn_timeout = args.timeout
self.comparetab = {}

def config_zero(self):
Expand Down Expand Up @@ -228,4 +227,5 @@ def merge(self, flow, res):
@staticmethod
def register_args(subparsers):
parser = subparsers.add_parser('ecn', help="Explicit Congestion Notification")
parser.add_argument("--timeout", default=5, type=int, help="The timeout to use for attempted connections in seconds (Default: 5)")
parser.set_defaults(spider=ECN)
4 changes: 2 additions & 2 deletions pathspider/plugins/tfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ def __init__(self, worker_count, libtrace_uri, args):
super().__init__(worker_count=worker_count,
libtrace_uri=libtrace_uri,
args=args)
self.tos = None # set by configurator
self.conn_timeout = 10
self.conn_timeout = args.timeout

def connect(self, job, pcs, config):
# determine ip version
Expand Down Expand Up @@ -288,5 +287,6 @@ def merge(self, flow, res):
@staticmethod
def register_args(subparsers):
parser = subparsers.add_parser('tfo', help="TCP Fast Open")
parser.add_argument("--timeout", default=5, type=int, help="The timeout to use for attempted connections in seconds (Default: 5)")
parser.set_defaults(spider=TFO)

0 comments on commit 7ff9889

Please sign in to comment.