Skip to content

Commit

Permalink
fix pool item close
Browse files Browse the repository at this point in the history
  • Loading branch information
4el0ve4ek committed Nov 14, 2024
1 parent e8897e9 commit 211365a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Fixed connections pool leak on closing

## v3.92.2
* Added `table/options.WithShardNodesInfo()` experimental option to get shard nodeId for describe table call

Expand Down
14 changes: 7 additions & 7 deletions internal/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,15 @@ func makeAsyncCloseItemFunc[PT ItemConstraint[T], T any](
p *Pool[PT, T],
) func(ctx context.Context, item PT) {
return func(ctx context.Context, item PT) {
closeItemCtx, closeItemCancel := xcontext.WithDone(xcontext.ValueOnly(ctx), p.done)
defer closeItemCancel()

if d := p.config.closeTimeout; d > 0 {
closeItemCtx, closeItemCancel = xcontext.WithTimeout(ctx, d)
go func() {
closeItemCtx, closeItemCancel := xcontext.WithDone(xcontext.ValueOnly(ctx), p.done)
defer closeItemCancel()
}

go func() {
if d := p.config.closeTimeout; d > 0 {
closeItemCtx, closeItemCancel = xcontext.WithTimeout(ctx, d)
defer closeItemCancel()
}

_ = item.Close(closeItemCtx)
}()
}
Expand Down

0 comments on commit 211365a

Please sign in to comment.