#include <common/dynamic-array.hpp>
#include <common/macros.hpp>
#include <common/optional.hpp>
+#include <common/urcu.hpp>
#include <lttng/action/action-internal.hpp>
#include <lttng/action/list-internal.hpp>
* Only return non-zero on a fatal error that should shut down the action
* executor.
*/
-typedef int (*action_executor_handler)(struct action_executor *executor,
- const struct action_work_item *,
- struct action_work_subitem *item);
+using action_executor_handler = int (*)(struct action_executor *,
+ const struct action_work_item *,
+ struct action_work_subitem *);
static int action_executor_notify_handler(struct action_executor *executor,
const struct action_work_item *,
work_item->client_list,
work_item->trigger,
work_item->evaluation,
- work_item->object_creds.is_set ? &(work_item->object_creds.value) : NULL,
+ work_item->object_creds.is_set ? &(work_item->object_creds.value) : nullptr,
client_handle_transmission_status,
executor);
}
enum lttng_error_code cmd_ret;
struct lttng_action *action = item->action;
+ lttng::urcu::read_lock_guard read_lock;
+
action_status = lttng_action_start_session_get_session_name(action, &session_name);
if (action_status != LTTNG_ACTION_STATUS_OK) {
ERR("Failed to get session name from `%s` action", get_action_name(action));
}
session_lock_list();
- rcu_read_lock();
session = session_find_by_id(LTTNG_OPTIONAL_GET(item->context.session_id));
if (!session) {
DBG("Failed to find session `%s` by name while executing `%s` action of trigger `%s`",
session_unlock(session);
session_put(session);
error_unlock_list:
- rcu_read_unlock();
session_unlock_list();
end:
return ret;
enum lttng_error_code cmd_ret;
struct lttng_action *action = item->action;
+ lttng::urcu::read_lock_guard read_lock;
+
action_status = lttng_action_stop_session_get_session_name(action, &session_name);
if (action_status != LTTNG_ACTION_STATUS_OK) {
ERR("Failed to get session name from `%s` action", get_action_name(action));
}
session_lock_list();
- rcu_read_lock();
session = session_find_by_id(LTTNG_OPTIONAL_GET(item->context.session_id));
if (!session) {
DBG("Failed to find session `%s` by name while executing `%s` action of trigger `%s`",
session_unlock(session);
session_put(session);
error_unlock_list:
- rcu_read_unlock();
session_unlock_list();
end:
return ret;
enum lttng_error_code cmd_ret;
struct lttng_action *action = item->action;
+ lttng::urcu::read_lock_guard read_lock;
+
action_status = lttng_action_rotate_session_get_session_name(action, &session_name);
if (action_status != LTTNG_ACTION_STATUS_OK) {
ERR("Failed to get session name from `%s` action", get_action_name(action));
}
session_lock_list();
- rcu_read_lock();
session = session_find_by_id(LTTNG_OPTIONAL_GET(item->context.session_id));
if (!session) {
DBG("Failed to find session `%s` by name while executing `%s` action of trigger `%s`",
}
cmd_ret = (lttng_error_code) cmd_rotate_session(
- session, NULL, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
+ session, nullptr, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
switch (cmd_ret) {
case LTTNG_OK:
DBG("Successfully started rotation of session `%s` on behalf of trigger `%s`",
session_unlock(session);
session_put(session);
error_unlock_list:
- rcu_read_unlock();
session_unlock_list();
end:
return ret;
default_snapshot_output.max_size = UINT64_MAX;
+ lttng::urcu::read_lock_guard read_lock;
+
/*
* Validate if, at the moment the action was queued, the target session
* existed. If not, skip the action altogether.
}
session_lock_list();
- rcu_read_lock();
session = session_find_by_id(LTTNG_OPTIONAL_GET(item->context.session_id));
if (!session) {
DBG("Failed to find session `%s` by name while executing `%s` action of trigger `%s`",
session_unlock(session);
session_put(session);
error_unlock_list:
- rcu_read_unlock();
session_unlock_list();
end:
return ret;
/* Execute item only if a trigger is registered. */
lttng_trigger_lock(work_item->trigger);
if (!lttng_trigger_is_registered(work_item->trigger)) {
- const char *trigger_name = NULL;
+ const char *trigger_name = nullptr;
uid_t trigger_owner_uid;
enum lttng_trigger_status trigger_status;
rcu_unregister_thread();
health_unregister(the_health_sessiond);
- return NULL;
+ return nullptr;
}
static bool shutdown_action_executor_thread(void *_data)
}
CDS_INIT_LIST_HEAD(&executor->work.list);
- pthread_cond_init(&executor->work.cond, NULL);
- pthread_mutex_init(&executor->work.lock, NULL);
+ pthread_cond_init(&executor->work.cond, nullptr);
+ pthread_mutex_init(&executor->work.lock, nullptr);
executor->notification_thread_handle = handle;
executor->thread = lttng_thread_create(THREAD_NAME,
/* Ownership transferred to the work item. */
work_item->evaluation = evaluation;
- evaluation = NULL;
+ evaluation = nullptr;
work_item->client_list = client_list;
work_item->object_creds.is_set = !!object_creds;
{
int ret = 0;
enum lttng_action_type type = lttng_action_get_type(action);
- const char *session_name = NULL;
+ const char *session_name = nullptr;
enum lttng_action_status status;
struct action_work_subitem subitem = {
- .action = NULL,
+ .action = nullptr,
.context = {
.session_id = LTTNG_OPTIONAL_INIT_UNSET,
},
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
for (i = 0; i < count; i++) {
- struct lttng_action *inner_action = NULL;
+ struct lttng_action *inner_action = nullptr;
inner_action = lttng_action_list_borrow_mutable_at_index(action, i);
LTTNG_ASSERT(inner_action);
* now we leave the decision to skip to the action executor for sake of
* simplicity and consistency.
*/
- if (session_name != NULL) {
+ if (session_name != nullptr) {
uint64_t session_id;
/*