Fix: data reception is called event when only FDS are expected for reception
[lttng-tools.git] / src / bin / lttng-sessiond / notification-thread-events.c
index c9c21bc7225df72ee21ad8a74d33f101dd878aca..655400f9484c790af2116f1855203a806f562e2d 100644 (file)
@@ -1134,9 +1134,11 @@ int notification_thread_client_subscribe(struct notification_client *client,
         */
        CDS_INIT_LIST_HEAD(&condition_list_element->node);
        condition_list_element->condition = condition;
+       condition = NULL;
        cds_list_add(&condition_list_element->node, &client->condition_list);
 
-       client_list = get_client_list_from_condition(state, condition);
+       client_list = get_client_list_from_condition(
+                       state, condition_list_element->condition);
        if (!client_list) {
                /*
                 * No notification-emiting trigger registered with this
@@ -1160,7 +1162,7 @@ int notification_thread_client_subscribe(struct notification_client *client,
        pthread_mutex_lock(&client_list->lock);
        cds_list_for_each_entry(trigger_ht_element,
                        &client_list->triggers_list, client_list_trigger_node) {
-               if (evaluate_condition_for_client(trigger_ht_element->trigger, condition,
+               if (evaluate_condition_for_client(trigger_ht_element->trigger, condition_list_element->condition,
                                client, state)) {
                        WARN("[notification-thread] Evaluation of a condition on client subscription failed, aborting.");
                        ret = -1;
@@ -1189,10 +1191,12 @@ end:
        if (client_list) {
                notification_client_list_put(client_list);
        }
+       lttng_condition_destroy(condition);
        return ret;
 error:
        free(condition_list_element);
        free(client_list_element);
+       lttng_condition_destroy(condition);
        return ret;
 }
 
@@ -2487,7 +2491,7 @@ bool is_trigger_action_notify(const struct lttng_trigger *trigger)
        if (action_type == LTTNG_ACTION_TYPE_NOTIFY) {
                is_notify = true;
                goto end;
-       } else if (action_type != LTTNG_ACTION_TYPE_GROUP) {
+       } else if (action_type != LTTNG_ACTION_TYPE_LIST) {
                goto end;
        }
 
@@ -2603,7 +2607,7 @@ enum lttng_error_code setup_tracer_notifier(
                        trigger, &error_counter_index);
        if (error_accounting_status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
                if (error_accounting_status == EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NO_INDEX_AVAILABLE) {
-                       DBG("Trigger group error accounting counter full.");
+                       DBG("Trigger list error accounting counter full.");
                        ret = LTTNG_ERR_EVENT_NOTIFIER_ERROR_ACCOUNTING_FULL;
                } else {
                        ERR("Error registering trigger for error accounting");
@@ -3862,6 +3866,7 @@ int client_handle_message_subscription(
                goto end;
        }
 
+       /* Ownership of condition is always transferred. */
        if (msg_type == LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE) {
                ret = notification_thread_client_subscribe(
                                client, condition, state, &status);
@@ -3949,6 +3954,12 @@ int handle_notification_thread_client_in(
                goto end;
        }
 
+       if (client->communication.inbound.bytes_to_receive == 0 &&
+                       client->communication.inbound.fds_to_receive != 0) {
+               /* Only FDs left to receive. */
+               goto receive_fds;
+       }
+
        offset = client->communication.inbound.payload.buffer.size -
                        client->communication.inbound.bytes_to_receive;
        if (client->communication.inbound.expect_creds) {
@@ -3977,6 +3988,7 @@ int handle_notification_thread_client_in(
                goto end;
        }
 
+receive_fds:
        assert(client->communication.inbound.bytes_to_receive == 0);
 
        /* Receive fds. */
This page took 0.029139 seconds and 4 git commands to generate.