mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
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:
parent
effc667544
commit
3e8947bfc9
1 changed files with 3 additions and 3 deletions
|
@ -136,13 +136,13 @@ func Handler(socks net.Conn, tongue Tongue) error {
|
||||||
// transfer to the Tor SOCKS handler when needed.
|
// transfer to the Tor SOCKS handler when needed.
|
||||||
func connectLoop(snowflakes SnowflakeCollector) {
|
func connectLoop(snowflakes SnowflakeCollector) {
|
||||||
for {
|
for {
|
||||||
|
timer := time.After(ReconnectTimeout)
|
||||||
_, err := snowflakes.Collect()
|
_, err := snowflakes.Collect()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("WebRTC: %v Retrying in %v...",
|
log.Printf("WebRTC: %v Retrying...", err)
|
||||||
err, ReconnectTimeout)
|
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case <-time.After(ReconnectTimeout):
|
case <-timer:
|
||||||
continue
|
continue
|
||||||
case <-snowflakes.Melted():
|
case <-snowflakes.Melted():
|
||||||
log.Println("ConnectLoop: stopped.")
|
log.Println("ConnectLoop: stopped.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue