From 29eb89a52822ca5e613733f6ff31f2296b7ebd3f Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Wed, 8 Jun 2022 12:26:35 +0200 Subject: [PATCH] Attach client->local->listener to a client very early, now that it is safe. This makes other code safer as well since they can assume that if the client is local (client->local) that the listener (client->local->listener) is non-NULL and safe to access until the client is completely destroyed. --- src/socket.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/socket.c b/src/socket.c index dd9308571..4a2d1ffee 100644 --- a/src/socket.c +++ b/src/socket.c @@ -810,6 +810,8 @@ Client *add_connection(ConfigItem_listen *listener, int fd) client = make_client(NULL, &me); client->local->socket_type = listener->socket_type; + client->local->listener = listener; + client->local->listener->clients++; if (listener->socket_type == SOCKET_TYPE_UNIX) ip = "127.0.0.1"; @@ -860,9 +862,6 @@ refuse_client: break; } - client->local->listener = listener; - if (client->local->listener != NULL) - client->local->listener->clients++; add_client_to_list(client); if (!(listener->options & LISTENER_CONTROL))