* The actions to be executed with their respective execution context.
* See struct `action_work_subitem`.
*/
- struct lttng_dynamic_array *subitems;
+ struct lttng_dynamic_array subitems;
/* Execution context data */
struct lttng_trigger *trigger;
* existed. If not skip the action altogether.
*/
if (!item->context.session_id.is_set) {
- DBG("Session `%s` was not present at the moment the work item was enqueued for %s` action of trigger `%s`",
+ DBG("Session `%s` was not present at the moment the work item was enqueued for `%s` action of trigger `%s`",
session_name, get_action_name(action),
get_trigger_name(work_item->trigger));
lttng_action_increase_execution_failure_count(action);
if (session->id != LTTNG_OPTIONAL_GET(item->context.session_id)) {
DBG("Session id for session `%s` (id: %" PRIu64
" is not the same that was sampled (id: %" PRIu64
- " at the moment the work item was enqueued for %s` action of trigger `%s`",
+ " at the moment the work item was enqueued for `%s` action of trigger `%s`",
session_name, session->id,
LTTNG_OPTIONAL_GET(item->context.session_id),
get_action_name(action),
get_trigger_name(work_item->trigger));
ret = 0;
- goto error_unlock_list;
+ goto error_put_session;
}
session_lock(session);
if (!is_trigger_allowed_for_session(work_item->trigger, session)) {
- goto error_dispose_session;
+ goto error_unlock_session;
}
cmd_ret = cmd_start_trace(session);
break;
}
-error_dispose_session:
+error_unlock_session:
session_unlock(session);
+error_put_session:
session_put(session);
error_unlock_list:
session_unlock_list();
* existed. If not, skip the action altogether.
*/
if (!item->context.session_id.is_set) {
- DBG("Session `%s` was not present at the moment the work item was enqueued for %s` action of trigger `%s`",
+ DBG("Session `%s` was not present at the moment the work item was enqueued for `%s` action of trigger `%s`",
session_name, get_action_name(action),
get_trigger_name(work_item->trigger));
lttng_action_increase_execution_failure_count(action);
if (session->id != LTTNG_OPTIONAL_GET(item->context.session_id)) {
DBG("Session id for session `%s` (id: %" PRIu64
" is not the same that was sampled (id: %" PRIu64
- " at the moment the work item was enqueued for %s` action of trigger `%s`",
+ " at the moment the work item was enqueued for `%s` action of trigger `%s`",
session_name, session->id,
LTTNG_OPTIONAL_GET(item->context.session_id),
get_action_name(action),
get_trigger_name(work_item->trigger));
ret = 0;
- goto error_unlock_list;
+ goto error_put_session;
}
session_lock(session);
if (!is_trigger_allowed_for_session(work_item->trigger, session)) {
- goto error_dispose_session;
+ goto error_unlock_session;
}
cmd_ret = cmd_stop_trace(session);
break;
}
-error_dispose_session:
+error_unlock_session:
session_unlock(session);
+error_put_session:
session_put(session);
error_unlock_list:
session_unlock_list();
* existed. If not, skip the action altogether.
*/
if (!item->context.session_id.is_set) {
- DBG("Session `%s` was not present at the moment the work item was enqueued for %s` action of trigger `%s`",
+ DBG("Session `%s` was not present at the moment the work item was enqueued for `%s` action of trigger `%s`",
session_name, get_action_name(action),
get_trigger_name(work_item->trigger));
lttng_action_increase_execution_failure_count(action);
if (session->id != LTTNG_OPTIONAL_GET(item->context.session_id)) {
DBG("Session id for session `%s` (id: %" PRIu64
" is not the same that was sampled (id: %" PRIu64
- " at the moment the work item was enqueued for %s` action of trigger `%s`",
+ " at the moment the work item was enqueued for `%s` action of trigger `%s`",
session_name, session->id,
LTTNG_OPTIONAL_GET(item->context.session_id),
get_action_name(action),
get_trigger_name(work_item->trigger));
ret = 0;
- goto error_unlock_list;
+ goto error_put_session;
}
session_lock(session);
if (!is_trigger_allowed_for_session(work_item->trigger, session)) {
- goto error_dispose_session;
+ goto error_unlock_session;
}
cmd_ret = cmd_rotate_session(session, NULL, false,
break;
}
-error_dispose_session:
+error_unlock_session:
session_unlock(session);
+error_put_session:
session_put(session);
error_unlock_list:
session_unlock_list();
* existed. If not, skip the action altogether.
*/
if (!item->context.session_id.is_set) {
- DBG("Session was not present at the moment the work item was enqueued for %s` action of trigger `%s`",
+ DBG("Session was not present at the moment the work item was enqueued for `%s` action of trigger `%s`",
get_action_name(action),
get_trigger_name(work_item->trigger));
lttng_action_increase_execution_failure_count(action);
if (session->id != LTTNG_OPTIONAL_GET(item->context.session_id)) {
DBG("Session id for session `%s` (id: %" PRIu64
" is not the same that was sampled (id: %" PRIu64
- " at the moment the work item was enqueued for %s` action of trigger `%s`",
+ " at the moment the work item was enqueued for `%s` action of trigger `%s`",
session_name, session->id,
LTTNG_OPTIONAL_GET(item->context.session_id),
get_action_name(action),
get_trigger_name(work_item->trigger));
ret = 0;
- goto error_unlock_list;
+ goto error_put_session;
}
session_lock(session);
if (!is_trigger_allowed_for_session(work_item->trigger, session)) {
- goto error_dispose_session;
+ goto error_unlock_session;
}
cmd_ret = cmd_snapshot_record(session, snapshot_output, 0);
break;
}
-error_dispose_session:
+error_unlock_session:
session_unlock(session);
+error_put_session:
session_put(session);
error_unlock_list:
session_unlock_list();
DBG("Starting execution of action work item %" PRIu64 " of trigger `%s`",
work_item->id, get_trigger_name(work_item->trigger));
- count = lttng_dynamic_array_get_count(work_item->subitems);
+ count = lttng_dynamic_array_get_count(&work_item->subitems);
for (i = 0; i < count; i++) {
struct action_work_subitem *item;
- item = lttng_dynamic_array_get_element(work_item->subitems, i);
+ item = lttng_dynamic_array_get_element(&work_item->subitems, i);
ret = action_executor_generic_handler(
executor, work_item, item);
if (ret) {
lttng_trigger_put(work_item->trigger);
lttng_evaluation_destroy(work_item->evaluation);
notification_client_list_put(work_item->client_list);
- lttng_dynamic_array_reset(work_item->subitems);
+ lttng_dynamic_array_reset(&work_item->subitems);
free(work_item);
}
DBG("Entering work execution loop");
pthread_mutex_lock(&executor->work.lock);
while (!executor->should_quit) {
- int ret;
+ int ret = 0;
struct action_work_item *work_item;
health_code_update();
work_item->trigger, &trigger_owner_uid);
assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
- DBG("Work item skipped since the associated trigger is no longer registered: work item id = %" PRIu64 ", trigger name = '%s', trigger owner uid = %d",
+ DBG("Work item skipped since the associated trigger is no longer registered: work item id = %" PRIu64 ", trigger name = `%s`, trigger owner uid = %d",
work_item->id, trigger_name,
(int) trigger_owner_uid);
ret = 0;
const uint64_t work_item_id = executor->next_work_item_id++;
struct action_work_item *work_item;
bool signal = false;
- struct lttng_dynamic_array *subitems = NULL;
assert(trigger);
- /* Build the array of action work subitems for the passed trigger. */
- subitems = zmalloc(sizeof(*subitems));
- if (!subitems) {
- PERROR("Failed to allocate action executor subitems array: trigger name = `%s`",
- get_trigger_name(trigger));
- executor_status = ACTION_EXECUTOR_STATUS_ERROR;
- goto error_unlock;
- }
-
- lttng_dynamic_array_init(subitems, sizeof(struct action_work_subitem),
- action_work_subitem_destructor);
-
- ret = populate_subitem_array_from_trigger(trigger, subitems);
- if (ret) {
- ERR("Failed to populate work item sub items on behalf of trigger: trigger name = `%s`",
- get_trigger_name(trigger));
- executor_status = ACTION_EXECUTOR_STATUS_ERROR;
- goto error_unlock;
- }
-
pthread_mutex_lock(&executor->work.lock);
/* Check for queue overflow. */
if (executor->work.pending_count >= MAX_QUEUED_WORK_COUNT) {
work_item = zmalloc(sizeof(*work_item));
if (!work_item) {
- PERROR("Failed to allocate action executor work item: trigger name = '%s'",
+ PERROR("Failed to allocate action executor work item: trigger name = `%s`",
get_trigger_name(trigger));
executor_status = ACTION_EXECUTOR_STATUS_ERROR;
goto error_unlock;
*work_item = (typeof(*work_item)){
.id = work_item_id,
- /* Ownership transferred to the work item. */
- .subitems = subitems,
.trigger = trigger,
/* Ownership transferred to the work item. */
.evaluation = evaluation,
};
evaluation = NULL;
- subitems = NULL;
+
+ /* Build the array of action work subitems for the passed trigger. */
+ lttng_dynamic_array_init(&work_item->subitems,
+ sizeof(struct action_work_subitem),
+ action_work_subitem_destructor);
+
+ ret = populate_subitem_array_from_trigger(
+ trigger, &work_item->subitems);
+ if (ret) {
+ ERR("Failed to populate work item sub items on behalf of trigger: trigger name = `%s`",
+ get_trigger_name(trigger));
+ executor_status = ACTION_EXECUTOR_STATUS_ERROR;
+ goto error_unlock;
+ }
+
cds_list_add_tail(&work_item->list_node, &executor->work.list);
executor->work.pending_count++;
DBG("Enqueued action for trigger: trigger name = `%s`, work item id = %" PRIu64,
if (signal) {
pthread_cond_signal(&executor->work.cond);
}
- pthread_mutex_unlock(&executor->work.lock);
+ pthread_mutex_unlock(&executor->work.lock);
lttng_evaluation_destroy(evaluation);
- if (subitems) {
- lttng_dynamic_array_reset(subitems);
- free(subitems);
- }
return executor_status;
}
static int add_action_to_subitem_array(struct lttng_action *action,
struct lttng_dynamic_array *subitems)
{
- int ret;
+ int ret = 0;
enum lttng_action_type type = lttng_action_get_type(action);
const char *session_name = NULL;
enum lttng_action_status status;