Skip to content

Commit

Permalink
Fix goroutine leak
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Jun 13, 2024
1 parent c624ce1 commit 8908c62
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmd/soroban-rpc/internal/test/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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:
}
}()
}

Expand Down

0 comments on commit 8908c62

Please sign in to comment.