From 1b5edb83504a933f6f5a1b07d574f8c6cf2e0e4e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 10 Feb 2020 18:35:27 -0500 Subject: [PATCH] sessiond: notification: introduce the notion of 'active' client MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Since notification_clients are now accessed from multiple threads, it is possible for a thread to access a client while it is being "cleaned-up" following an error. The 'active' communication flag allows a check to be performed before any communication is attempted with a client. The communication is considered 'active' once the handshake has been performed. It is considered 'inactive' if a fatal protocol error occurs. Signed-off-by: Jérémie Galarneau Change-Id: If16f83ef12fe9a6ef597ae464867011811389177 --- src/bin/lttng-sessiond/notification-thread-events.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bin/lttng-sessiond/notification-thread-events.c b/src/bin/lttng-sessiond/notification-thread-events.c index 51b95ee6d..a2fa8a1ca 100644 --- a/src/bin/lttng-sessiond/notification-thread-events.c +++ b/src/bin/lttng-sessiond/notification-thread-events.c @@ -151,6 +151,13 @@ struct notification_client { struct cds_lfht_node client_socket_ht_node; struct cds_lfht_node client_id_ht_node; struct { + /* + * If a client's communication is inactive, it means a fatal + * error (either a protocol error or the socket API returned + * a fatal error). No further communication should be attempted; + * the client is queued for clean-up. + */ + bool active; struct { /* * During the reception of a message, the reception @@ -2836,6 +2843,7 @@ int client_dispatch_message(struct notification_client *client, goto end; } client->validated = true; + client->communication.active = true; break; } case LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE: -- 2.34.1