From 8908c6256113944dcc95fa55dca356e593615cfc Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Thu, 13 Jun 2024 16:45:03 +0200 Subject: [PATCH] Fix goroutine leak --- cmd/soroban-rpc/internal/test/integration.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/soroban-rpc/internal/test/integration.go b/cmd/soroban-rpc/internal/test/integration.go index eec2775b..99d74f3f 100644 --- a/cmd/soroban-rpc/internal/test/integration.go +++ b/cmd/soroban-rpc/internal/test/integration.go @@ -341,8 +341,10 @@ func (i *Test) runComposeCommand(args ...string) { } func (i *Test) prepareShutdownHandlers() { + done := make(chan struct{}) i.shutdownCalls = append(i.shutdownCalls, func() { + close(done) i.StopRPC() if i.historyArchiveProxy != nil { i.historyArchiveProxy.Close() @@ -358,9 +360,12 @@ func (i *Test) prepareShutdownHandlers() { c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, syscall.SIGTERM) go func() { - <-c - i.Shutdown() - os.Exit(int(syscall.SIGTERM)) + select { + case <-c: + i.Shutdown() + os.Exit(int(syscall.SIGTERM)) + case <-done: + } }() }