Fix consumerd fd leak
[lttng-tools.git] / src / common / ust-consumer / ust-consumer.c
index 2bbc3f5e4fab1ba7b89fd0820ddf93080229b15d..03c00a677ac4f53702dd79c68cc2759b897bdd4f 100644 (file)
@@ -859,13 +859,6 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                        goto end_channel_error;
                }
 
-               /*
-                * Set refcount to 1 for owner. Below, we will pass
-                * ownership to the consumer_thread_channel_poll()
-                * thread.
-                */
-               channel->refcount = 1;
-
                /* Build channel attributes from received message. */
                attr.subbuf_size = msg.u.ask_channel.subbuf_size;
                attr.num_subbuf = msg.u.ask_channel.num_subbuf;
@@ -890,6 +883,12 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                case LTTNG_UST_CHAN_PER_CPU:
                        channel->type = CONSUMER_CHANNEL_TYPE_DATA;
                        attr.type = LTTNG_UST_CHAN_PER_CPU;
+                       /*
+                        * Set refcount to 1 for owner. Below, we will
+                        * pass ownership to the
+                        * consumer_thread_channel_poll() thread.
+                        */
+                       channel->refcount = 1;
                        break;
                case LTTNG_UST_CHAN_METADATA:
                        channel->type = CONSUMER_CHANNEL_TYPE_METADATA;
@@ -1049,6 +1048,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                if (!channel) {
                        ERR("UST consumer push metadata %" PRIu64 " not found", key);
                        ret_code = LTTNG_ERR_UST_CHAN_NOT_FOUND;
+                       goto end_msg_sessiond;
                }
 
                /* Tell session daemon we are ready to receive the metadata. */
This page took 0.027616 seconds and 4 git commands to generate.