Skip to content

Commit

Permalink
Avoid remove/new/init loop in pool
Browse files Browse the repository at this point in the history
  • Loading branch information
dim committed Apr 23, 2015
1 parent 3cf1488 commit 6313dc0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,16 @@ 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
}

return cn, nil
}

// 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
}
Expand Down

0 comments on commit 6313dc0

Please sign in to comment.