1
0
mirror of https://github.com/redis/go-redis.git synced 2025-08-01 16:06:54 +03:00

Fix connection initialization.

This commit is contained in:
Vladimir Mihailenco
2016-03-15 14:04:35 +02:00
parent 7f594cdbe1
commit 707472c09b
17 changed files with 71 additions and 67 deletions

View File

@ -30,25 +30,23 @@ func (p *StickyConnPool) First() *Conn {
return cn
}
func (p *StickyConnPool) Get() (cn *Conn, isNew bool, err error) {
func (p *StickyConnPool) Get() (*Conn, error) {
defer p.mx.Unlock()
p.mx.Lock()
if p.closed {
err = ErrClosed
return
return nil, ErrClosed
}
if p.cn != nil {
cn = p.cn
return
return p.cn, nil
}
cn, isNew, err = p.pool.Get()
cn, err := p.pool.Get()
if err != nil {
return
return nil, err
}
p.cn = cn
return
return cn, nil
}
func (p *StickyConnPool) put() (err error) {