Add synchronization to prevent post-melt collects

This fixes a race condition in which snowflakes.End() is called while
snowflakes.Collect() is in progress resulting in a write to a closed
channel. We now wait for all in-progress collections to finish and add
an extra check before proceeding with a collection.
This commit is contained in:
Cecylia Bocovich 2020-10-15 14:47:51 -04:00
parent d7aa9b8356
commit 6baa3c4d5f
2 changed files with 13 additions and 3 deletions

View file

@ -181,7 +181,6 @@ func Handler(socks net.Conn, tongue Tongue) error {
// transfer to the Tor SOCKS handler when needed.
func connectLoop(snowflakes SnowflakeCollector) {
for {
// Check if ending is necessary.
_, err := snowflakes.Collect()
if err != nil {
log.Printf("WebRTC: %v Retrying in %v...",