From 30019f60988d213416a63c5a2ee7b11fcdb73eae Mon Sep 17 00:00:00 2001 From: Didrole Date: Thu, 7 Jul 2022 10:57:30 +0200 Subject: [PATCH] Use the host tg's stop context instead of using the OnStop callback. This leaked the created context until host shutdown. --- modules/host/rpcexecuteprogram.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/host/rpcexecuteprogram.go b/modules/host/rpcexecuteprogram.go index 2f925b618..a9db9cd3e 100644 --- a/modules/host/rpcexecuteprogram.go +++ b/modules/host/rpcexecuteprogram.go @@ -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 @@ -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 {