From ec66ab15f2fa20de5b11a5888e57be0d3f2f8e6a Mon Sep 17 00:00:00 2001 From: iyear Date: Thu, 3 Oct 2024 12:38:23 +0800 Subject: [PATCH] fix(dcpool): invalid takeout caused by double lock --- core/dcpool/dcpool.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/dcpool/dcpool.go b/core/dcpool/dcpool.go index e929cea36c..6174112972 100644 --- a/core/dcpool/dcpool.go +++ b/core/dcpool/dcpool.go @@ -48,13 +48,13 @@ func (p *pool) current() int { } func (p *pool) Client(ctx context.Context, dc int) *tg.Client { + p.mu.Lock() + defer p.mu.Unlock() + return tg.NewClient(p.invoker(ctx, dc)) } func (p *pool) invoker(ctx context.Context, dc int) tg.Invoker { - p.mu.Lock() - defer p.mu.Unlock() - if i, ok := p.invokers[dc]; ok { return i }