Skip to content

Commit

Permalink
Merge pull request hoisie#19 from eaigner/master
Browse files Browse the repository at this point in the history
Fixed hoisie#18
  • Loading branch information
hoisie committed Jun 26, 2013
2 parents c044ea7 + 01d27cc commit 96b5da6
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 96b5da6

Please sign in to comment.