From a8dd0b7f294a2664d53f39ce75c5154fd6cb435e Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Thu, 30 Jan 2025 17:33:18 -0800 Subject: [PATCH] Cleanup retrySendTimeout func creation (#1872) --- 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 37bb48888..400d0070c 100644 --- a/pkg/wshutil/wshrpc.go +++ b/pkg/wshutil/wshrpc.go @@ -736,21 +736,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)