From: Lennart Poettering Date: Tue, 3 Jan 2012 19:33:28 +0000 (+0100) Subject: socket: only add dependency on kmsg socket to socket units which have any kind of... X-Git-Tag: v38~105 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4cfc6dbe52e4ff867750ce0d64f09d42c0ea6c27;p=systemd socket: only add dependency on kmsg socket to socket units which have any kind of exec program specified --- diff --git a/src/socket.c b/src/socket.c index bbfc842c..1f5e0673 100644 --- a/src/socket.c +++ b/src/socket.c @@ -323,6 +323,17 @@ static int socket_add_default_dependencies(Socket *s) { return unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true); } +static bool socket_has_exec(Socket *s) { + unsigned i; + assert(s); + + for (i = 0; i < _SOCKET_EXEC_COMMAND_MAX; i++) + if (s->exec_command[i]) + return true; + + return false; +} + static int socket_load(Unit *u) { Socket *s = SOCKET(u); int r; @@ -352,8 +363,9 @@ static int socket_load(Unit *u) { if ((r = socket_add_device_link(s)) < 0) return r; - if ((r = unit_add_exec_dependencies(u, &s->exec_context)) < 0) - return r; + if (socket_has_exec(s)) + if ((r = unit_add_exec_dependencies(u, &s->exec_context)) < 0) + return r; if ((r = unit_add_default_cgroups(u)) < 0) return r;