File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -537,18 +537,28 @@ func (c *Client) Close(ctx context.Context) (err error) {
537537
538538 if atomic .CompareAndSwapUint32 (& c .closed , 0 , 1 ) {
539539 close (c .done )
540+
541+ wg := sync.WaitGroup {}
540542 c .mu .WithLock (func () {
543+ c .limit = 0
544+
541545 for el := c .waitq .Front (); el != nil ; el = el .Next () {
542546 ch := el .Value .(* chan * session )
543547 close (* ch )
544548 }
545549
546550 for e := c .idle .Front (); e != nil ; e = e .Next () {
547- c .internalPoolAsyncCloseSession (ctx , e .Value .(* session ))
551+ wg .Add (1 )
552+ s := e .Value .(* session )
553+ s .SetStatus (options .SessionClosing )
554+ go func () {
555+ defer wg .Done ()
556+ c .internalPoolSyncCloseSession (ctx , s )
557+ }()
548558 }
549-
550- c .limit = 0
551559 })
560+ wg .Wait ()
561+
552562 c .spawnedGoroutines .Wait ()
553563 }
554564
You can’t perform that action at this time.
0 commit comments