[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [chutney/master] Make tor clean up connections before stopping a chutney network



commit 4334644994f32395a2858773b638430d50ff402e
Author: teor <teor2345@xxxxxxxxx>
Date:   Mon Apr 10 13:15:12 2017 +1000

    Make tor clean up connections before stopping a chutney network
    
    This increases integration test coverage, and improves the reliability of
    any statistics being gathered on chutney networks.
    
    Implements feature #21901.
---
 lib/chutney/TorNet.py    | 10 ++++++++++
 tools/test-network.sh    |  2 ++
 torrc_templates/common.i |  3 ++-
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py
index 6e3b77a..e61e425 100644
--- a/lib/chutney/TorNet.py
+++ b/lib/chutney/TorNet.py
@@ -982,17 +982,27 @@ class Network(object):
                 if c.isRunning():
                     c.stop(sig=sig)
             print("Waiting for nodes to finish.")
+            wrote_dot = False
             for n in range(15):
                 time.sleep(1)
                 if all(not c.isRunning() for c in controllers):
+                    # make the output clearer by adding a newline
+                    if wrote_dot:
+                        sys.stdout.write("\n")
+                        sys.stdout.flush()
                     # check for stale lock file when Tor crashes
                     for c in controllers:
                         c.cleanup_lockfile()
                     return
                 sys.stdout.write(".")
+                wrote_dot = True
                 sys.stdout.flush()
             for c in controllers:
                 c.check(listNonRunning=False)
+            # make the output clearer by adding a newline
+            if wrote_dot:
+                sys.stdout.write("\n")
+                sys.stdout.flush()
 
 
 def ConfigureNodes(nodelist):
diff --git a/tools/test-network.sh b/tools/test-network.sh
index 9da20b1..79cce9c 100755
--- a/tools/test-network.sh
+++ b/tools/test-network.sh
@@ -292,6 +292,8 @@ if [ "$CHUTNEY_STOP_TIME" -ge 0 ]; then
   # work around a bug/feature in make -j2 (or more)
   # where make hangs if any child processes are still alive
   "$CHUTNEY" stop "$CHUTNEY_NETWORK"
+  # Give tor time to exit gracefully
+  sleep 3
   "$WARNINGS"
   exit "$VERIFY_EXIT_STATUS"
 else
diff --git a/torrc_templates/common.i b/torrc_templates/common.i
index bca0407..39c76f8 100644
--- a/torrc_templates/common.i
+++ b/torrc_templates/common.i
@@ -36,7 +36,8 @@ DataDirectory $dir
 RunAsDaemon 1
 ConnLimit $connlimit
 Nickname $nick
-ShutdownWaitLength 0
+# Let tor close connections gracefully before exiting
+ShutdownWaitLength 2
 DisableDebuggerAttachment 0
 
 ControlPort $controlport



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits