From 2a09015afff818b5feba1e9bd7712f675c0c6b41 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 4 Jul 2024 18:51:34 +0200 Subject: 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. --- pkg/rpcserver/runner.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pkg/rpcserver') 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 } -- cgit mrf-deployment