From f1f42c8c11af351b861da8564eff79f113075ea9 Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Fri, 1 Dec 2023 13:25:12 +0100 Subject: [PATCH] Handle stop request with already zero users Handle case where users already reached zero and there are no users to terminate on stop request --- src/amoc_controller.erl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/amoc_controller.erl b/src/amoc_controller.erl index 1547834a..8af6b032 100644 --- a/src/amoc_controller.erl +++ b/src/amoc_controller.erl @@ -196,6 +196,10 @@ handle_start_scenario(_Scenario, _Settings, #state{status = Status} = State) -> {{error, {invalid_status, Status}}, State}. -spec handle_stop_scenario(state()) -> {handle_call_res(), state()}. +handle_stop_scenario(#state{scenario = Scenario, scenario_state = ScenarioState, + no_of_users = 0, status = running} = State) -> + amoc_scenario:terminate(Scenario, ScenarioState), + {ok, State#state{status = finished}}; handle_stop_scenario(#state{status = running} = State) -> terminate_all_users(), {ok, State#state{status = terminating}};