service_step(): Fix problem with double start of service/run/tasks

Make svc state transition to RUNNING *before* service_start(), because
in that function we may call service_step() as well, which would start
the svc again (since it was still in READY).

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-12-13 17:58:48 +01:00
parent 594476c4fc
commit e841984a4e
+8 -3
View File
@@ -888,16 +888,21 @@ restart:
if (sm_is_in_teardown(&sm))
break;
/*
* Make state transition *before* service_start(), because
* of HOOK_SVC_START, which may call service_step()
*/
svc_mark_clean(svc);
svc_set_state(svc, SVC_RUNNING_STATE);
err = service_start(svc);
if (err) {
(*restart_cnt)++;
svc_set_state(svc, SVC_READY_STATE);
if (!svc_is_inetd_conn(svc))
break;
}
svc_mark_clean(svc);
svc_set_state(svc, SVC_RUNNING_STATE);
}
break;