From be2b086cc44bbee86a82d14f68f7d05a2b0b1491 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sat, 15 Apr 2017 11:43:19 -0700 Subject: [PATCH] Make sure tor process is killed in a more robust manner, and also increase tor connection timeout to 45 seconds --- onionshare/onion.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/onionshare/onion.py b/onionshare/onion.py index d0908cb3..07c516b2 100644 --- a/onionshare/onion.py +++ b/onionshare/onion.py @@ -136,7 +136,7 @@ class Onion(object): (self.tor_path, self.tor_geo_ip_file_path, self.tor_geo_ipv6_file_path) = helpers.get_tor_paths() # The tor process - self.tor_p = None + self.tor_proc = None # Try to connect to Tor self.c = None @@ -215,8 +215,8 @@ class Onion(object): break time.sleep(0.2) - # Timeout after 30 seconds - if time.time() - start_ts > 30: + # Timeout after 45 seconds + if time.time() - start_ts > 45: print("") self.tor_proc.terminate() raise BundledTorTimeout(strings._('settings_error_bundled_tor_timeout')) @@ -387,6 +387,9 @@ class Onion(object): # Stop tor process if self.tor_proc: self.tor_proc.terminate() + time.sleep(0.2) + if not self.tor_proc.poll(): + self.tor_proc.kill() self.tor_proc = None def _get_available_port(self):