chiark / gitweb /
unit: optionally allow making cgroup attribute changes persistent
[elogind.git] / src / core / socket.c
index fcbcdbe192f306e3e999e27720c384eaa96e3ad8..f74d88e60206ed959fc37f5ad6b3a950831f9bf1 100644 (file)
@@ -102,8 +102,7 @@ static void socket_unwatch_control_pid(Socket *s) {
         s->control_pid = 0;
 }
 
-static void socket_done(Unit *u) {
-        Socket *s = SOCKET(u);
+void socket_free_ports(Socket *s) {
         SocketPort *p;
 
         assert(s);
@@ -119,6 +118,14 @@ static void socket_done(Unit *u) {
                 free(p->path);
                 free(p);
         }
+}
+
+static void socket_done(Unit *u) {
+        Socket *s = SOCKET(u);
+
+        assert(s);
+
+        socket_free_ports(s);
 
         exec_context_done(&s->exec_context);
         exec_command_free_array(s->exec_command, _SOCKET_EXEC_COMMAND_MAX);
@@ -308,7 +315,7 @@ static int socket_add_device_link(Socket *s) {
 
         assert(s);
 
-        if (!s->bind_to_device)
+        if (!s->bind_to_device || streq(s->bind_to_device, "lo"))
                 return 0;
 
         if (asprintf(&t, "/sys/subsystem/net/devices/%s", s->bind_to_device) < 0)
@@ -2381,13 +2388,15 @@ DEFINE_STRING_TABLE_LOOKUP(socket_result, SocketResult);
 
 const UnitVTable socket_vtable = {
         .object_size = sizeof(Socket),
-        .exec_context_offset = offsetof(Socket, exec_context),
 
         .sections =
                 "Unit\0"
                 "Socket\0"
                 "Install\0",
 
+        .exec_context_offset = offsetof(Socket, exec_context),
+        .exec_section = "Socket",
+
         .init = socket_init,
         .done = socket_done,
         .load = socket_load,