summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2018-10-06 16:05:04 -0500
committerNick Mathewson <nickm@torproject.org>2018-11-02 13:14:23 -0400
commit8f43b8fb477e0fe538336fd0e1cb772d1686fb47 (patch)
tree2b0dcfd6741ebc2865402de72d08f2707c40f410 /src/test
parent43211c3a0c4b56d4100daf3a541250b953fb7230 (diff)
downloadtor-8f43b8fb477e0fe538336fd0e1cb772d1686fb47.tar.gz
tor-8f43b8fb477e0fe538336fd0e1cb772d1686fb47.zip
Avoid a race condition in test_rebind.py
If tor terminates due to SIGNAL HALT before test_rebind.py calls tor_process.terminate(), an OSError 3 (no such process) is thrown. Fixes part of bug 27968 on 0.3.5.1-alpha.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_rebind.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/test/test_rebind.py b/src/test/test_rebind.py
index 7ba3a5796d..13e4446cec 100644
--- a/src/test/test_rebind.py
+++ b/src/test/test_rebind.py
@@ -6,6 +6,7 @@ import socket
import os
import time
import random
+import errno
def try_connecting_to_socksport():
socks_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -88,6 +89,14 @@ try_connecting_to_socksport()
control_socket.sendall('SIGNAL HALT\r\n'.encode('utf8'))
-time.sleep(0.1)
+wait_for_log('exiting cleanly')
print('OK')
-tor_process.terminate()
+
+try:
+ tor_process.terminate()
+except OSError as e:
+ if e.errno == errno.ESRCH: # errno 3: No such process
+ # assume tor has already exited due to SIGNAL HALT
+ print("Tor has already exited")
+ else:
+ raise