浏览代码

dont cause internal errors to close the connection

If reading a frame from a framer returns an error it is returned
out to recv() which will close the connection and cancel all
inflight requests. Some errors are not fatal for all requests so
only return this erorr out for net errors.
Chris Bannister 10 年之前
父节点
当前提交
2c4f859917
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      conn.go

+ 6 - 4
conn.go

@@ -327,13 +327,15 @@ func (c *Conn) recv() error {
 	call := &c.calls[head.stream]
 	call := &c.calls[head.stream]
 	err = call.framer.readFrame(&head)
 	err = call.framer.readFrame(&head)
 	if err != nil {
 	if err != nil {
-		return err
+		// only net errors should cause the connection to be closed. Though
+		// cassandra returning corrupt frames will be returned here as well.
+		if _, ok := err.(net.Error); ok {
+			return err
+		}
 	}
 	}
 
 
-	// once we get to here we know that the caller must be waiting and that there
-	// is no error.
 	select {
 	select {
-	case call.resp <- nil:
+	case call.resp <- err:
 	default:
 	default:
 		// in case the caller timedout
 		// in case the caller timedout
 	}
 	}