[lttng-dev] [PATCH lttng-tools 2/2] Cleanup: consumer_add_metadata_stream always return 0

Jérémie Galarneau jeremie.galarneau at efficios.com
Sun Dec 3 14:46:31 UTC 2017


On 28 September 2017 at 22:37, Jonathan Rajotte
<jonathan.rajotte-julien at efficios.com> wrote:
> Since c869f647b0c4476645ab9ee01e362401fb8c1e42, the return value of

That commit dates back to 2012. Didn't know you were into archaeology! :)

Good find, merged in master.

Thanks!
Jérémie

> consumer_add_metadata_stream is always zero. Hence, we can remove some
> dead error handling code.
>
> consumer_add_metadata_stream success is based on assert() check for
> relevant data.
>
> Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
> ---
>  src/common/consumer/consumer.c               |  9 ++-------
>  src/common/consumer/consumer.h               |  4 ++--
>  src/common/kernel-consumer/kernel-consumer.c | 18 +++---------------
>  src/common/ust-consumer/ust-consumer.c       | 14 ++------------
>  4 files changed, 9 insertions(+), 36 deletions(-)
>
> diff --git a/src/common/consumer/consumer.c b/src/common/consumer/consumer.c
> index a8c36990..96ad8512 100644
> --- a/src/common/consumer/consumer.c
> +++ b/src/common/consumer/consumer.c
> @@ -630,10 +630,9 @@ end:
>  /*
>   * Add a stream to the global list protected by a mutex.
>   */
> -int consumer_add_data_stream(struct lttng_consumer_stream *stream)
> +void consumer_add_data_stream(struct lttng_consumer_stream *stream)
>  {
>         struct lttng_ht *ht = data_ht;
> -       int ret = 0;
>
>         assert(stream);
>         assert(ht);
> @@ -683,8 +682,6 @@ int consumer_add_data_stream(struct lttng_consumer_stream *stream)
>         pthread_mutex_unlock(&stream->chan->timer_lock);
>         pthread_mutex_unlock(&stream->chan->lock);
>         pthread_mutex_unlock(&consumer_data.lock);
> -
> -       return ret;
>  }
>
>  void consumer_del_data_stream(struct lttng_consumer_stream *stream)
> @@ -2106,10 +2103,9 @@ void consumer_del_metadata_stream(struct lttng_consumer_stream *stream,
>   * Action done with the metadata stream when adding it to the consumer internal
>   * data structures to handle it.
>   */
> -int consumer_add_metadata_stream(struct lttng_consumer_stream *stream)
> +void consumer_add_metadata_stream(struct lttng_consumer_stream *stream)
>  {
>         struct lttng_ht *ht = metadata_ht;
> -       int ret = 0;
>         struct lttng_ht_iter iter;
>         struct lttng_ht_node_u64 *node;
>
> @@ -2169,7 +2165,6 @@ int consumer_add_metadata_stream(struct lttng_consumer_stream *stream)
>         pthread_mutex_unlock(&stream->chan->lock);
>         pthread_mutex_unlock(&stream->chan->timer_lock);
>         pthread_mutex_unlock(&consumer_data.lock);
> -       return ret;
>  }
>
>  /*
> diff --git a/src/common/consumer/consumer.h b/src/common/consumer/consumer.h
> index d115a597..eb9b8c46 100644
> --- a/src/common/consumer/consumer.h
> +++ b/src/common/consumer/consumer.h
> @@ -754,9 +754,9 @@ void consumer_destroy_relayd(struct consumer_relayd_sock_pair *relayd);
>  unsigned long consumer_get_consume_start_pos(unsigned long consumed_pos,
>                 unsigned long produced_pos, uint64_t nb_packets_per_stream,
>                 uint64_t max_sb_size);
> -int consumer_add_data_stream(struct lttng_consumer_stream *stream);
> +void consumer_add_data_stream(struct lttng_consumer_stream *stream);
>  void consumer_del_stream_for_data(struct lttng_consumer_stream *stream);
> -int consumer_add_metadata_stream(struct lttng_consumer_stream *stream);
> +void consumer_add_metadata_stream(struct lttng_consumer_stream *stream);
>  void consumer_del_stream_for_metadata(struct lttng_consumer_stream *stream);
>  int consumer_create_index_file(struct lttng_consumer_stream *stream);
>
> diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c
> index 7bcb86a3..b761a879 100644
> --- a/src/common/kernel-consumer/kernel-consumer.c
> +++ b/src/common/kernel-consumer/kernel-consumer.c
> @@ -748,26 +748,14 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
>
>                 /* Get the right pipe where the stream will be sent. */
>                 if (new_stream->metadata_flag) {
> -                       ret = consumer_add_metadata_stream(new_stream);
> -                       if (ret) {
> -                               ERR("Consumer add metadata stream %" PRIu64 " failed. Continuing",
> -                                               new_stream->key);
> -                               consumer_stream_free(new_stream);
> -                               goto end_nosignal;
> -                       }
> +                       consumer_add_metadata_stream(new_stream);
>                         stream_pipe = ctx->consumer_metadata_pipe;
>                 } else {
> -                       ret = consumer_add_data_stream(new_stream);
> -                       if (ret) {
> -                               ERR("Consumer add stream %" PRIu64 " failed. Continuing",
> -                                               new_stream->key);
> -                               consumer_stream_free(new_stream);
> -                               goto end_nosignal;
> -                       }
> +                       consumer_add_data_stream(new_stream);
>                         stream_pipe = ctx->consumer_data_pipe;
>                 }
>
> -               /* Vitible to other threads */
> +               /* Visible to other threads */
>                 new_stream->globally_visible = 1;
>
>                 health_code_update();
> diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c
> index ab240f7d..bd8e2c50 100644
> --- a/src/common/ust-consumer/ust-consumer.c
> +++ b/src/common/ust-consumer/ust-consumer.c
> @@ -206,20 +206,10 @@ static int send_stream_to_thread(struct lttng_consumer_stream *stream,
>
>         /* Get the right pipe where the stream will be sent. */
>         if (stream->metadata_flag) {
> -               ret = consumer_add_metadata_stream(stream);
> -               if (ret) {
> -                       ERR("Consumer add metadata stream %" PRIu64 " failed.",
> -                                       stream->key);
> -                       goto error;
> -               }
> +               consumer_add_metadata_stream(stream);
>                 stream_pipe = ctx->consumer_metadata_pipe;
>         } else {
> -               ret = consumer_add_data_stream(stream);
> -               if (ret) {
> -                       ERR("Consumer add stream %" PRIu64 " failed.",
> -                                       stream->key);
> -                       goto error;
> -               }
> +               consumer_add_data_stream(stream);
>                 stream_pipe = ctx->consumer_data_pipe;
>         }
>
> --
> 2.11.0
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com


More information about the lttng-dev mailing list