From 6313dc03a76335ea00b0c6efb52c653bc00a17d4 Mon Sep 17 00:00:00 2001 From: Dimitrij Denissenko Date: Thu, 23 Apr 2015 10:33:59 +0100 Subject: [PATCH] Avoid remove/new/init loop in pool --- pool.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pool.go b/pool.go index b2e2d08..96007fb 100644 --- a/pool.go +++ b/pool.go @@ -178,8 +178,8 @@ func (p *connPool) new() (*conn, error) { return nil, err } - if err := p.init(cn); err != nil { - p.Remove(cn) + if err := p.initConn(cn); err != nil { + cn.Close() return nil, err } @@ -187,7 +187,7 @@ func (p *connPool) new() (*conn, error) { } // Initialize connection -func (p *connPool) init(cn *conn) error { +func (p *connPool) initConn(cn *conn) error { if p.opt.Password == "" && p.opt.DB == 0 { return nil }