Skip to content

Commit

Permalink
Merge pull request #141 from Didrole/context-leak-fix
Browse files Browse the repository at this point in the history
Use the host tg's stop context instead of using the OnStop callback.
  • Loading branch information
lukechampine authored Jul 7, 2022
2 parents 7208954 + 30019f6 commit 9c71482
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions modules/host/rpcexecuteprogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (h *Host) managedRPCExecuteProgram(stream siamux.Stream) error {
duration := sos.ProofDeadline() - bh

// Get a context that can be used to interrupt the program.
ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(h.tg.StopCtx())
defer cancel()
go func() {
// TODO (followup): In the future we might want to wait for a signal
Expand All @@ -116,10 +116,6 @@ func (h *Host) managedRPCExecuteProgram(stream siamux.Stream) error {
}
}()

// Cancel the context on shutdown. The host's tg doesn't have a `StopCtx` so
// we need to do it this way.
h.tg.OnStop(cancel)

// Execute the program.
finalize, outputs, err := h.staticMDM.ExecuteProgram(ctx, pt, program, budget, collateralBudget, sos, duration, dataLength, stream)
if err != nil {
Expand Down

0 comments on commit 9c71482

Please sign in to comment.