commit ef4d0a1da56e15327173923fa14a28d9ca40789c
Author: David Fifield <da...@bamsoftware.com>
Date:   Wed May 19 13:03:23 2021 +0200

    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
---
 probetest/probetest.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/probetest/probetest.go b/probetest/probetest.go
index f9bc96b..4158fa5 100644
--- a/probetest/probetest.go
+++ b/probetest/probetest.go
@@ -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)
                }

_______________________________________________
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to