Skip to content

Commit 25364ef

Browse files
YHNdnzjbluca
authored andcommitted
core/service: fix accept-socket deserialization
Follow-up for 45b1017 (cherry picked from commit 9f5d8c3) (cherry picked from commit f7d55cc) (cherry picked from commit 8ead254) (cherry picked from commit 8f28021) (cherry picked from commit 72c1768)
1 parent fc63fd0 commit 25364ef

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/core/service.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ static int service_coldplug(Unit *u) {
12331233
service_start_watchdog(s);
12341234

12351235
if (UNIT_ISSET(s->accept_socket)) {
1236-
Socket* socket = SOCKET(UNIT_DEREF(s->accept_socket));
1236+
Socket *socket = SOCKET(UNIT_DEREF(s->accept_socket));
12371237

12381238
if (socket->max_connections_per_source > 0) {
12391239
SocketPeer *peer;
@@ -3011,8 +3011,8 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
30113011
} else if (streq(key, "accept-socket")) {
30123012
Unit *socket;
30133013

3014-
if (u->type != UNIT_SOCKET) {
3015-
log_unit_debug(u, "Failed to deserialize accept-socket: unit is not a socket");
3014+
if (unit_name_to_type(value) != UNIT_SOCKET) {
3015+
log_unit_debug(u, "Deserialized accept-socket is not a socket unit, ignoring: %s", value);
30163016
return 0;
30173017
}
30183018

@@ -3021,7 +3021,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
30213021
log_unit_debug_errno(u, r, "Failed to load accept-socket unit '%s': %m", value);
30223022
else {
30233023
unit_ref_set(&s->accept_socket, u, socket);
3024-
SOCKET(socket)->n_connections++;
3024+
ASSERT_PTR(SOCKET(socket))->n_connections++;
30253025
}
30263026

30273027
} else if (streq(key, "socket-fd")) {

0 commit comments

Comments
 (0)