From a021ff6b227ec30a16558313da3b8512c0efea7a Mon Sep 17 00:00:00 2001 From: "Quentin McGaw (desktop)" Date: Mon, 9 Aug 2021 14:35:55 +0000 Subject: [PATCH] Fix: loopstate mutex unlocking - Fix #547 - Fix all run loops for restarts --- internal/loopstate/apply.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/loopstate/apply.go b/internal/loopstate/apply.go index c0f10192..d48eda6c 100644 --- a/internal/loopstate/apply.go +++ b/internal/loopstate/apply.go @@ -37,6 +37,7 @@ func (s *State) ApplyStatus(ctx context.Context, status models.LoopStatus) ( switch existingStatus { case constants.Stopped, constants.Completed: default: + s.statusMu.Unlock() return "already " + existingStatus.String(), nil } @@ -50,11 +51,13 @@ func (s *State) ApplyStatus(ctx context.Context, status models.LoopStatus) ( case <-ctx.Done(): case newStatus = <-s.running: } + s.SetStatus(newStatus) return newStatus.String(), nil case constants.Stopped: if existingStatus != constants.Running { + s.statusMu.Unlock() return "already " + existingStatus.String(), nil } @@ -73,6 +76,7 @@ func (s *State) ApplyStatus(ctx context.Context, status models.LoopStatus) ( return newStatus.String(), nil default: + s.statusMu.Unlock() return "", fmt.Errorf("%w: %s: it can only be one of: %s, %s", ErrInvalidStatus, status, constants.Running, constants.Stopped) }