From 27376e9863a070bc8e0b9db86d680d05a6b3ccf4 Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Wed, 29 Jan 2025 13:27:07 -0800 Subject: [PATCH] Cleanup retrySendTimeout --- pkg/wshutil/wshrpc.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/wshutil/wshrpc.go b/pkg/wshutil/wshrpc.go index a1ea1f71ae..5ab52ad90f 100644 --- a/pkg/wshutil/wshrpc.go +++ b/pkg/wshutil/wshrpc.go @@ -732,21 +732,21 @@ func (w *WshRpc) setServerDone() { } func (w *WshRpc) retrySendTimeout(resId string) { + done := func() bool { + w.Lock.Lock() + defer w.Lock.Unlock() + if w.ServerDone { + return true + } + select { + case w.CtxDoneCh <- resId: + return true + default: + return false + } + } for { - done := func() bool { - w.Lock.Lock() - defer w.Lock.Unlock() - if w.ServerDone { - return true - } - select { - case w.CtxDoneCh <- resId: - return true - default: - return false - } - }() - if done { + if done() { return } time.Sleep(100 * time.Millisecond)