pool: Close inner pools during close routine #169

Merged
alexvanin merged 1 commit from alexvanin/frostfs-sdk-go:fix/pool-close into master 2023-09-20 10:19:44 +00:00
2 changed files with 20 additions and 0 deletions

View file

@ -189,3 +189,7 @@ func (m *mockClient) restartIfUnhealthy(ctx context.Context) (healthy bool, chan
}
return
}
func (m *mockClient) close() error {
return nil
}

View file

@ -78,6 +78,8 @@ type client interface {
dial(ctx context.Context) error
// see clientWrapper.restartIfUnhealthy.
restartIfUnhealthy(ctx context.Context) (bool, bool)
// see clientWrapper.close.
close() error
}
// clientStatus provide access to some metrics for connection.
@ -1080,6 +1082,13 @@ func (c *clientWrapper) incRequests(elapsed time.Duration, method MethodIndex) {
}
}
func (c *clientWrapper) close() error {
if c.client != nil {
return c.client.Close()
}
return nil
}
func (c *clientStatusMonitor) handleError(ctx context.Context, st apistatus.Status, err error) error {
if err != nil {
if needCountError(ctx, err) {
@ -2766,6 +2775,13 @@ func (p *Pool) NetworkInfo(ctx context.Context) (netmap.NetworkInfo, error) {
func (p *Pool) Close() {
p.cancel()
<-p.closedCh
// close all clients
for _, pools := range p.innerPools {
for _, cli := range pools.clients {
_ = cli.close()
}
}
}
// SyncContainerWithNetwork applies network configuration received via