From 3e8947bfc9af1b299bc202d0252245c03ba20f11 Mon Sep 17 00:00:00 2001 From: Cecylia Bocovich <cohosh@torproject.org> Date: Fri, 4 Dec 2020 13:41:11 -0500 Subject: [PATCH] Avoid double delay in client from ReconnectTimeout Run the snowflake collection ReconnectTimeout timer in parallel to the negotiation with the broker. This way, if the broker takes a long time to respond the client doesn't have to wait the full timeout to respond. --- client/lib/snowflake.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/lib/snowflake.go b/client/lib/snowflake.go index 171e173f..10a2c0df 100644 --- a/client/lib/snowflake.go +++ b/client/lib/snowflake.go @@ -136,13 +136,13 @@ func Handler(socks net.Conn, tongue Tongue) error { // transfer to the Tor SOCKS handler when needed. func connectLoop(snowflakes SnowflakeCollector) { for { + timer := time.After(ReconnectTimeout) _, err := snowflakes.Collect() if err != nil { - log.Printf("WebRTC: %v Retrying in %v...", - err, ReconnectTimeout) + log.Printf("WebRTC: %v Retrying...", err) } select { - case <-time.After(ReconnectTimeout): + case <-timer: continue case <-snowflakes.Melted(): log.Println("ConnectLoop: stopped.") -- GitLab