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.
This commit is contained in:
Cecylia Bocovich 2020-12-04 13:41:11 -05:00
parent effc667544
commit 3e8947bfc9

View file

@ -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.")