Explorar o código

conn: fix memory leak when using long timeouts

A timer will only be garbage collected once it has fired, if a call
returns before the timeout is reached then it will not be garbage
collected, leading to potentially many timers on the heap.

fixes #851
Chris Bannister %!s(int64=9) %!d(string=hai) anos
pai
achega
016a613b83
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      conn.go

+ 4 - 0
conn.go

@@ -536,6 +536,10 @@ func (c *Conn) releaseStream(stream int) {
 	delete(c.calls, stream)
 	c.mu.Unlock()
 
+	if call.timer != nil {
+		call.timer.Stop()
+	}
+
 	streamPool.Put(call)
 	c.streams.Clear(stream)
 }