Use compiler-agnostic defines to silence warning
[lttng-tools.git] / src / common / consumer / consumer-timer.cpp
index 8c9371bae780191207c345e3a39184f4b24c97ab..f79a8061b3412d444c4a781a8f350be2ac865592 100644 (file)
@@ -82,6 +82,7 @@ static void metadata_switch_timer(struct lttng_consumer_local_data *ctx, siginfo
 
        channel = (lttng_consumer_channel *) si->si_value.sival_ptr;
        LTTNG_ASSERT(channel);
 
        channel = (lttng_consumer_channel *) si->si_value.sival_ptr;
        LTTNG_ASSERT(channel);
+       LTTNG_ASSERT(!channel->is_deleted);
 
        if (channel->switch_timer_error) {
                return;
 
        if (channel->switch_timer_error) {
                return;
@@ -266,43 +267,34 @@ end:
 static void live_timer(struct lttng_consumer_local_data *ctx, siginfo_t *si)
 {
        int ret;
 static void live_timer(struct lttng_consumer_local_data *ctx, siginfo_t *si)
 {
        int ret;
-       struct lttng_consumer_channel *channel;
-       struct lttng_consumer_stream *stream;
-       struct lttng_ht_iter iter;
        const struct lttng_ht *ht = the_consumer_data.stream_per_chan_id_ht;
        const flush_index_cb flush_index = ctx->type == LTTNG_CONSUMER_KERNEL ?
                consumer_flush_kernel_index :
                consumer_flush_ust_index;
 
        const struct lttng_ht *ht = the_consumer_data.stream_per_chan_id_ht;
        const flush_index_cb flush_index = ctx->type == LTTNG_CONSUMER_KERNEL ?
                consumer_flush_kernel_index :
                consumer_flush_ust_index;
 
-       channel = (lttng_consumer_channel *) si->si_value.sival_ptr;
+       auto *channel = (lttng_consumer_channel *) si->si_value.sival_ptr;
        LTTNG_ASSERT(channel);
        LTTNG_ASSERT(channel);
+       LTTNG_ASSERT(!channel->is_deleted);
 
        if (channel->switch_timer_error) {
 
        if (channel->switch_timer_error) {
-               goto error;
+               return;
        }
 
        DBG("Live timer for channel %" PRIu64, channel->key);
 
        }
 
        DBG("Live timer for channel %" PRIu64, channel->key);
 
-       {
-               lttng::urcu::read_lock_guard read_lock;
-               cds_lfht_for_each_entry_duplicate(ht->ht,
-                                                 ht->hash_fct(&channel->key, lttng_ht_seed),
-                                                 ht->match_fct,
-                                                 &channel->key,
-                                                 &iter.iter,
-                                                 stream,
-                                                 node_channel_id.node)
-               {
-                       ret = check_stream(stream, flush_index);
-                       if (ret < 0) {
-                               goto error_unlock;
-                       }
+       for (auto *stream : lttng::urcu::lfht_filtered_iteration_adapter<
+                    lttng_consumer_stream,
+                    decltype(lttng_consumer_stream::node_channel_id),
+                    &lttng_consumer_stream::node_channel_id,
+                    std::uint64_t>(*ht->ht,
+                                   &channel->key,
+                                   ht->hash_fct(&channel->key, lttng_ht_seed),
+                                   ht->match_fct)) {
+               ret = check_stream(stream, flush_index);
+               if (ret < 0) {
+                       return;
                }
        }
                }
        }
-error_unlock:
-
-error:
-       return;
 }
 
 static void consumer_timer_signal_thread_qs(unsigned int signr)
 }
 
 static void consumer_timer_signal_thread_qs(unsigned int signr)
@@ -373,6 +365,7 @@ static int consumer_channel_timer_start(timer_t *timer_id,
 
        LTTNG_ASSERT(channel);
        LTTNG_ASSERT(channel->key);
 
        LTTNG_ASSERT(channel);
        LTTNG_ASSERT(channel->key);
+       LTTNG_ASSERT(!channel->is_deleted);
 
        if (timer_interval_us == 0) {
                /* No creation needed; not an error. */
 
        if (timer_interval_us == 0) {
                /* No creation needed; not an error. */
@@ -435,6 +428,7 @@ void consumer_timer_switch_start(struct lttng_consumer_channel *channel,
 
        LTTNG_ASSERT(channel);
        LTTNG_ASSERT(channel->key);
 
        LTTNG_ASSERT(channel);
        LTTNG_ASSERT(channel->key);
+       LTTNG_ASSERT(!channel->is_deleted);
 
        ret = consumer_channel_timer_start(&channel->switch_timer,
                                           channel,
 
        ret = consumer_channel_timer_start(&channel->switch_timer,
                                           channel,
@@ -471,6 +465,7 @@ void consumer_timer_live_start(struct lttng_consumer_channel *channel,
 
        LTTNG_ASSERT(channel);
        LTTNG_ASSERT(channel->key);
 
        LTTNG_ASSERT(channel);
        LTTNG_ASSERT(channel->key);
+       LTTNG_ASSERT(!channel->is_deleted);
 
        ret = consumer_channel_timer_start(
                &channel->live_timer, channel, live_timer_interval_us, LTTNG_CONSUMER_SIG_LIVE);
 
        ret = consumer_channel_timer_start(
                &channel->live_timer, channel, live_timer_interval_us, LTTNG_CONSUMER_SIG_LIVE);
@@ -508,6 +503,7 @@ int consumer_timer_monitor_start(struct lttng_consumer_channel *channel,
 
        LTTNG_ASSERT(channel);
        LTTNG_ASSERT(channel->key);
 
        LTTNG_ASSERT(channel);
        LTTNG_ASSERT(channel->key);
+       LTTNG_ASSERT(!channel->is_deleted);
        LTTNG_ASSERT(!channel->monitor_timer_enabled);
 
        ret = consumer_channel_timer_start(&channel->monitor_timer,
        LTTNG_ASSERT(!channel->monitor_timer_enabled);
 
        ret = consumer_channel_timer_start(&channel->monitor_timer,
@@ -530,7 +526,7 @@ int consumer_timer_monitor_stop(struct lttng_consumer_channel *channel)
 
        ret = consumer_channel_timer_stop(&channel->monitor_timer, LTTNG_CONSUMER_SIG_MONITOR);
        if (ret == -1) {
 
        ret = consumer_channel_timer_stop(&channel->monitor_timer, LTTNG_CONSUMER_SIG_MONITOR);
        if (ret == -1) {
-               ERR("Failed to stop live timer");
+               ERR("Failed to stop monitor timer");
                goto end;
        }
 
                goto end;
        }
 
@@ -568,24 +564,20 @@ static int sample_channel_positions(struct lttng_consumer_channel *channel,
                                    get_produced_cb get_produced)
 {
        int ret = 0;
                                    get_produced_cb get_produced)
 {
        int ret = 0;
-       struct lttng_ht_iter iter;
-       struct lttng_consumer_stream *stream;
        bool empty_channel = true;
        uint64_t high = 0, low = UINT64_MAX;
        struct lttng_ht *ht = the_consumer_data.stream_per_chan_id_ht;
 
        *_total_consumed = 0;
 
        bool empty_channel = true;
        uint64_t high = 0, low = UINT64_MAX;
        struct lttng_ht *ht = the_consumer_data.stream_per_chan_id_ht;
 
        *_total_consumed = 0;
 
-       lttng::urcu::read_lock_guard read_lock;
-
-       cds_lfht_for_each_entry_duplicate(ht->ht,
-                                         ht->hash_fct(&channel->key, lttng_ht_seed),
-                                         ht->match_fct,
-                                         &channel->key,
-                                         &iter.iter,
-                                         stream,
-                                         node_channel_id.node)
-       {
+       for (auto *stream : lttng::urcu::lfht_filtered_iteration_adapter<
+                    lttng_consumer_stream,
+                    decltype(lttng_consumer_stream::node_channel_id),
+                    &lttng_consumer_stream::node_channel_id,
+                    std::uint64_t>(*ht->ht,
+                                   &channel->key,
+                                   ht->hash_fct(&channel->key, lttng_ht_seed),
+                                   ht->match_fct)) {
                unsigned long produced, consumed, usage;
 
                empty_channel = false;
                unsigned long produced, consumed, usage;
 
                empty_channel = false;
@@ -637,6 +629,7 @@ end:
        if (empty_channel) {
                ret = -1;
        }
        if (empty_channel) {
                ret = -1;
        }
+
        return ret;
 }
 
        return ret;
 }
 
@@ -644,7 +637,7 @@ end:
 void sample_and_send_channel_buffer_stats(struct lttng_consumer_channel *channel)
 {
        int ret;
 void sample_and_send_channel_buffer_stats(struct lttng_consumer_channel *channel)
 {
        int ret;
-       int channel_monitor_pipe = consumer_timer_thread_get_channel_monitor_pipe();
+       const int channel_monitor_pipe = consumer_timer_thread_get_channel_monitor_pipe();
        struct lttcomm_consumer_channel_monitor_msg msg = {
                .key = channel->key,
                .session_id = channel->session_id,
        struct lttcomm_consumer_channel_monitor_msg msg = {
                .key = channel->key,
                .session_id = channel->session_id,
@@ -687,7 +680,8 @@ void sample_and_send_channel_buffer_stats(struct lttng_consumer_channel *channel
 
        msg.highest = highest;
        msg.lowest = lowest;
 
        msg.highest = highest;
        msg.lowest = lowest;
-       msg.consumed_since_last_sample = total_consumed - channel->last_consumed_size_sample_sent;
+       msg.consumed_since_last_sample =
+               total_consumed - channel->consumed_size_as_of_last_sample_sent;
 
        /*
         * Writes performed here are assumed to be atomic which is only
 
        /*
         * Writes performed here are assumed to be atomic which is only
@@ -712,7 +706,7 @@ void sample_and_send_channel_buffer_stats(struct lttng_consumer_channel *channel
                    channel->key,
                    msg.highest,
                    msg.lowest);
                    channel->key,
                    msg.highest,
                    msg.lowest);
-               channel->last_consumed_size_sample_sent = msg.consumed_since_last_sample;
+               channel->consumed_size_as_of_last_sample_sent = total_consumed;
        }
 }
 
        }
 }
 
This page took 0.026359 seconds and 4 git commands to generate.