瀏覽代碼

conn: closeWithError shoudl always try to deliver

Remove the redundant err != nil check inside the loop and
use call.timeout to check if the caller has gone away.

This fixes the root cause issue of Stream0 test flakes
Chris Bannister 10 年之前
父節點
當前提交
27ba892354
共有 1 個文件被更改,包括 5 次插入7 次删除
  1. 5 7
      conn.go

+ 5 - 7
conn.go

@@ -328,18 +328,16 @@ func (c *Conn) closeWithError(err error) {
 		return
 	}
 
+	// we should attempt to deliver the error back to the caller if it
+	// exists
 	if err != nil {
-		// we should attempt to deliver the error back to the caller if it
-		// exists
 		c.mu.RLock()
 		for _, req := range c.calls {
 			// we need to send the error to all waiting queries, put the state
 			// of this conn into not active so that it can not execute any queries.
-			if err != nil {
-				select {
-				case req.resp <- err:
-				default:
-				}
+			select {
+			case req.resp <- err:
+			case <-req.timeout:
 			}
 		}
 		c.mu.RUnlock()