service_stop_dynamic(): Skip already stopped and HALT removed services

new postponed stop handling tried to reload already stopped and removed
services.  We should of course skip already stopped services and halt
those that have been removed.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2015-11-26 19:13:39 +01:00
1 parent 8073f7cf27
commit 8df2b7b6e9
1 file changed
+10 -4
+10 -4
View File
@@ -424,10 +424,15 @@ void service_stop_dynamic(void)
_d("Stopping disabled/removed services ...");
for (svc = svc_dynamic_iterator(1); svc; svc = svc_dynamic_iterator(0)) {
if (svc_is_changed(svc)) {
if (svc_is_changed(svc) && svc->pid) {
svc_state_t new_state = SVC_RELOAD_STATE;
if (svc_is_removed(svc))
new_state = SVC_HALTED_STATE;
dyn_stop_cnt++;
_d("Marking service %s as state %d", svc->cmd, SVC_RELOAD_STATE);
service_stop(svc, SVC_RELOAD_STATE);
_d("Marking service %s as state %d", svc->cmd, new_state);
service_stop(svc, new_state);
}
}
@@ -827,7 +832,8 @@ int service_register(int type, char *line, time_t mtime, char *username)
void service_unregister(svc_t *svc)
{
service_stop(svc, SVC_HALTED_STATE);
if (svc->state != SVC_HALTED_STATE)
_e("Failed stopping %s, removing anyway from list of monitored services.", svc->cmd);
svc_del(svc);
}