Browse Source

p2p/discv5: add missing Timer.Stop calls (#20853)

ucwong 5 năm trước cách đây
mục cha
commit
c87cdd3053
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  1. 4 0
      p2p/discv5/net.go

+ 4 - 0
p2p/discv5/net.go

@@ -357,6 +357,8 @@ func (net *Network) loop() {
 		bucketRefreshTimer = time.NewTimer(bucketRefreshInterval)
 		refreshDone        chan struct{} // closed when the 'refresh' lookup has ended
 	)
+	defer refreshTimer.Stop()
+	defer bucketRefreshTimer.Stop()
 
 	// Tracking the next ticket to register.
 	var (
@@ -393,11 +395,13 @@ func (net *Network) loop() {
 		searchInfo                = make(map[Topic]topicSearchInfo)
 		activeSearchCount         int
 	)
+	defer topicRegisterLookupTick.Stop()
 	topicSearchLookupDone := make(chan topicSearchResult, 100)
 	topicSearch := make(chan Topic, 100)
 	<-topicRegisterLookupTick.C
 
 	statsDump := time.NewTicker(10 * time.Second)
+	defer statsDump.Stop()
 
 loop:
 	for {