@@ -54,8 +54,7 @@ type Pooler interface {
5454}
5555
5656type Options struct {
57- Dialer func (context.Context ) (net.Conn , error )
58- OnClose func (* Conn ) error
57+ Dialer func (context.Context ) (net.Conn , error )
5958
6059 PoolFIFO bool
6160 PoolSize int
@@ -87,8 +86,7 @@ type ConnPool struct {
8786
8887 stats Stats
8988
90- _closed uint32 // atomic
91- closedCh chan struct {}
89+ _closed uint32 // atomic
9290}
9391
9492var _ Pooler = (* ConnPool )(nil )
@@ -100,7 +98,6 @@ func NewConnPool(opt *Options) *ConnPool {
10098 queue : make (chan struct {}, opt .PoolSize ),
10199 conns : make ([]* Conn , 0 , opt .PoolSize ),
102100 idleConns : make ([]* Conn , 0 , opt .PoolSize ),
103- closedCh : make (chan struct {}),
104101 }
105102
106103 p .connsMu .Lock ()
@@ -376,7 +373,7 @@ func (p *ConnPool) Put(ctx context.Context, cn *Conn) {
376373 }
377374}
378375
379- func (p * ConnPool ) Remove (ctx context.Context , cn * Conn , reason error ) {
376+ func (p * ConnPool ) Remove (_ context.Context , cn * Conn , reason error ) {
380377 p .removeConnWithLock (cn )
381378 p .freeTurn ()
382379 _ = p .closeConn (cn )
@@ -407,9 +404,6 @@ func (p *ConnPool) removeConn(cn *Conn) {
407404}
408405
409406func (p * ConnPool ) closeConn (cn * Conn ) error {
410- if p .cfg .OnClose != nil {
411- _ = p .cfg .OnClose (cn )
412- }
413407 return cn .Close ()
414408}
415409
@@ -464,7 +458,6 @@ func (p *ConnPool) Close() error {
464458 if ! atomic .CompareAndSwapUint32 (& p ._closed , 0 , 1 ) {
465459 return ErrClosed
466460 }
467- close (p .closedCh )
468461
469462 var firstErr error
470463 p .connsMu .Lock ()
@@ -489,7 +482,6 @@ func (p *ConnPool) isHealthyConn(cn *Conn) bool {
489482 return false
490483 }
491484 if p .cfg .ConnMaxIdleTime > 0 && now .Sub (cn .UsedAt ()) >= p .cfg .ConnMaxIdleTime {
492- atomic .AddUint32 (& p .stats .IdleConns , 1 )
493485 return false
494486 }
495487
0 commit comments