* have to send a command to clean them up or else they leaked.
*/
if (!ksess->output_traces && ksess->consumer_fds_sent) {
- int ret;
- struct consumer_socket *socket;
- struct lttng_ht_iter iter;
-
- /* For each consumer socket. */
- const lttng::urcu::read_lock_guard read_lock;
-
- cds_lfht_for_each_entry (
- ksess->consumer->socks->ht, &iter.iter, socket, node.node) {
+ for (auto *socket :
+ lttng::urcu::lfht_iteration_adapter<consumer_socket,
+ decltype(consumer_socket::node),
+ &consumer_socket::node>(
+ *ksess->consumer->socks->ht)) {
struct ltt_kernel_channel *chan;
/* For each channel, ask the consumer to destroy it. */
cds_list_for_each_entry (chan, &ksess->channel_list.head, list) {
- ret = kernel_consumer_destroy_channel(socket, chan);
+ const auto ret = kernel_consumer_destroy_channel(socket, chan);
if (ret < 0) {
/* Consumer is probably dead. Use next socket. */
continue;
{
int err, ret, saved_metadata_fd;
enum lttng_error_code status = LTTNG_OK;
- struct consumer_socket *socket;
- struct lttng_ht_iter iter;
struct ltt_kernel_metadata *saved_metadata;
char *trace_path = nullptr;
size_t consumer_path_offset = 0;
goto error;
}
- {
- /* Send metadata to consumer and snapshot everything. */
- const lttng::urcu::read_lock_guard read_lock;
-
- cds_lfht_for_each_entry (output->socks->ht, &iter.iter, socket, node.node) {
- struct ltt_kernel_channel *chan;
-
- pthread_mutex_lock(socket->lock);
- /* This stream must not be monitored by the consumer. */
- ret = kernel_consumer_add_metadata(socket, ksess, 0);
- pthread_mutex_unlock(socket->lock);
- if (ret < 0) {
- status = LTTNG_ERR_KERN_META_FAIL;
- goto error_consumer;
- }
+ for (auto *socket :
+ lttng::urcu::lfht_iteration_adapter<consumer_socket,
+ decltype(consumer_socket::node),
+ &consumer_socket::node>(*output->socks->ht)) {
+ struct ltt_kernel_channel *chan;
- /* For each channel, ask the consumer to snapshot it. */
- cds_list_for_each_entry (chan, &ksess->channel_list.head, list) {
- status =
- consumer_snapshot_channel(socket,
- chan->key,
- output,
- 0,
- &trace_path[consumer_path_offset],
- nb_packets_per_stream);
- if (status != LTTNG_OK) {
- (void) kernel_consumer_destroy_metadata(socket,
- ksess->metadata);
- goto error_consumer;
- }
- }
+ pthread_mutex_lock(socket->lock);
+ /* This stream must not be monitored by the consumer. */
+ ret = kernel_consumer_add_metadata(socket, ksess, 0);
+ pthread_mutex_unlock(socket->lock);
+ if (ret < 0) {
+ status = LTTNG_ERR_KERN_META_FAIL;
+ goto error_consumer;
+ }
- /* Snapshot metadata, */
+ /* For each channel, ask the consumer to snapshot it. */
+ cds_list_for_each_entry (chan, &ksess->channel_list.head, list) {
status = consumer_snapshot_channel(socket,
- ksess->metadata->key,
+ chan->key,
output,
- 1,
+ 0,
&trace_path[consumer_path_offset],
- 0);
+ nb_packets_per_stream);
if (status != LTTNG_OK) {
+ (void) kernel_consumer_destroy_metadata(socket, ksess->metadata);
goto error_consumer;
}
+ }
- /*
- * The metadata snapshot is done, ask the consumer to destroy it since
- * it's not monitored on the consumer side.
- */
- (void) kernel_consumer_destroy_metadata(socket, ksess->metadata);
+ /* Snapshot metadata, */
+ status = consumer_snapshot_channel(socket,
+ ksess->metadata->key,
+ output,
+ 1,
+ &trace_path[consumer_path_offset],
+ 0);
+ if (status != LTTNG_OK) {
+ goto error_consumer;
}
+
+ /*
+ * The metadata snapshot is done, ask the consumer to destroy it since
+ * it's not monitored on the consumer side.
+ */
+ (void) kernel_consumer_destroy_metadata(socket, ksess->metadata);
}
error_consumer:
{
int ret;
enum lttng_error_code status = LTTNG_OK;
- struct consumer_socket *socket;
- struct lttng_ht_iter iter;
struct ltt_kernel_session *ksess = session->kernel_session;
LTTNG_ASSERT(ksess);
DBG("Rotate kernel session %s started (session %" PRIu64 ")", session->name, session->id);
- {
- /*
- * Note that this loop will end after one iteration given that there is
- * only one kernel consumer.
- */
- const lttng::urcu::read_lock_guard read_lock;
-
- cds_lfht_for_each_entry (
- ksess->consumer->socks->ht, &iter.iter, socket, node.node) {
- struct ltt_kernel_channel *chan;
-
- /* For each channel, ask the consumer to rotate it. */
- cds_list_for_each_entry (chan, &ksess->channel_list.head, list) {
- DBG("Rotate kernel channel %" PRIu64 ", session %s",
- chan->key,
- session->name);
- ret = consumer_rotate_channel(socket,
- chan->key,
- ksess->consumer,
- /* is_metadata_channel */ false);
- if (ret < 0) {
- status = LTTNG_ERR_ROTATION_FAIL_CONSUMER;
- goto error;
- }
- }
-
- /*
- * Rotate the metadata channel.
- */
+ /*
+ * Note that this loop will end after one iteration given that there is
+ * only one kernel consumer.
+ */
+ for (auto *socket : lttng::urcu::lfht_iteration_adapter<consumer_socket,
+ decltype(consumer_socket::node),
+ &consumer_socket::node>(
+ *ksess->consumer->socks->ht)) {
+ struct ltt_kernel_channel *chan;
+
+ /* For each channel, ask the consumer to rotate it. */
+ cds_list_for_each_entry (chan, &ksess->channel_list.head, list) {
+ DBG("Rotate kernel channel %" PRIu64 ", session %s",
+ chan->key,
+ session->name);
ret = consumer_rotate_channel(socket,
- ksess->metadata->key,
+ chan->key,
ksess->consumer,
- /* is_metadata_channel */ true);
+ /* is_metadata_channel */ false);
if (ret < 0) {
status = LTTNG_ERR_ROTATION_FAIL_CONSUMER;
goto error;
}
}
+
+ /*
+ * Rotate the metadata channel.
+ */
+ ret = consumer_rotate_channel(socket,
+ ksess->metadata->key,
+ ksess->consumer,
+ /* is_metadata_channel */ true);
+ if (ret < 0) {
+ status = LTTNG_ERR_ROTATION_FAIL_CONSUMER;
+ goto error;
+ }
}
error:
{
int ret;
enum lttng_error_code status = LTTNG_OK;
- struct consumer_socket *socket;
- struct lttng_ht_iter iter;
struct ltt_kernel_session *ksess = session->kernel_session;
LTTNG_ASSERT(ksess);
goto end;
}
- {
- /*
- * Note that this loop will end after one iteration given that there is
- * only one kernel consumer.
- */
- const lttng::urcu::read_lock_guard read_lock;
-
- cds_lfht_for_each_entry (
- ksess->consumer->socks->ht, &iter.iter, socket, node.node) {
- struct ltt_kernel_channel *chan;
-
- /* For each channel, ask the consumer to clear it. */
- cds_list_for_each_entry (chan, &ksess->channel_list.head, list) {
- DBG("Clear kernel channel %" PRIu64 ", session %s",
- chan->key,
- session->name);
- ret = consumer_clear_channel(socket, chan->key);
- if (ret < 0) {
- goto error;
- }
- }
-
- if (!ksess->metadata) {
- /*
- * Nothing to do for the metadata.
- * This is a snapshot session.
- * The metadata is genererated on the fly.
- */
- continue;
+ /*
+ * Note that this loop will end after one iteration given that there is
+ * only one kernel consumer.
+ */
+ for (auto *socket : lttng::urcu::lfht_iteration_adapter<consumer_socket,
+ decltype(consumer_socket::node),
+ &consumer_socket::node>(
+ *ksess->consumer->socks->ht)) {
+ struct ltt_kernel_channel *chan;
+
+ /* For each channel, ask the consumer to clear it. */
+ cds_list_for_each_entry (chan, &ksess->channel_list.head, list) {
+ DBG("Clear kernel channel %" PRIu64 ", session %s",
+ chan->key,
+ session->name);
+ ret = consumer_clear_channel(socket, chan->key);
+ if (ret < 0) {
+ goto error;
}
+ }
+ if (!ksess->metadata) {
/*
- * Clear the metadata channel.
- * Metadata channel is not cleared per se but we still need to
- * perform a rotation operation on it behind the scene.
+ * Nothing to do for the metadata.
+ * This is a snapshot session.
+ * The metadata is genererated on the fly.
*/
- ret = consumer_clear_channel(socket, ksess->metadata->key);
- if (ret < 0) {
- goto error;
- }
+ continue;
+ }
+
+ /*
+ * Clear the metadata channel.
+ * Metadata channel is not cleared per se but we still need to
+ * perform a rotation operation on it behind the scene.
+ */
+ ret = consumer_clear_channel(socket, ksess->metadata->key);
+ if (ret < 0) {
+ goto error;
}
}