mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
Stop timers before expiration
If we don't stop them explicitly, the timers will not get garbage collected until they timeout: https://medium.com/@oboturov/golang-time-after-is-not-garbage-collected-4cbc94740082 Related to #40039
This commit is contained in:
parent
7ef49272fa
commit
ef4d0a1da5
1 changed files with 5 additions and 1 deletions
|
@ -147,10 +147,14 @@ func probeHandler(w http.ResponseWriter, r *http.Request) {
|
|||
// advanced to PeerConnectionStateConnected in this time,
|
||||
// destroy the peer connection and return the token.
|
||||
go func() {
|
||||
timer := time.NewTimer(dataChannelTimeout)
|
||||
defer timer.Stop()
|
||||
|
||||
select {
|
||||
case <-dataChan:
|
||||
case <-time.After(dataChannelTimeout):
|
||||
case <-timer.C:
|
||||
}
|
||||
|
||||
if err := pc.Close(); err != nil {
|
||||
log.Printf("Error calling pc.Close: %v", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue