mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Fix datarace for Peers.melted
Using the boolean value was unnecessary since we already have a channel we can check for closure.
This commit is contained in:
parent
ddcdfc4f09
commit
bb7ff6180b
1 changed files with 4 additions and 4 deletions
|
@ -27,7 +27,6 @@ type Peers struct {
|
|||
activePeers *list.List
|
||||
|
||||
melt chan struct{}
|
||||
melted bool
|
||||
|
||||
collection sync.WaitGroup
|
||||
}
|
||||
|
@ -51,8 +50,10 @@ func (p *Peers) Collect() (*WebRTCPeer, error) {
|
|||
// Engage the Snowflake Catching interface, which must be available.
|
||||
p.collection.Add(1)
|
||||
defer p.collection.Done()
|
||||
if p.melted {
|
||||
select {
|
||||
case <-p.melt:
|
||||
return nil, fmt.Errorf("Snowflakes have melted")
|
||||
default:
|
||||
}
|
||||
if nil == p.Tongue {
|
||||
return nil, errors.New("missing Tongue to catch Snowflakes with")
|
||||
|
@ -120,7 +121,6 @@ func (p *Peers) purgeClosedPeers() {
|
|||
// Close all Peers contained here.
|
||||
func (p *Peers) End() {
|
||||
close(p.melt)
|
||||
p.melted = true
|
||||
p.collection.Wait()
|
||||
close(p.snowflakeChan)
|
||||
cnt := p.Count()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue