Fix: add missing metadata socket lock
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 16 Jul 2013 01:06:07 +0000 (21:06 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 16 Jul 2013 18:33:27 +0000 (14:33 -0400)
Protect metadata socket, which can be accessed concurrently by the
metadata timer and by snapshot.

Reviewed-by: Julien Desfossez <julien.desfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/common/consumer.c
src/common/consumer.h
src/common/ust-consumer/ust-consumer.c

index a26a41554d2e379c2e97ad4cca20929627571468..6e99a7f52d0d24ac1473db3f1c2bf12880a8df78 100644 (file)
@@ -1153,6 +1153,7 @@ struct lttng_consumer_local_data *lttng_consumer_create(
 
        ctx->consumer_error_socket = -1;
        ctx->consumer_metadata_socket = -1;
+       pthread_mutex_init(&ctx->metadata_socket_lock, NULL);
        /* assign the callbacks */
        ctx->on_buffer_ready = buffer_ready;
        ctx->on_recv_channel = recv_channel;
index fe396c017a6f4109291d95aa64d50a462c7a3dcb..5a11950084bce1f36625ff0ce7809c31ca5eae71 100644 (file)
@@ -396,8 +396,10 @@ struct lttng_consumer_local_data {
        enum lttng_consumer_type type;
        /* socket to communicate errors with sessiond */
        int consumer_error_socket;
-       /* socket to ask metadata to sessiond */
+       /* socket to ask metadata to sessiond. */
        int consumer_metadata_socket;
+       /* Protect consumer_metadata_socket. */
+       pthread_mutex_t metadata_socket_lock;
        /* socket to exchange commands with sessiond */
        char *consumer_command_sock_path;
        /* communication with splice */
index 6b47ec0c9b2739cb04b07808a03890eee065e2fa..986826fca267c455ba9825ea288edbff2e1ca8f4 100644 (file)
@@ -1890,6 +1890,7 @@ int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx,
                        channel->session_id,
                        channel->session_id_per_pid);
 
+       pthread_mutex_lock(&ctx->metadata_socket_lock);
        ret = lttcomm_send_unix_sock(ctx->consumer_metadata_socket, &request,
                        sizeof(request));
        if (ret < 0) {
@@ -1955,5 +1956,6 @@ int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx,
        ret = 0;
 
 end:
+       pthread_mutex_unlock(&ctx->metadata_socket_lock);
        return ret;
 }
This page took 0.029739 seconds and 4 git commands to generate.