summaryrefslogtreecommitdiff
path: root/src/socket.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-07-03 19:48:33 +0200
committerLennart Poettering <lennart@poettering.net>2010-07-03 19:48:33 +0200
commita40eb73224e237f758d38847ae216c019425ebac (patch)
treedc95aa3e1800bb44f43393341acb469863483036 /src/socket.c
parent2c966c038dc32ef39baa176371395cde4e541d01 (diff)
unit: add DefaultDependencies= setting
In order to simplify writing of unit files introduce default dependencies that are added to all units unless explictly disabled in a unit. This option can be switched off for select units that are involved in early boot-up ot late system shutdown, This should simplify service files for most normal daemons, but breaks existing service files for software involved in early boot (notably udev), which need to be updated for a DefaultDependencies=no setting)
Diffstat (limited to 'src/socket.c')
-rw-r--r--src/socket.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/socket.c b/src/socket.c
index 91eea7d294..03e556c30e 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -37,6 +37,7 @@
#include "unit-name.h"
#include "dbus-socket.h"
#include "missing.h"
+#include "special.h"
static const UnitActiveState state_translation_table[_SOCKET_STATE_MAX] = {
[SOCKET_DEAD] = UNIT_INACTIVE,
@@ -241,6 +242,17 @@ static int socket_add_device_link(Socket *s) {
return r;
}
+static int socket_add_default_dependencies(Socket *s) {
+ int r;
+ assert(s);
+
+ if (s->meta.manager->running_as == MANAGER_SYSTEM)
+ if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0)
+ return r;
+
+ return unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
+}
+
static int socket_load(Unit *u) {
Socket *s = SOCKET(u);
int r;
@@ -273,6 +285,10 @@ static int socket_load(Unit *u) {
if ((r = unit_add_default_cgroup(u)) < 0)
return r;
+
+ if (s->meta.default_dependencies)
+ if ((r = socket_add_default_dependencies(s)) < 0)
+ return r;
}
return socket_verify(s);