ソースを参照

dont block indefinatly waiting for a stream

Chris Bannister 10 年 前
コミット
eab95a919e
1 ファイル変更6 行追加1 行削除
  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) {
 func (c *Conn) exec(req frameWriter, tracer Tracer) (frame, error) {
 	// TODO: move tracer onto conn
 	// 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]
 	call := &c.calls[stream]
 	// resp is basically a waiting semaphore protecting the framer
 	// resp is basically a waiting semaphore protecting the framer