aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/rpcserver
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-07-04 18:51:34 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-07-08 07:01:24 +0000
commit2a09015afff818b5feba1e9bd7712f675c0c6b41 (patch)
tree85d03aa2d086d0166b3ec36f4b8221cdd0eca34b /pkg/rpcserver
parent5a7005591465dd7ea34834918299fac3bfe508f6 (diff)
pkg/rpcserver: stop the loop on shutdown
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.
Diffstat (limited to 'pkg/rpcserver')
-rw-r--r--pkg/rpcserver/runner.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/pkg/rpcserver/runner.go b/pkg/rpcserver/runner.go
index ea45aa89a..06fa6a581 100644
--- a/pkg/rpcserver/runner.go
+++ b/pkg/rpcserver/runner.go
@@ -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
}