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

[tor-commits] [onionperf/master] Tweak --drop-guards switch.



commit 9d76ca4b3847a10c9565d12cf130933a1076297b
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Tue Sep 1 17:02:47 2020 +0200

    Tweak --drop-guards switch.
    
    This commit tweaks the recently added --drop-guards switch as follows:
    
     - Guards are dropped right at startup and then every N hours.
       Otherwise we might not receive the first round of GUARD NEW/UP
       events. It's unclear why we don't receive those events, but finding
       out might be time-consuming whereas dropping guards at startup is
       basically free.
    
     - Right after guards are dropped, circuit build timeouts are dropped,
       too, if supported by the Tor version. If the Tor version does not
       support this, there's going to be a warning, and the control log
       will simply not contain BUILDTIMEOUT_SET events.
    
    Still part of the reopened tpo/metrics/onionperf#33399.
---
 CHANGELOG.md         |  3 ++-
 onionperf/monitor.py | 12 +++++++-----
 onionperf/onionperf  |  2 +-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index a212842..e0253c5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,8 @@
 # Changes in version 0.7 - 2020-??-??
 
  - Add `onionperf measure --drop-guards` parameter to use and drop
-   guards after a given number of hours. Implements #33399.
+   guards and circuit build timeouts every given number of hours, if
+   supported by the Tor version. Implements #33399.
  - Remove the `onionperf measure --oneshot` switch and replace it with
    new switches `--tgen-pause-initial`, `--tgen-pause-between`,
    `--tgen-transfer-size`, and `--tgen-num-transfers ` to further
diff --git a/onionperf/monitor.py b/onionperf/monitor.py
index b5e6390..886a9a0 100644
--- a/onionperf/monitor.py
+++ b/onionperf/monitor.py
@@ -57,21 +57,23 @@ class TorMonitor(object):
                 interval_count = 0
                 if newnym_interval_seconds is not None:
                     next_newnym = newnym_interval_seconds
-                if drop_guards_interval_hours > 0:
-                    next_drop_guards = drop_guards_interval_hours * 3600
+                next_drop_guards = 0
                 while done_ev is None or not done_ev.is_set():
                     # if self.filepath != '-' and os.path.exists(self.filepath):
                     #    with open(self.filepath, 'rb') as sizef:
                     #        msg = "tor-ctl-logger[port={0}] logged {1} bytes to {2}, press CTRL-C to quit".format(self.tor_ctl_port, os.fstat(sizef.fileno()).st_size, self.filepath)
                     #        logging.info(msg)
+                    if drop_guards_interval_hours > 0 and interval_count >= next_drop_guards:
+                        next_drop_guards += drop_guards_interval_hours * 3600
+                        torctl.drop_guards()
+                        drop_timeouts_response = torctl.msg("DROPTIMEOUTS")
+                        if not drop_timeouts_response.is_ok():
+                            self.__log(self.writable, "[WARNING] unrecognized command DROPTIMEOUTS in tor\n")
                     sleep(1)
                     interval_count += 1
                     if newnym_interval_seconds is not None and interval_count >= next_newnym:
                         next_newnym += newnym_interval_seconds
                         torctl.signal(Signal.NEWNYM)
-                    if drop_guards_interval_hours > 0 and interval_count >= next_drop_guards:
-                        next_drop_guards += drop_guards_interval_hours * 3600
-                        torctl.drop_guards()
 
             except KeyboardInterrupt:
                 pass  # the user hit ctrl+c
diff --git a/onionperf/onionperf b/onionperf/onionperf
index e6aa44a..d3d8e31 100755
--- a/onionperf/onionperf
+++ b/onionperf/onionperf
@@ -215,7 +215,7 @@ def main():
         default=0)
 
     measure_parser.add_argument('--drop-guards',
-        help="""Use and drop guards every N > 0 hours, or do not use guards at all if N = 0""",
+        help="""Use and drop guards and circuit build timeouts every N > 0 hours, or do not use guards at all and never drop circuit build timeouts if N = 0""",
         metavar="N", type=type_nonnegative_integer,
         action="store", dest="drop_guards_interval_hours",
         default=0)



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