Browse Source

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 years ago
parent
commit
27ba892354
1 changed files with 5 additions and 7 deletions
  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()