diff --git a/redis.go b/redis.go index 88729c2..0870dad 100644 --- a/redis.go +++ b/redis.go @@ -218,6 +218,7 @@ func (client *Client) sendCommands(cmdArgs <-chan []string, data chan<- interfac var reader *bufio.Reader var pong interface{} var errs chan error + var errsClosed = false if err != nil { goto End @@ -253,23 +254,33 @@ func (client *Client) sendCommands(cmdArgs <-chan []string, data chan<- interfac for cmdArg := range cmdArgs { err = writeRequest(c, cmdArg[0], cmdArg[1:]...) if err != nil { - errs <- err + if !errsClosed { + errs <- err + } break } } - close(errs) + if !errsClosed { + errsClosed = true + close(errs) + } }() go func() { for { response, err := readResponse(reader) if err != nil { - errs <- err + if !errsClosed { + errs <- err + } break } data <- response } - close(errs) + if !errsClosed { + errsClosed = true + close(errs) + } }() // Block until errs channel closes