소스 검색

conn: release the stream when recieving an error

When exec recvieves an error from recv via call.resp it should release
the stream if it is done with it, but only if the connection was not
closed due to the error. This is to avoid potential issues if a response
comes back on a stream.
Chris Bannister 10 년 전
부모
커밋
3233d7ba31
1개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  1. 7 0
      conn.go

+ 7 - 0
conn.go

@@ -468,6 +468,13 @@ func (c *Conn) exec(req frameWriter, tracer Tracer) (frame, error) {
 	select {
 	case err := <-call.resp:
 		if err != nil {
+			if !c.Closed() {
+				// if the connection is closed then we cant release the stream,
+				// this is because the request is still outstanding and we have
+				// been handed another error from another stream which caused the
+				// connection to close.
+				c.releaseStream(stream)
+			}
 			return nil, err
 		}
 	case <-time.After(c.timeout):