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;
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 */
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) {
ret = 0;
end:
+ pthread_mutex_unlock(&ctx->metadata_socket_lock);
return ret;
}