Skip to content

Commit a8dd0b7

Browse files
authored
Cleanup retrySendTimeout func creation (#1872)
1 parent 5db84e5 commit a8dd0b7

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

pkg/wshutil/wshrpc.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -736,21 +736,21 @@ func (w *WshRpc) setServerDone() {
736736
}
737737

738738
func (w *WshRpc) retrySendTimeout(resId string) {
739+
done := func() bool {
740+
w.Lock.Lock()
741+
defer w.Lock.Unlock()
742+
if w.ServerDone {
743+
return true
744+
}
745+
select {
746+
case w.CtxDoneCh <- resId:
747+
return true
748+
default:
749+
return false
750+
}
751+
}
739752
for {
740-
done := func() bool {
741-
w.Lock.Lock()
742-
defer w.Lock.Unlock()
743-
if w.ServerDone {
744-
return true
745-
}
746-
select {
747-
case w.CtxDoneCh <- resId:
748-
return true
749-
default:
750-
return false
751-
}
752-
}()
753-
if done {
753+
if done() {
754754
return
755755
}
756756
time.Sleep(100 * time.Millisecond)

0 commit comments

Comments
 (0)