Fix restart mutex unlocking for loops
This commit is contained in:
@@ -37,6 +37,7 @@ func (s *State) ApplyStatus(ctx context.Context, status models.LoopStatus) (
|
|||||||
switch existingStatus {
|
switch existingStatus {
|
||||||
case constants.Stopped, constants.Completed:
|
case constants.Stopped, constants.Completed:
|
||||||
default:
|
default:
|
||||||
|
s.statusMu.Unlock()
|
||||||
return "already " + existingStatus.String(), nil
|
return "already " + existingStatus.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ func (s *State) ApplyStatus(ctx context.Context, status models.LoopStatus) (
|
|||||||
return newStatus.String(), nil
|
return newStatus.String(), nil
|
||||||
case constants.Stopped:
|
case constants.Stopped:
|
||||||
if existingStatus != constants.Running {
|
if existingStatus != constants.Running {
|
||||||
|
s.statusMu.Unlock()
|
||||||
return "already " + existingStatus.String(), nil
|
return "already " + existingStatus.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +75,7 @@ func (s *State) ApplyStatus(ctx context.Context, status models.LoopStatus) (
|
|||||||
|
|
||||||
return newStatus.String(), nil
|
return newStatus.String(), nil
|
||||||
default:
|
default:
|
||||||
|
s.statusMu.Unlock()
|
||||||
return "", fmt.Errorf("%w: %s: it can only be one of: %s, %s",
|
return "", fmt.Errorf("%w: %s: it can only be one of: %s, %s",
|
||||||
ErrInvalidStatus, status, constants.Running, constants.Stopped)
|
ErrInvalidStatus, status, constants.Running, constants.Stopped)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user