chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
shared/utf8: mark char* as const
[elogind.git]
/
src
/
core
/
service.c
diff --git
a/src/core/service.c
b/src/core/service.c
index 567e9a4eb316c6e727b2d94b1f83f72f9f4613db..e74da54eac5b288ed54c7c839335fb73a460807e 100644
(file)
--- a/
src/core/service.c
+++ b/
src/core/service.c
@@
-130,12
+130,12
@@
static const UnitActiveState state_translation_table_idle[_SERVICE_STATE_MAX] =
static void service_init(Unit *u) {
Service *s = SERVICE(u);
static void service_init(Unit *u) {
Service *s = SERVICE(u);
- int i;
assert(u);
assert(u->load_state == UNIT_STUB);
assert(u);
assert(u->load_state == UNIT_STUB);
- s->timeout_usec = DEFAULT_TIMEOUT_USEC;
+ s->timeout_start_usec = DEFAULT_TIMEOUT_USEC;
+ s->timeout_stop_usec = DEFAULT_TIMEOUT_USEC;
s->restart_usec = DEFAULT_RESTART_USEC;
s->type = _SERVICE_TYPE_INVALID;
s->restart_usec = DEFAULT_RESTART_USEC;
s->type = _SERVICE_TYPE_INVALID;
@@
-150,9
+150,6
@@
static void service_init(Unit *u) {
s->guess_main_pid = true;
exec_context_init(&s->exec_context);
s->guess_main_pid = true;
exec_context_init(&s->exec_context);
- for (i = 0; i < RLIMIT_NLIMITS; i++)
- if (UNIT(s)->manager->rlimit[i])
- s->exec_context.rlimit[i] = newdup(struct rlimit, UNIT(s)->manager->rlimit[i], 1);
kill_context_init(&s->kill_context);
RATELIMIT_INIT(s->start_limit, 10*USEC_PER_SEC, 5);
kill_context_init(&s->kill_context);
RATELIMIT_INIT(s->start_limit, 10*USEC_PER_SEC, 5);
@@
-568,7
+565,6
@@
static int service_load_sysv_path(Service *s, const char *path) {
goto finish;
}
goto finish;
}
- zero(st);
if (fstat(fileno(f), &st) < 0) {
r = -errno;
goto finish;
if (fstat(fileno(f), &st) < 0) {
r = -errno;
goto finish;
@@
-919,9
+915,13
@@
static int service_load_sysv_path(Service *s, const char *path) {
UNIT(s)->default_dependencies = false;
/* Don't timeout special services during boot (like fsck) */
UNIT(s)->default_dependencies = false;
/* Don't timeout special services during boot (like fsck) */
- s->timeout_usec = 0;
- } else
- s->timeout_usec = DEFAULT_SYSV_TIMEOUT_USEC;
+ s->timeout_start_usec = 0;
+ s->timeout_stop_usec = 0;
+ } else {
+ s->timeout_start_usec = DEFAULT_SYSV_TIMEOUT_USEC;
+ s->timeout_stop_usec = DEFAULT_SYSV_TIMEOUT_USEC;
+ }
+
/* Special setting for all SysV services */
s->type = SERVICE_FORKING;
/* Special setting for all SysV services */
s->type = SERVICE_FORKING;
@@
-1246,9
+1246,9
@@
static int service_load(Unit *u) {
if (s->type == _SERVICE_TYPE_INVALID)
s->type = s->bus_name ? SERVICE_DBUS : SERVICE_SIMPLE;
if (s->type == _SERVICE_TYPE_INVALID)
s->type = s->bus_name ? SERVICE_DBUS : SERVICE_SIMPLE;
- /* Oneshot services have disabled timeout by default */
- if (s->type == SERVICE_ONESHOT && !s->timeout_defined)
- s->timeout_usec = 0;
+ /* Oneshot services have disabled
start
timeout by default */
+ if (s->type == SERVICE_ONESHOT && !s->
start_
timeout_defined)
+ s->timeout_
start_
usec = 0;
service_fix_output(s);
service_fix_output(s);
@@
-1284,7
+1284,7
@@
static int service_load(Unit *u) {
if ((r = service_add_default_dependencies(s)) < 0)
return r;
if ((r = service_add_default_dependencies(s)) < 0)
return r;
- r = unit_
patch_working_directory(UNIT(s)
, &s->exec_context);
+ r = unit_
exec_context_defaults(u
, &s->exec_context);
if (r < 0)
return r;
}
if (r < 0)
return r;
}
@@
-1608,11
+1608,10
@@
static int service_coldplug(Unit *u) {
s->deserialized_state == SERVICE_FINAL_SIGTERM ||
s->deserialized_state == SERVICE_FINAL_SIGKILL ||
s->deserialized_state == SERVICE_AUTO_RESTART) {
s->deserialized_state == SERVICE_FINAL_SIGTERM ||
s->deserialized_state == SERVICE_FINAL_SIGKILL ||
s->deserialized_state == SERVICE_AUTO_RESTART) {
-
- if (s->deserialized_state == SERVICE_AUTO_RESTART || s->timeout_usec > 0) {
+ if (s->deserialized_state == SERVICE_AUTO_RESTART || s->timeout_start_usec > 0) {
usec_t k;
usec_t k;
- k = s->deserialized_state == SERVICE_AUTO_RESTART ? s->restart_usec : s->timeout_usec;
+ k = s->deserialized_state == SERVICE_AUTO_RESTART ? s->restart_usec : s->timeout_
start_
usec;
if ((r = unit_watch_timer(UNIT(s), k, &s->timer_watch)) < 0)
return r;
if ((r = unit_watch_timer(UNIT(s), k, &s->timer_watch)) < 0)
return r;
@@
-1758,8
+1757,9
@@
static int service_spawn(
}
}
}
}
- if (timeout && s->timeout_usec) {
- if ((r = unit_watch_timer(UNIT(s), s->timeout_usec, &s->timer_watch)) < 0)
+ if (timeout && s->timeout_start_usec) {
+ r = unit_watch_timer(UNIT(s), s->timeout_start_usec, &s->timer_watch);
+ if (r < 0)
goto fail;
} else
unit_unwatch_timer(UNIT(s), &s->timer_watch);
goto fail;
} else
unit_unwatch_timer(UNIT(s), &s->timer_watch);
@@
-2016,9
+2016,11
@@
static void service_enter_signal(Service *s, ServiceState state, ServiceResult f
}
if (wait_for_exit) {
}
if (wait_for_exit) {
- if (s->timeout_usec > 0)
- if ((r = unit_watch_timer(UNIT(s), s->timeout_usec, &s->timer_watch)) < 0)
+ if (s->timeout_stop_usec > 0) {
+ r = unit_watch_timer(UNIT(s), s->timeout_stop_usec, &s->timer_watch);
+ if (r < 0)
goto fail;
goto fail;
+ }
service_set_state(s, state);
} else if (state == SERVICE_STOP_SIGTERM || state == SERVICE_STOP_SIGKILL)
service_set_state(s, state);
} else if (state == SERVICE_STOP_SIGTERM || state == SERVICE_STOP_SIGKILL)
@@
-3673,7
+3675,7
@@
static void service_reset_failed(Unit *u) {
RATELIMIT_RESET(s->start_limit);
}
RATELIMIT_RESET(s->start_limit);
}
-static int service_kill(Unit *u, KillWho who,
KillMode mode,
int signo, DBusError *error) {
+static int service_kill(Unit *u, KillWho who, int signo, DBusError *error) {
Service *s = SERVICE(u);
int r = 0;
Set *pid_set = NULL;
Service *s = SERVICE(u);
int r = 0;
Set *pid_set = NULL;
@@
-3700,28
+3702,33
@@
static int service_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusErro
if (kill(s->main_pid, signo) < 0)
r = -errno;
if (kill(s->main_pid, signo) < 0)
r = -errno;
- if (who == KILL_ALL
&& mode == KILL_CONTROL_GROUP
) {
+ if (who == KILL_ALL) {
int q;
int q;
- if (!(pid_set = set_new(trivial_hash_func, trivial_compare_func)))
+ pid_set = set_new(trivial_hash_func, trivial_compare_func);
+ if (!pid_set)
return -ENOMEM;
/* Exclude the control/main pid from being killed via the cgroup */
return -ENOMEM;
/* Exclude the control/main pid from being killed via the cgroup */
- if (s->control_pid > 0)
- if ((q = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0) {
+ if (s->control_pid > 0) {
+ q = set_put(pid_set, LONG_TO_PTR(s->control_pid));
+ if (q < 0) {
r = q;
goto finish;
}
r = q;
goto finish;
}
+ }
- if (s->main_pid > 0)
- if ((q = set_put(pid_set, LONG_TO_PTR(s->main_pid))) < 0) {
+ if (s->main_pid > 0) {
+ q = set_put(pid_set, LONG_TO_PTR(s->main_pid));
+ if (q < 0) {
r = q;
goto finish;
}
r = q;
goto finish;
}
+ }
+
q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, false, pid_set, NULL);
q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, false, pid_set, NULL);
- if (q < 0)
- if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
- r = q;
+ if (q < 0 && q != -EAGAIN && q != -ESRCH && q != -ENOENT)
+ r = q;
}
finish:
}
finish: