*/
static void delete_ust_app_session(int sock, struct ust_app_session *ua_sess, struct ust_app *app)
{
- int ret;
- struct lttng_ht_iter iter;
- struct ust_app_channel *ua_chan;
-
LTTNG_ASSERT(ua_sess);
ASSERT_RCU_READ_LOCKED();
(void) push_metadata(locked_registry, ua_sess->consumer);
}
- cds_lfht_for_each_entry (ua_sess->channels->ht, &iter.iter, ua_chan, node.node) {
- ret = lttng_ht_del(ua_sess->channels, &iter);
- LTTNG_ASSERT(!ret);
+ for (auto *ua_chan :
+ lttng::urcu::lfht_iteration_adapter<ust_app_channel,
+ decltype(ust_app_channel::node),
+ &ust_app_channel::node>(*ua_sess->channels->ht)) {
+ const auto ret = cds_lfht_del(ua_sess->channels->ht, &ua_chan->node.node);
+ LTTNG_ASSERT(ret == 0);
delete_ust_app_channel(sock, ua_chan, app, locked_registry);
}
if (ua_sess->handle != -1) {
pthread_mutex_lock(&app->sock_lock);
- ret = lttng_ust_ctl_release_handle(sock, ua_sess->handle);
+ auto ret = lttng_ust_ctl_release_handle(sock, ua_sess->handle);
pthread_mutex_unlock(&app->sock_lock);
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
}
/* Remove session from application UST object descriptor. */
- iter.iter.node = &ua_sess->ust_objd_node.node;
- ret = lttng_ht_del(app->ust_sessions_objd, &iter);
+ ret = cds_lfht_del(app->ust_sessions_objd->ht, &ua_sess->ust_objd_node.node);
LTTNG_ASSERT(!ret);
}
static void delete_ust_app(struct ust_app *app)
{
int ret, sock;
- struct lttng_ht_iter iter;
- struct ust_app_event_notifier_rule *event_notifier_rule;
bool event_notifier_write_fd_is_open;
/*
{
const lttng::urcu::read_lock_guard read_lock;
- cds_lfht_for_each_entry (app->token_to_event_notifier_rule_ht->ht,
- &iter.iter,
- event_notifier_rule,
- node.node) {
- ret = lttng_ht_del(app->token_to_event_notifier_rule_ht, &iter);
+ for (auto *event_notifier_rule :
+ lttng::urcu::lfht_iteration_adapter<ust_app_event_notifier_rule,
+ decltype(ust_app_event_notifier_rule::node),
+ &ust_app_event_notifier_rule::node>(
+ *app->token_to_event_notifier_rule_ht->ht)) {
+ ret = cds_lfht_del(app->token_to_event_notifier_rule_ht->ht,
+ &event_notifier_rule->node.node);
LTTNG_ASSERT(!ret);
delete_ust_app_event_notifier_rule(app->sock, event_notifier_rule, app);
static void ust_app_unregister(ust_app& app)
{
- struct lttng_ht_iter iter;
- struct ust_app_session *ua_sess;
-
const lttng::urcu::read_lock_guard read_lock;
/*
* ensuring proper behavior of data_pending check.
* Remove sessions so they are not visible during deletion.
*/
- cds_lfht_for_each_entry (app.sessions->ht, &iter.iter, ua_sess, node.node) {
- const auto del_ret = lttng_ht_del(app.sessions, &iter);
+ for (auto *ua_sess :
+ lttng::urcu::lfht_iteration_adapter<ust_app_session,
+ decltype(ust_app_session::node),
+ &ust_app_session::node>(*app.sessions->ht)) {
+ const auto del_ret = cds_lfht_del(app.sessions->ht, &ua_sess->node.node);
if (del_ret) {
/* The session was already removed so scheduled for teardown. */
continue;
* either way it's valid. The close of that socket is handled by the
* apps_notify_thread.
*/
- iter.iter.node = &app.notify_sock_n.node;
- (void) lttng_ht_del(ust_app_ht_by_notify_sock, &iter);
+ (void) cds_lfht_del(ust_app_ht_by_notify_sock->ht, &app.notify_sock_n.node);
/*
* Ignore return value since the node might have been removed before by an
* add replace during app registration because the PID can be reassigned by
* the OS.
*/
- iter.iter.node = &app.pid_n.node;
- if (lttng_ht_del(ust_app_ht, &iter)) {
+ if (cds_lfht_del(ust_app_ht->ht, &app.pid_n.node)) {
DBG3("Unregister app by PID %d failed. This can happen on pid reuse", app.pid);
}
}
void ust_app_clean_list()
{
int ret;
- struct ust_app *app;
- struct lttng_ht_iter iter;
-
DBG2("UST app cleaning registered apps hash table");
/* Cleanup notify socket hash table */
if (ust_app_ht_by_notify_sock) {
- const lttng::urcu::read_lock_guard read_lock;
-
- cds_lfht_for_each_entry (
- ust_app_ht_by_notify_sock->ht, &iter.iter, app, notify_sock_n.node) {
+ for (auto *app :
+ lttng::urcu::lfht_iteration_adapter<ust_app,
+ decltype(ust_app::notify_sock_n),
+ &ust_app::notify_sock_n>(
+ *ust_app_ht_by_notify_sock->ht)) {
/*
* Assert that all notifiers are gone as all triggers
* are unregistered prior to this clean-up.
if (ust_app_ht_by_sock) {
const lttng::urcu::read_lock_guard read_lock;
- cds_lfht_for_each_entry (ust_app_ht_by_sock->ht, &iter.iter, app, sock_n.node) {
- ret = lttng_ht_del(ust_app_ht_by_sock, &iter);
+ for (auto *app : lttng::urcu::lfht_iteration_adapter<ust_app,
+ decltype(ust_app::sock_n),
+ &ust_app::sock_n>(
+ *ust_app_ht_by_sock->ht)) {
+ ret = cds_lfht_del(ust_app_ht_by_sock->ht, &app->sock_n.node);
LTTNG_ASSERT(!ret);
ust_app_put(app);
}
static int ust_app_flush_app_session(ust_app& app, ust_app_session& ua_sess)
{
int ret, retval = 0;
- struct lttng_ht_iter iter;
- struct ust_app_channel *ua_chan;
struct consumer_socket *socket;
const auto update_health_code_on_exit =
switch (ua_sess.buffer_type) {
case LTTNG_BUFFER_PER_PID:
{
- const lttng::urcu::read_lock_guard read_lock;
-
- cds_lfht_for_each_entry (ua_sess.channels->ht, &iter.iter, ua_chan, node.node) {
+ for (auto *ua_chan :
+ lttng::urcu::lfht_iteration_adapter<ust_app_channel,
+ decltype(ust_app_channel::node),
+ &ust_app_channel::node>(
+ *ua_sess.channels->ht)) {
health_code_update();
ret = consumer_flush_channel(socket, ua_chan->key);
if (ret) {
case LTTNG_BUFFER_PER_UID:
{
struct buffer_reg_uid *reg;
- struct lttng_ht_iter iter;
/* Flush all per UID buffers associated to that session. */
cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) {
const lttng::urcu::read_lock_guard read_lock;
lsu::registry_session *ust_session_reg;
- struct buffer_reg_channel *buf_reg_chan;
struct consumer_socket *socket;
/* Get consumer socket to use to push the metadata.*/
continue;
}
- cds_lfht_for_each_entry (
- reg->registry->channels->ht, &iter.iter, buf_reg_chan, node.node) {
+ for (auto *buf_reg_chan :
+ lttng::urcu::lfht_iteration_adapter<buffer_reg_channel,
+ decltype(buffer_reg_channel::node),
+ &buffer_reg_channel::node>(
+ *reg->registry->channels->ht)) {
/*
* The following call will print error values so the return
* code is of little importance because whatever happens, we
static int ust_app_clear_quiescent_app_session(struct ust_app *app, struct ust_app_session *ua_sess)
{
int ret = 0;
- struct lttng_ht_iter iter;
- struct ust_app_channel *ua_chan;
struct consumer_socket *socket;
DBG("Clearing stream quiescent state for ust app pid %d", app->pid);
/* Clear quiescent state. */
switch (ua_sess->buffer_type) {
case LTTNG_BUFFER_PER_PID:
- cds_lfht_for_each_entry (ua_sess->channels->ht, &iter.iter, ua_chan, node.node) {
+ for (auto *ua_chan :
+ lttng::urcu::lfht_iteration_adapter<ust_app_channel,
+ decltype(ust_app_channel::node),
+ &ust_app_channel::node>(
+ *ua_sess->channels->ht)) {
health_code_update();
ret = consumer_clear_quiescent_channel(socket, ua_chan->key);
if (ret) {
switch (usess->buffer_type) {
case LTTNG_BUFFER_PER_UID:
{
- struct lttng_ht_iter iter;
struct buffer_reg_uid *reg;
/*
*/
cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) {
struct consumer_socket *socket;
- struct buffer_reg_channel *buf_reg_chan;
const lttng::urcu::read_lock_guard read_lock;
/* Get associated consumer socket.*/
continue;
}
- cds_lfht_for_each_entry (
- reg->registry->channels->ht, &iter.iter, buf_reg_chan, node.node) {
+ for (auto *buf_reg_chan :
+ lttng::urcu::lfht_iteration_adapter<buffer_reg_channel,
+ decltype(buffer_reg_channel::node),
+ &buffer_reg_channel::node>(
+ *reg->registry->channels->ht)) {
/*
* The following call will print error values so
* the return code is of little importance
}
case LTTNG_BUFFER_PER_PID:
{
- struct ust_app_session *ua_sess;
- const lttng::urcu::read_lock_guard read_lock;
-
/* Iterate on all apps. */
for (auto *app :
lttng::urcu::lfht_iteration_adapter<ust_app,
decltype(ust_app::pid_n),
&ust_app::pid_n>(*ust_app_ht->ht)) {
- ua_sess = ust_app_lookup_app_session(usess, app);
+ auto *ua_sess = ust_app_lookup_app_session(usess, app);
if (ua_sess == nullptr) {
continue;
}
+
(void) ust_app_clear_quiescent_app_session(app, ua_sess);
}
int ret = 0;
enum lttng_error_code ret_code;
enum lttng_trigger_status t_status;
- struct lttng_ht_iter app_trigger_iter;
struct lttng_triggers *triggers = nullptr;
- struct ust_app_event_notifier_rule *event_notifier_rule;
unsigned int count, i;
ASSERT_RCU_READ_LOCKED();
}
}
- {
- const lttng::urcu::read_lock_guard read_lock;
+ /* Remove all unknown event sources from the app. */
+ for (auto *event_notifier_rule :
+ lttng::urcu::lfht_iteration_adapter<ust_app_event_notifier_rule,
+ decltype(ust_app_event_notifier_rule::node),
+ &ust_app_event_notifier_rule::node>(
+ *app->token_to_event_notifier_rule_ht->ht)) {
+ const uint64_t app_token = event_notifier_rule->token;
+ bool found = false;
- /* Remove all unknown event sources from the app. */
- cds_lfht_for_each_entry (app->token_to_event_notifier_rule_ht->ht,
- &app_trigger_iter.iter,
- event_notifier_rule,
- node.node) {
- const uint64_t app_token = event_notifier_rule->token;
- bool found = false;
-
- /*
- * Check if the app event trigger still exists on the
- * notification side.
- */
- for (i = 0; i < count; i++) {
- uint64_t notification_thread_token;
- const struct lttng_trigger *trigger =
- lttng_triggers_get_at_index(triggers, i);
-
- LTTNG_ASSERT(trigger);
+ /*
+ * Check if the app event trigger still exists on the
+ * notification side.
+ */
+ for (i = 0; i < count; i++) {
+ uint64_t notification_thread_token;
+ const struct lttng_trigger *trigger =
+ lttng_triggers_get_at_index(triggers, i);
- notification_thread_token = lttng_trigger_get_tracer_token(trigger);
+ LTTNG_ASSERT(trigger);
- if (notification_thread_token == app_token) {
- found = true;
- break;
- }
- }
+ notification_thread_token = lttng_trigger_get_tracer_token(trigger);
- if (found) {
- /* Still valid. */
- continue;
+ if (notification_thread_token == app_token) {
+ found = true;
+ break;
}
+ }
- /*
- * This trigger was unregistered, disable it on the tracer's
- * side.
- */
- ret = lttng_ht_del(app->token_to_event_notifier_rule_ht, &app_trigger_iter);
- LTTNG_ASSERT(ret == 0);
+ if (found) {
+ /* Still valid. */
+ continue;
+ }
- /* Callee logs errors. */
- (void) disable_ust_object(app, event_notifier_rule->obj);
+ /*
+ * This trigger was unregistered, disable it on the tracer's
+ * side.
+ */
+ ret = cds_lfht_del(app->token_to_event_notifier_rule_ht->ht,
+ &event_notifier_rule->node.node);
+ LTTNG_ASSERT(ret == 0);
- delete_ust_app_event_notifier_rule(app->sock, event_notifier_rule, app);
- }
+ /* Callee logs errors. */
+ (void) disable_ust_object(app, event_notifier_rule->obj);
+ delete_ust_app_event_notifier_rule(app->sock, event_notifier_rule, app);
}
end:
const ust_app_session::locked_weak_ref& ua_sess,
struct ust_app *app)
{
- int ret = 0;
- struct cds_lfht_iter uchan_iter;
- struct ltt_ust_channel *uchan;
-
LTTNG_ASSERT(usess);
LTTNG_ASSERT(app);
ASSERT_RCU_READ_LOCKED();
- cds_lfht_for_each_entry (usess->domain_global.channels->ht, &uchan_iter, uchan, node.node) {
+ for (auto *uchan : lttng::urcu::lfht_iteration_adapter<ltt_ust_channel,
+ decltype(ltt_ust_channel::node),
+ <t_ust_channel::node>(
+ *usess->domain_global.channels->ht)) {
struct ust_app_channel *ua_chan;
- struct cds_lfht_iter uevent_iter;
- struct ltt_ust_event *uevent;
/*
* Search for a matching ust_app_channel. If none is found,
* allocated (if necessary) and sent to the application, and
* all enabled contexts will be added to the channel.
*/
- ret = find_or_create_ust_app_channel(usess, ua_sess, app, uchan, &ua_chan);
+ int ret = find_or_create_ust_app_channel(usess, ua_sess, app, uchan, &ua_chan);
if (ret) {
/* Tracer is probably gone or ENOMEM. */
goto end;
continue;
}
- cds_lfht_for_each_entry (uchan->events->ht, &uevent_iter, uevent, node.node) {
+ for (auto *uevent :
+ lttng::urcu::lfht_iteration_adapter<ltt_ust_event,
+ decltype(ltt_ust_event::node),
+ <t_ust_event::node>(
+ *uchan->events->ht)) {
ret = ust_app_channel_synchronize_event(ua_chan, uevent, app);
if (ret) {
goto end;
{
int ret = 0;
enum lttng_error_code status = LTTNG_OK;
- struct lttng_ht_iter iter;
char *trace_path = nullptr;
LTTNG_ASSERT(usess);
const lttng::urcu::read_lock_guard read_lock;
cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) {
- struct buffer_reg_channel *buf_reg_chan;
struct consumer_socket *socket;
char pathname[PATH_MAX];
size_t consumer_path_offset = 0;
goto error;
}
/* Add the UST default trace dir to path. */
- cds_lfht_for_each_entry (
- reg->registry->channels->ht, &iter.iter, buf_reg_chan, node.node) {
+ for (auto *buf_reg_chan :
+ lttng::urcu::lfht_iteration_adapter<buffer_reg_channel,
+ decltype(buffer_reg_channel::node),
+ &buffer_reg_channel::node>(
+ *reg->registry->channels->ht)) {
status =
consumer_snapshot_channel(socket,
buf_reg_chan->consumer_key,
decltype(ust_app::pid_n),
&ust_app::pid_n>(*ust_app_ht->ht)) {
struct consumer_socket *socket;
- struct lttng_ht_iter chan_iter;
- struct ust_app_channel *ua_chan;
struct ust_app_session *ua_sess;
lsu::registry_session *registry;
char pathname[PATH_MAX];
status = LTTNG_ERR_INVALID;
goto error;
}
- cds_lfht_for_each_entry (
- ua_sess->channels->ht, &chan_iter.iter, ua_chan, node.node) {
+
+ for (auto *ua_chan :
+ lttng::urcu::lfht_iteration_adapter<ust_app_channel,
+ decltype(ust_app_channel::node),
+ &ust_app_channel::node>(
+ *ua_sess->channels->ht)) {
status =
consumer_snapshot_channel(socket,
ua_chan->key,
uint64_t cur_nr_packets)
{
uint64_t tot_size = 0;
- struct lttng_ht_iter iter;
LTTNG_ASSERT(usess);
struct buffer_reg_uid *reg;
cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) {
- struct buffer_reg_channel *buf_reg_chan;
-
- const lttng::urcu::read_lock_guard read_lock;
-
- cds_lfht_for_each_entry (
- reg->registry->channels->ht, &iter.iter, buf_reg_chan, node.node) {
+ for (auto *buf_reg_chan :
+ lttng::urcu::lfht_iteration_adapter<buffer_reg_channel,
+ decltype(buffer_reg_channel::node),
+ &buffer_reg_channel::node>(
+ *reg->registry->channels->ht)) {
if (cur_nr_packets >= buf_reg_chan->num_subbuf) {
/*
* Don't take channel into account if we
lttng::urcu::lfht_iteration_adapter<ust_app,
decltype(ust_app::pid_n),
&ust_app::pid_n>(*ust_app_ht->ht)) {
- struct ust_app_channel *ua_chan;
- struct ust_app_session *ua_sess;
- struct lttng_ht_iter chan_iter;
-
- ua_sess = ust_app_lookup_app_session(usess, app);
+ const auto *ua_sess = ust_app_lookup_app_session(usess, app);
if (!ua_sess) {
/* Session not associated with this app. */
continue;
}
- cds_lfht_for_each_entry (
- ua_sess->channels->ht, &chan_iter.iter, ua_chan, node.node) {
+ for (auto *ua_chan :
+ lttng::urcu::lfht_iteration_adapter<ust_app_channel,
+ decltype(ust_app_channel::node),
+ &ust_app_channel::node>(
+ *ua_sess->channels->ht)) {
if (cur_nr_packets >= ua_chan->attr.num_subbuf) {
/*
* Don't take channel into account if we
{
int ret;
enum lttng_error_code cmd_ret = LTTNG_OK;
- struct lttng_ht_iter iter;
struct ltt_ust_session *usess = session->ust_session;
LTTNG_ASSERT(usess);
struct buffer_reg_uid *reg;
cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) {
- struct buffer_reg_channel *buf_reg_chan;
struct consumer_socket *socket;
const lttng::urcu::read_lock_guard read_lock;
}
/* Rotate the data channels. */
- cds_lfht_for_each_entry (
- reg->registry->channels->ht, &iter.iter, buf_reg_chan, node.node) {
+ for (auto *buf_reg_chan :
+ lttng::urcu::lfht_iteration_adapter<buffer_reg_channel,
+ decltype(buffer_reg_channel::node),
+ &buffer_reg_channel::node>(
+ *reg->registry->channels->ht)) {
ret = consumer_rotate_channel(socket,
buf_reg_chan->consumer_key,
usess->consumer,
decltype(ust_app::pid_n),
&ust_app::pid_n>(*ust_app_ht->ht)) {
struct consumer_socket *socket;
- struct lttng_ht_iter chan_iter;
- struct ust_app_channel *ua_chan;
struct ust_app_session *ua_sess;
lsu::registry_session *registry;
bool app_reference_taken;
LTTNG_ASSERT(registry);
/* Rotate the data channels. */
- cds_lfht_for_each_entry (
- ua_sess->channels->ht, &chan_iter.iter, ua_chan, node.node) {
+ for (auto *ua_chan :
+ lttng::urcu::lfht_iteration_adapter<ust_app_channel,
+ decltype(ust_app_channel::node),
+ &ust_app_channel::node>(
+ *ua_sess->channels->ht)) {
ret = consumer_rotate_channel(socket,
ua_chan->key,
ua_sess->consumer,