From 697afe8608fbf85c86fa70e7dbd2680bfdff3b7e Mon Sep 17 00:00:00 2001 From: "Alessandro (Ale) Segala" <43508+ItalyPaleAle@users.noreply.github.com> Date: Tue, 9 Aug 2022 11:37:07 -0700 Subject: [PATCH] bindings.cron: ensure it can resume correctly after context cancellation (#1943) Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> --- bindings/cron/cron.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/cron/cron.go b/bindings/cron/cron.go index 927ec7f84..e16a756e5 100644 --- a/bindings/cron/cron.go +++ b/bindings/cron/cron.go @@ -85,12 +85,12 @@ func (b *Binding) Read(ctx context.Context, handler bindings.Handler) error { b.logger.Debugf("name: %s, next run: %v", b.name, time.Until(c.Entry(id).Next)) go func() { - // Wait for a context to be canceled or a message on the stopCh + // Wait for a context to be canceled select { case <-b.runningCtx.Done(): // Do nothing case <-ctx.Done(): - b.runningCancel() + b.resetContext() } b.logger.Debugf("name: %s, stopping schedule: %s", b.name, b.schedule) c.Stop()