chiark / gitweb /
unit: simplify things a little by introducing API to add two dependencies in one...
[elogind.git] / src / socket.c
index 7e62dbce9639d59f8ca7c37f07fbb21c9267424b..91eea7d294895bca43d481d68c2949a62929546f 100644 (file)
@@ -66,15 +66,10 @@ static void socket_init(Unit *u) {
 
         s->max_connections = 64;
 
-        s->keep_alive = false;
         s->priority = -1;
-        s->receive_buffer = 0;
-        s->send_buffer = 0;
         s->ip_tos = -1;
         s->ip_ttl = -1;
-        s->pipe_size = 0;
         s->mark = -1;
-        s->free_bind = false;
 
         exec_context_init(&s->exec_context);
 
@@ -209,10 +204,7 @@ int socket_add_one_mount_link(Socket *s, Mount *m) {
         if (!socket_needs_mount(s, m->where))
                 return 0;
 
-        if ((r = unit_add_dependency(UNIT(m), UNIT_BEFORE, UNIT(s), true)) < 0)
-                return r;
-
-        if ((r = unit_add_dependency(UNIT(s), UNIT_REQUIRES, UNIT(m), true)) < 0)
+        if ((r = unit_add_two_dependencies(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, UNIT(m), true)) < 0)
                 return r;
 
         return 0;
@@ -577,9 +569,15 @@ static void socket_apply_socket_options(Socket *s, int fd) {
                 if (setsockopt(fd, IPPROTO_IP, IP_TOS, &s->ip_tos, sizeof(s->ip_tos)) < 0)
                         log_warning("IP_TOS failed: %m");
 
-        if (s->ip_ttl >= 0)
-                if (setsockopt(fd, IPPROTO_IP, IP_TTL, &s->ip_ttl, sizeof(s->ip_ttl)) < 0)
-                        log_warning("IP_TTL failed: %m");
+        if (s->ip_ttl >= 0) {
+                int r, x;
+
+                r = setsockopt(fd, IPPROTO_IP, IP_TTL, &s->ip_ttl, sizeof(s->ip_ttl));
+                x = setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &s->ip_ttl, sizeof(s->ip_ttl));
+
+                if (r < 0 && x < 0)
+                        log_warning("IP_TTL/IPV6_UNICAST_HOPS failed: %m");
+        }
 }
 
 static void socket_apply_pipe_options(Socket *s, int fd) {