diff options
author | Cecylia Bocovich <cohosh@torproject.org> | 2020-12-04 13:41:11 -0500 |
---|---|---|
committer | Cecylia Bocovich <cohosh@torproject.org> | 2020-12-05 15:51:42 -0500 |
commit | 3e8947bfc9af1b299bc202d0252245c03ba20f11 (patch) | |
tree | bccf738381feba4fa2b524149c97558e0d8eef1c | |
parent | effc6675448a3a6e62d2784557d67e2c46e376d5 (diff) | |
download | snowflake-3e8947bfc9af1b299bc202d0252245c03ba20f11.tar.gz snowflake-3e8947bfc9af1b299bc202d0252245c03ba20f11.zip |
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.
-rw-r--r-- | client/lib/snowflake.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/client/lib/snowflake.go b/client/lib/snowflake.go index 171e173..10a2c0d 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.") |