Explorar el Código

dont block indefinatly waiting for a stream

Chris Bannister hace 10 años
padre
commit
eab95a919e
Se han modificado 1 ficheros con 6 adiciones y 1 borrados
  1. 6 1
      conn.go

+ 6 - 1
conn.go

@@ -381,7 +381,12 @@ func (c *Conn) handleTimeout() {
 
 func (c *Conn) exec(req frameWriter, tracer Tracer) (frame, error) {
 	// TODO: move tracer onto conn
-	stream := <-c.uniq
+	var stream int
+	select {
+	case stream = <-c.uniq:
+	case <-c.quit:
+		return nil, ErrConnectionClosed
+	}
 
 	call := &c.calls[stream]
 	// resp is basically a waiting semaphore protecting the framer