From cc47faab56325a022ff59cd7277abbf99ff4f8ff Mon Sep 17 00:00:00 2001 From: Or Shachar Date: Sat, 25 Nov 2023 16:26:32 +0200 Subject: [PATCH] fix: call wg.Close() in defer func (#9) --- cacheproc/cacheproc.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cacheproc/cacheproc.go b/cacheproc/cacheproc.go index 6c90735..b1b9d83 100644 --- a/cacheproc/cacheproc.go +++ b/cacheproc/cacheproc.go @@ -69,6 +69,7 @@ func (p *Process) Run(ctx context.Context) error { } defer func() { _ = p.close() + _ = wg.Wait() }() for { var req wire.Request @@ -102,11 +103,6 @@ func (p *Process) Run(ctx context.Context) error { _ = bw.Flush() return nil }) - select { - case <-ctx.Done(): - return wg.Wait() - default: - } } }