aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCecylia Bocovich <cohosh@torproject.org>2020-12-04 13:41:11 -0500
committerCecylia Bocovich <cohosh@torproject.org>2020-12-05 15:51:42 -0500
commit3e8947bfc9af1b299bc202d0252245c03ba20f11 (patch)
treebccf738381feba4fa2b524149c97558e0d8eef1c
parenteffc6675448a3a6e62d2784557d67e2c46e376d5 (diff)
downloadsnowflake-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.go6
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.")