fix(proxy): race condition warning for isClosing

It appears that there is no need for the `isClosing` var at all:
we can just `close(c.sendMoreCh)` to ensure that it doesn't block
any more `Write()`s.

This is a follow-up to
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/merge_requests/144.
Related:
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/merge_requests/524.
This commit is contained in:
WofWca 2025-03-03 17:59:22 +04:00 committed by Cecylia Bocovich
parent 1aa5a61fe8
commit 01819eee32
No known key found for this signature in database
GPG key ID: 009DE379FD9B7B90
2 changed files with 5 additions and 9 deletions

View file

@ -485,6 +485,10 @@ func (sf *SnowflakeProxy) makePeerConnectionFromOffer(
}
})
dc.OnClose(func() {
// Make sure that the `Write()`s are not blocked any more.
dc.OnBufferedAmountLow(func() {})
close(conn.sendMoreCh)
conn.lock.Lock()
defer conn.lock.Unlock()
log.Printf("Data Channel %s-%d close\n", dc.Label(), dc.ID())