File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package conn
22
33import (
44 "context"
5+ "sync"
56 "sync/atomic"
67 "time"
78
@@ -137,11 +138,26 @@ func (p *Pool) Release(ctx context.Context) error {
137138 }
138139 })
139140
140- var issues []error
141+ var (
142+ errCh = make (chan error , len (conns ))
143+ wg sync.WaitGroup
144+ )
145+
146+ wg .Add (len (conns ))
141147 for _ , c := range conns {
142- if err := c .Close (ctx ); err != nil {
143- issues = append (issues , err )
144- }
148+ go func (c closer.Closer ) {
149+ defer wg .Done ()
150+ if err := c .Close (ctx ); err != nil {
151+ errCh <- err
152+ }
153+ }(c )
154+ }
155+ wg .Wait ()
156+ close (errCh )
157+
158+ issues := make ([]error , 0 , len (conns ))
159+ for err := range errCh {
160+ issues = append (issues , err )
145161 }
146162
147163 if len (issues ) > 0 {
You can’t perform that action at this time.
0 commit comments