Cleanup: Reduce scope of connections in main relayd thread
[lttng-tools.git] / src / bin / lttng-sessiond / ust-consumer.c
index 9715c426f468f5b24cf76bf64726b0cf218d5af3..611b54dcdb17d392f14bd42dc98320a0cb098b61 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #define _GNU_SOURCE
+#define _LGPL_SOURCE
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -308,7 +309,7 @@ int ust_consumer_get_channel(struct consumer_socket *socket,
                cds_list_add_tail(&stream->list, &ua_chan->streams.head);
                ua_chan->streams.count++;
 
-               DBG2("UST app stream %d received succesfully", ua_chan->streams.count);
+               DBG2("UST app stream %d received successfully", ua_chan->streams.count);
        }
 
        /* This MUST match or else we have a synchronization problem. */
@@ -383,8 +384,8 @@ int ust_consumer_send_stream_to_ust(struct ust_app *app,
        ret = ustctl_send_stream_to_ust(app->sock, channel->obj, stream->obj);
        if (ret < 0) {
                if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
-                       ERR("Error ustctl send stream %s to app pid: %d with ret %d",
-                                       stream->name, app->pid, ret);
+                       ERR("ustctl send stream handle %d to app pid: %d with ret %d",
+                                       stream->obj->handle, app->pid, ret);
                } else {
                        DBG3("UST app send stream to ust failed. Application is dead.");
                }
@@ -447,12 +448,12 @@ int ust_consumer_metadata_request(struct consumer_socket *socket)
        assert(socket);
 
        rcu_read_lock();
-       pthread_mutex_lock(socket->lock);
-
        health_code_update();
 
        /* Wait for a metadata request */
+       pthread_mutex_lock(socket->lock);
        ret = consumer_socket_recv(socket, &request, sizeof(request));
+       pthread_mutex_unlock(socket->lock);
        if (ret < 0) {
                goto end;
        }
@@ -487,7 +488,9 @@ int ust_consumer_metadata_request(struct consumer_socket *socket)
        }
        assert(ust_reg);
 
+       pthread_mutex_lock(&ust_reg->lock);
        ret_push = ust_app_push_metadata(ust_reg, socket, 1);
+       pthread_mutex_unlock(&ust_reg->lock);
        if (ret_push < 0) {
                ERR("Pushing metadata");
                ret = -1;
@@ -497,7 +500,6 @@ int ust_consumer_metadata_request(struct consumer_socket *socket)
        ret = 0;
 
 end:
-       pthread_mutex_unlock(socket->lock);
        rcu_read_unlock();
        return ret;
 }
This page took 0.024507 seconds and 4 git commands to generate.