diff --git a/context.go b/context.go index 427a1617..38ff41de 100644 --- a/context.go +++ b/context.go @@ -827,9 +827,13 @@ func (c *callCmd) done() { c.sess.graceCallCmdWaitGroup.Done() } -func (c *callCmd) cancel() { +func (c *callCmd) cancel(reason string) { c.sess.callCmdMap.Delete(c.output.Seq()) - c.rerr = rerrConnClosed + if reason != "" { + c.rerr = rerrConnClosed.Copy().SetReason(reason) + } else { + c.rerr = rerrConnClosed + } c.callCmdChan <- c close(c.doneChan) // free count call-launch diff --git a/session.go b/session.go index 30b428ca..efd540d7 100644 --- a/session.go +++ b/session.go @@ -693,8 +693,10 @@ func (s *session) readDisconnected(oldConn net.Conn, err error) { s.peer.sessHub.Delete(s.ID()) + var reason string if err != nil && err != socket.ErrProactivelyCloseSocket { if errStr := err.Error(); errStr != "EOF" { + reason = errStr Debugf("disconnect(%s) when reading: %T %s", s.RemoteAddr().String(), err, errStr) } } @@ -705,7 +707,7 @@ func (s *session) readDisconnected(oldConn net.Conn, err error) { callCmd := v.(*callCmd) callCmd.mu.Lock() if !callCmd.hasReply() && callCmd.rerr == nil { - callCmd.cancel() + callCmd.cancel(reason) } callCmd.mu.Unlock() return true