Explorar o código

Log the last error from serve

Chris Bannister %!s(int64=12) %!d(string=hai) anos
pai
achega
daffa8a1ff
Modificáronse 1 ficheiros con 8 adicións e 3 borrados
  1. 8 3
      conn.go

+ 8 - 3
conn.go

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