Skip to content

Commit

Permalink
pkg/rpcserver: stop the loop on shutdown
Browse files Browse the repository at this point in the history
There's no sense in continuing the operation once the Runner has been
stopped.

If no new requests are coming, the loop goroutine may last a long time
since it never actually interacts with the (possibly already closed)
socket.
  • Loading branch information
a-nogikh authored and dvyukov committed Jul 8, 2024
1 parent 5a70055 commit 2a09015
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/rpcserver/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ func (runner *Runner) ConnectionLoop() error {
}
}
if len(runner.requests) == 0 {
// The runner has not requests at all, so don't wait to receive anything from it.
if !runner.Alive() {
return nil
}
// The runner has no new requests, so don't wait to receive anything from it.
time.Sleep(10 * time.Millisecond)
continue
}
Expand Down

0 comments on commit 2a09015

Please sign in to comment.