]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/service: fix accept-socket deserialization 33374/head
authorMike Yuan <me@yhndnzj.com>
Mon, 17 Jun 2024 05:47:20 +0000 (07:47 +0200)
committerMike Yuan <me@yhndnzj.com>
Mon, 17 Jun 2024 15:02:51 +0000 (17:02 +0200)
Follow-up for 45b1017488cef2a5bacdf82028ce900a311c9a1c

src/core/service.c

index 92ce26c234cf19bd90ed1aa46b19b60006b953f3..f37a941a6d4323bdfcbfd25ffb8b2a2de5af7201 100644 (file)
@@ -1363,7 +1363,7 @@ static int service_coldplug(Unit *u) {
                 service_start_watchdog(s);
 
         if (UNIT_ISSET(s->accept_socket)) {
-                Socketsocket = SOCKET(UNIT_DEREF(s->accept_socket));
+                Socket *socket = SOCKET(UNIT_DEREF(s->accept_socket));
 
                 if (socket->max_connections_per_source > 0) {
                         SocketPeer *peer;
@@ -3217,8 +3217,8 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
         } else if (streq(key, "accept-socket")) {
                 Unit *socket;
 
-                if (u->type != UNIT_SOCKET) {
-                        log_unit_debug(u, "Failed to deserialize accept-socket: unit is not a socket");
+                if (unit_name_to_type(value) != UNIT_SOCKET) {
+                        log_unit_debug(u, "Deserialized accept-socket is not a socket unit, ignoring: %s", value);
                         return 0;
                 }
 
@@ -3227,7 +3227,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
                         log_unit_debug_errno(u, r, "Failed to load accept-socket unit '%s': %m", value);
                 else {
                         unit_ref_set(&s->accept_socket, u, socket);
-                        SOCKET(socket)->n_connections++;
+                        ASSERT_PTR(SOCKET(socket))->n_connections++;
                 }
 
         } else if (streq(key, "socket-fd")) {