소스 검색

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 9 년 전
부모
커밋
016a613b83
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  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)
 }