Assert that the consumer lock is held while sending FDs to consumerd
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 14 Feb 2018 21:14:21 +0000 (16:14 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 14 Feb 2018 22:55:54 +0000 (17:55 -0500)
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 <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/consumer.c

index bd9048bf517d54b9ccb8148310d82b5ee21bc9b1..ced965dee34aa435828eb7484aa8d058d56bb4d3 100644 (file)
@@ -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) {
This page took 0.026096 seconds and 4 git commands to generate.