1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

Fix waiting reply on empty queue.

This commit is contained in:
Vladimir Mihailenco
2012-07-29 12:51:29 +03:00
parent 41137c2e6f
commit 9d06871d6e
2 changed files with 20 additions and 0 deletions

View File

@ -131,6 +131,10 @@ func (c *Client) Run(req Req) {
}
func (c *Client) RunQueued() ([]Req, error) {
if len(c.reqs) == 0 {
return c.reqs, nil
}
c.mtx.Lock()
reqs := c.reqs
c.reqs = make([]Req, 0)
@ -177,6 +181,10 @@ func (c *Client) Discard() {
}
func (c *Client) Exec() ([]Req, error) {
if len(c.reqs) == 0 {
return c.reqs, nil
}
c.mtx.Lock()
reqs := c.reqs
c.reqs = make([]Req, 0)