*
*/
-#include "action-executor.h"
-#include "cmd.h"
-#include "health-sessiond.h"
-#include "lttng-sessiond.h"
-#include "notification-thread-internal.h"
-#include "session.h"
-#include "thread.h"
-#include <common/dynamic-array.h>
-#include <common/macros.h>
-#include <common/optional.h>
-#include <lttng/action/action-internal.h>
-#include <lttng/action/list-internal.h>
+#include "action-executor.hpp"
+#include "cmd.hpp"
+#include "health-sessiond.hpp"
+#include "lttng-sessiond.hpp"
+#include "notification-thread-internal.hpp"
+#include "session.hpp"
+#include "thread.hpp"
+#include <common/dynamic-array.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/action/list-internal.hpp>
#include <lttng/action/list.h>
-#include <lttng/action/notify-internal.h>
+#include <lttng/action/notify-internal.hpp>
#include <lttng/action/notify.h>
#include <lttng/action/rotate-session.h>
#include <lttng/action/snapshot-session.h>
#include <lttng/action/start-session.h>
#include <lttng/action/stop-session.h>
#include <lttng/condition/evaluation.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/lttng-error.h>
-#include <lttng/trigger/trigger-internal.h>
+#include <lttng/trigger/trigger-internal.hpp>
#include <pthread.h>
#include <stdbool.h>
#include <stddef.h>
#define THREAD_NAME "Action Executor"
#define MAX_QUEUED_WORK_COUNT 8192
+struct action_executor {
+ struct lttng_thread *thread;
+ struct notification_thread_handle *notification_thread_handle;
+ struct {
+ uint64_t pending_count;
+ struct cds_list_head list;
+ pthread_cond_t cond;
+ pthread_mutex_t lock;
+ } work;
+ bool should_quit;
+ uint64_t next_work_item_id;
+};
+
+namespace {
/*
* A work item is composed of a dynamic array of sub-items which
* represent a flattened, and augmented, version of a trigger's actions.
* trigger object at the moment of execution, if the trigger is found to be
* unregistered, the execution is skipped.
*/
-
struct action_work_item {
uint64_t id;
LTTNG_OPTIONAL(uint64_t) session_id;
} context;
};
+} /* namespace */
-struct action_executor {
- struct lttng_thread *thread;
- struct notification_thread_handle *notification_thread_handle;
- struct {
- uint64_t pending_count;
- struct cds_list_head list;
- pthread_cond_t cond;
- pthread_mutex_t lock;
- } work;
- bool should_quit;
- uint64_t next_work_item_id;
-};
/*
* Only return non-zero on a fatal error that should shut down the action
case CLIENT_TRANSMISSION_STATUS_COMPLETE:
DBG("Successfully sent full notification to client, client_id = %" PRIu64,
client->id);
+ /*
+ * There is no need to wake the (e)poll thread. If it was waiting for
+ * "out" events on the client's socket, it will see that no payload
+ * in queued and will unsubscribe from that event.
+ *
+ * In the other cases, we have to wake the the (e)poll thread to either
+ * handle the error on the client or to get it to monitor the client "out"
+ * events.
+ */
update_communication = false;
break;
case CLIENT_TRANSMISSION_STATUS_QUEUED:
struct action_executor *action_executor_create(
struct notification_thread_handle *handle)
{
- struct action_executor *executor = (action_executor *) zmalloc(sizeof(*executor));
+ struct action_executor *executor = zmalloc<action_executor>();
if (!executor) {
goto end;
goto error_unlock;
}
- work_item = (action_work_item *) zmalloc(sizeof(*work_item));
+ work_item = zmalloc<action_work_item>();
if (!work_item) {
PERROR("Failed to allocate action executor work item: trigger name = `%s`",
get_trigger_name(trigger));