mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
core/unit: use FOREACH_ELEMENT() to add dependencies for journal namespace instances
Follow-up for 06c0f569e9
.
This commit is contained in:
parent
ae1cb17cef
commit
2b699c2362
@ -1311,27 +1311,26 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
|
||||
* is run first. */
|
||||
|
||||
if (c->log_namespace) {
|
||||
FOREACH_STRING(s, "systemd-journald", "systemd-journald-varlink") {
|
||||
_cleanup_free_ char *socket_unit = NULL;
|
||||
static const struct {
|
||||
const char *template;
|
||||
UnitType type;
|
||||
} deps[] = {
|
||||
{ "systemd-journald", UNIT_SOCKET, },
|
||||
{ "systemd-journald-varlink", UNIT_SOCKET, },
|
||||
{ "systemd-journald-sync", UNIT_SERVICE, },
|
||||
};
|
||||
|
||||
r = unit_name_build_from_type(s, c->log_namespace, UNIT_SOCKET, &socket_unit);
|
||||
FOREACH_ELEMENT(i, deps) {
|
||||
_cleanup_free_ char *unit = NULL;
|
||||
|
||||
r = unit_name_build_from_type(i->template, c->log_namespace, i->type, &unit);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = unit_add_two_dependencies_by_name(u, UNIT_AFTER, UNIT_REQUIRES, socket_unit, true, UNIT_DEPENDENCY_FILE);
|
||||
r = unit_add_two_dependencies_by_name(u, UNIT_AFTER, UNIT_REQUIRES, unit, true, UNIT_DEPENDENCY_FILE);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
_cleanup_free_ char *sync_unit = NULL;
|
||||
|
||||
r = unit_name_build_from_type("systemd-journald-sync", c->log_namespace, UNIT_SERVICE, &sync_unit);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = unit_add_two_dependencies_by_name(u, UNIT_AFTER, UNIT_REQUIRES, sync_unit, true, UNIT_DEPENDENCY_FILE);
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else {
|
||||
r = unit_add_dependency_by_name(u, UNIT_AFTER, SPECIAL_JOURNALD_SOCKET, true, UNIT_DEPENDENCY_FILE);
|
||||
if (r < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user