1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Add ParseReq method and tweak benchmarks.

This commit is contained in:
Vladimir Mihailenco
2012-08-24 15:16:12 +03:00
parent f56748aab9
commit b6ae953e1c
5 changed files with 119 additions and 21 deletions

View File

@ -79,6 +79,9 @@ func (c *BaseClient) conn() (*Conn, error) {
}
err = c.InitConn(client)
if err != nil {
if err := c.ConnPool.Remove(conn); err != nil {
panic(err)
}
return nil, err
}
}
@ -102,7 +105,9 @@ func (c *BaseClient) Run(req Req) {
err = c.WriteReq(conn, req)
if err != nil {
c.ConnPool.Remove(conn)
if err := c.ConnPool.Remove(conn); err != nil {
panic(err)
}
req.SetErr(err)
return
}
@ -110,15 +115,21 @@ func (c *BaseClient) Run(req Req) {
val, err := req.ParseReply(conn.Rd)
if err != nil {
if err == Nil {
c.ConnPool.Add(conn)
if err := c.ConnPool.Add(conn); err != nil {
panic(err)
}
} else {
c.ConnPool.Remove(conn)
if err := c.ConnPool.Remove(conn); err != nil {
panic(err)
}
}
req.SetErr(err)
return
}
c.ConnPool.Add(conn)
if err := c.ConnPool.Add(conn); err != nil {
panic(err)
}
req.SetVal(val)
}