static void init_notification_thread_command(struct notification_thread_command *cmd)
{
CDS_INIT_LIST_HEAD(&cmd->cmd_list_node);
- lttng_waiter_init(&cmd->reply_waiter);
}
static int run_command_wait(struct notification_thread_handle *handle,
int ret;
uint64_t notification_counter = 1;
+ lttng::synchro::waiter command_completion_waiter;
+ cmd->command_completed_waker.emplace(command_completion_waiter.get_waker());
+
pthread_mutex_lock(&handle->cmd_queue.lock);
/* Add to queue. */
cds_list_add_tail(&cmd->cmd_list_node, &handle->cmd_queue.list);
}
pthread_mutex_unlock(&handle->cmd_queue.lock);
- lttng_waiter_wait(&cmd->reply_waiter);
+ command_completion_waiter.wait();;
return 0;
error_unlock_queue:
pthread_mutex_unlock(&handle->cmd_queue.lock);
{
struct notification_thread_command *new_cmd;
- new_cmd = zmalloc<notification_thread_command>();
- if (!new_cmd) {
- goto end;
+ try {
+ new_cmd = new notification_thread_command;
+ } catch (const std::bad_alloc &e) {
+ ERR("Failed to allocate notification_thread_command: %s", e.what());
+ return nullptr;
}
*new_cmd = *original_cmd;
init_notification_thread_command(new_cmd);
-end:
return new_cmd;
}
cds_list_del(&new_cmd->cmd_list_node);
goto error_unlock_queue;
}
+
pthread_mutex_unlock(&handle->cmd_queue.lock);
return 0;
error_unlock_queue:
- free(new_cmd);
+
+ delete new_cmd;
pthread_mutex_unlock(&handle->cmd_queue.lock);
error:
return -1;
{
int ret;
enum lttng_error_code ret_code;
- struct notification_thread_command cmd = {};
+ notification_thread_command cmd;
LTTNG_ASSERT(trigger);
init_notification_thread_command(&cmd);
{
int ret;
enum lttng_error_code ret_code;
- struct notification_thread_command cmd = {};
+ notification_thread_command cmd;
init_notification_thread_command(&cmd);
{
int ret;
enum lttng_error_code ret_code;
- struct notification_thread_command cmd = {};
+ notification_thread_command cmd;
init_notification_thread_command(&cmd);
{
int ret;
enum lttng_error_code ret_code;
- struct notification_thread_command cmd = {};
+ notification_thread_command cmd;
init_notification_thread_command(&cmd);
{
int ret;
enum lttng_error_code ret_code;
- struct notification_thread_command cmd = {};
+ notification_thread_command cmd;
init_notification_thread_command(&cmd);
{
int ret;
enum lttng_error_code ret_code;
- struct notification_thread_command cmd = {};
+ notification_thread_command cmd;
init_notification_thread_command(&cmd);
{
int ret;
enum lttng_error_code ret_code;
- struct notification_thread_command cmd = {};
+ notification_thread_command cmd;
init_notification_thread_command(&cmd);
{
int ret;
enum lttng_error_code ret_code;
- struct notification_thread_command cmd = {};
+ notification_thread_command cmd;
init_notification_thread_command(&cmd);
{
int ret;
enum lttng_error_code ret_code;
- struct notification_thread_command cmd = {};
+ notification_thread_command cmd;
LTTNG_ASSERT(tracer_event_source_fd >= 0);
{
int ret;
enum lttng_error_code ret_code;
- struct notification_thread_command cmd = {};
+ notification_thread_command cmd;
init_notification_thread_command(&cmd);
{
int ret;
enum lttng_error_code ret_code;
- struct notification_thread_command cmd = {};
+ notification_thread_command cmd;
LTTNG_ASSERT(handle);
LTTNG_ASSERT(triggers);
void notification_thread_command_quit(struct notification_thread_handle *handle)
{
int ret;
- struct notification_thread_command cmd = {};
+ notification_thread_command cmd;
init_notification_thread_command(&cmd);
notification_client_id id,
enum client_transmission_status transmission_status)
{
- struct notification_thread_command cmd = {};
+ notification_thread_command cmd;
init_notification_thread_command(&cmd);
{
int ret;
enum lttng_error_code ret_code;
- struct notification_thread_command cmd = {};
+ notification_thread_command cmd;
init_notification_thread_command(&cmd);
struct lttng_event_notifier_notification *lttng_event_notifier_notification_create(
uint64_t tracer_token, enum lttng_domain_type domain, char *payload, size_t payload_size)
{
- struct lttng_event_notifier_notification *notification = NULL;
+ struct lttng_event_notifier_notification *notification = nullptr;
LTTNG_ASSERT(domain != LTTNG_DOMAIN_NONE);
LTTNG_ASSERT((payload && payload_size) || (!payload && !payload_size));
notification = zmalloc<lttng_event_notifier_notification>();
- if (notification == NULL) {
+ if (notification == nullptr) {
ERR("Error allocating notification");
goto end;
}