瀏覽代碼

Merge pull request #79 from Zariel/propogate-recv-error

Log the last error from serve
Ben Hood 11 年之前
父節點
當前提交
22d37847b4
共有 1 個文件被更改,包括 8 次插入3 次删除
  1. 8 3
      conn.go

+ 8 - 3
conn.go

@@ -184,8 +184,13 @@ func (c *Conn) startup(cfg *ConnConfig) error {
 // to execute any queries. This method runs as long as the connection is
 // open and is therefore usually called in a separate goroutine.
 func (c *Conn) serve() {
+	var (
+		err  error
+		resp frame
+	)
+
 	for {
-		resp, err := c.recv()
+		resp, err = c.recv()
 		if err != nil {
 			break
 		}
@@ -196,10 +201,10 @@ func (c *Conn) serve() {
 	for id := 0; id < len(c.calls); id++ {
 		req := &c.calls[id]
 		if atomic.LoadInt32(&req.active) == 1 {
-			req.resp <- callResp{nil, ErrProtocol}
+			req.resp <- callResp{nil, err}
 		}
 	}
-	c.cluster.HandleError(c, ErrProtocol, true)
+	c.cluster.HandleError(c, err, true)
 }
 
 func (c *Conn) recv() (frame, error) {