From 05dac5980b42afe7b0334b009f43b4e3ba98a319 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 14 Feb 2018 16:14:21 -0500 Subject: [PATCH] Assert that the consumer lock is held while sending FDs to consumerd MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The consumer_data lock must be held during the communications between the consumerd and sessiond. The consumer_data lock is refered-to by each consumer_socket instance; they point to their consumer's global data lock. The lock can't be taken in consumer_send_msg() or consumer_send_fds() since we want to protect a complete "transaction". Some commands require both functions to be called and we want to hold the lock over the duration of both calls to protect against other threads initiating a communication between the two calls. Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/consumer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index bd9048bf5..ced965dee 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -739,6 +739,7 @@ int consumer_send_fds(struct consumer_socket *sock, int *fds, size_t nb_fd) assert(fds); assert(sock); assert(nb_fd > 0); + assert(pthread_mutex_trylock(sock->lock) == EBUSY); ret = lttcomm_send_fds_unix_sock(*sock->fd_ptr, fds, nb_fd); if (ret < 0) { -- 2.34.1