Fix: double mutex_unlock() if session is deleted
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.c
index eb5c5a2ead4f2c1652da68782e86c03fd06783c6..a1c681143c90be4afb71390270fb608dcef564e7 100644 (file)
@@ -27,7 +27,7 @@
 #include <common/hashtable/utils.h>
 #include <lttng/event-rule/event-rule.h>
 #include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/tracepoint.h>
+#include <lttng/event-rule/user-tracepoint.h>
 #include <lttng/condition/condition.h>
 #include <lttng/condition/event-rule-matches-internal.h>
 #include <lttng/condition/event-rule-matches.h>
@@ -93,7 +93,7 @@ static uint64_t get_next_session_id(void)
 }
 
 static void copy_channel_attr_to_ustctl(
-               struct ustctl_consumer_channel_attr *attr,
+               struct lttng_ust_ctl_consumer_channel_attr *attr,
                struct lttng_ust_abi_channel_attr *uattr)
 {
        /* Copy event attributes since the layout is different. */
@@ -290,7 +290,7 @@ void delete_ust_app_ctx(int sock, struct ust_app_ctx *ua_ctx,
 
        if (ua_ctx->obj) {
                pthread_mutex_lock(&app->sock_lock);
-               ret = ustctl_release_object(sock, ua_ctx->obj);
+               ret = lttng_ust_ctl_release_object(sock, ua_ctx->obj);
                pthread_mutex_unlock(&app->sock_lock);
                if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
                        ERR("UST app sock %d release ctx obj handle %d failed with ret %d",
@@ -318,7 +318,7 @@ void delete_ust_app_event(int sock, struct ust_app_event *ua_event,
                free(ua_event->exclusion);
        if (ua_event->obj != NULL) {
                pthread_mutex_lock(&app->sock_lock);
-               ret = ustctl_release_object(sock, ua_event->obj);
+               ret = lttng_ust_ctl_release_object(sock, ua_event->obj);
                pthread_mutex_unlock(&app->sock_lock);
                if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
                        ERR("UST app sock %d release event obj failed with ret %d",
@@ -359,7 +359,7 @@ static void delete_ust_app_event_notifier_rule(int sock,
 
        if (ua_event_notifier_rule->obj != NULL) {
                pthread_mutex_lock(&app->sock_lock);
-               ret = ustctl_release_object(sock, ua_event_notifier_rule->obj);
+               ret = lttng_ust_ctl_release_object(sock, ua_event_notifier_rule->obj);
                pthread_mutex_unlock(&app->sock_lock);
                if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
                        ERR("Failed to release event notifier object: app = '%s' (ppid %d), ret = %d",
@@ -388,7 +388,7 @@ static int release_ust_app_stream(int sock, struct ust_app_stream *stream,
 
        if (stream->obj) {
                pthread_mutex_lock(&app->sock_lock);
-               ret = ustctl_release_object(sock, stream->obj);
+               ret = lttng_ust_ctl_release_object(sock, stream->obj);
                pthread_mutex_unlock(&app->sock_lock);
                if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
                        ERR("UST app sock %d release stream obj failed with ret %d",
@@ -564,7 +564,7 @@ void delete_ust_app_channel(int sock, struct ust_app_channel *ua_chan,
                ret = lttng_ht_del(app->ust_objd, &iter);
                assert(!ret);
                pthread_mutex_lock(&app->sock_lock);
-               ret = ustctl_release_object(sock, ua_chan->obj);
+               ret = lttng_ust_ctl_release_object(sock, ua_chan->obj);
                pthread_mutex_unlock(&app->sock_lock);
                if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
                        ERR("UST app sock %d release channel obj failed with ret %d",
@@ -581,7 +581,7 @@ int ust_app_register_done(struct ust_app *app)
        int ret;
 
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_register_done(app->sock);
+       ret = lttng_ust_ctl_register_done(app->sock);
        pthread_mutex_unlock(&app->sock_lock);
        return ret;
 }
@@ -596,7 +596,7 @@ int ust_app_release_object(struct ust_app *app, struct lttng_ust_abi_object_data
        } else {
                sock = -1;
        }
-       ret = ustctl_release_object(sock, data);
+       ret = lttng_ust_ctl_release_object(sock, data);
        if (app) {
                pthread_mutex_unlock(&app->sock_lock);
        }
@@ -929,7 +929,7 @@ void delete_ust_app_session(int sock, struct ust_app_session *ua_sess,
 
        if (ua_sess->handle != -1) {
                pthread_mutex_lock(&app->sock_lock);
-               ret = ustctl_release_handle(sock, ua_sess->handle);
+               ret = lttng_ust_ctl_release_handle(sock, ua_sess->handle);
                pthread_mutex_unlock(&app->sock_lock);
                if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
                        ERR("UST app sock %d release session handle failed with ret %d",
@@ -1022,7 +1022,7 @@ void delete_ust_app(struct ust_app *app)
                        ERR("Error unregistering app from event notifier error accounting");
                }
 
-               ustctl_release_object(sock, app->event_notifier_group.object);
+               lttng_ust_ctl_release_object(sock, app->event_notifier_group.object);
                free(app->event_notifier_group.object);
        }
 
@@ -1165,7 +1165,7 @@ struct ust_app_channel *alloc_ust_app_channel(const char *name,
 
        /* Copy attributes */
        if (attr) {
-               /* Translate from lttng_ust_channel to ustctl_consumer_channel_attr. */
+               /* Translate from lttng_ust_channel to lttng_ust_ctl_consumer_channel_attr. */
                ua_chan->attr.subbuf_size = attr->subbuf_size;
                ua_chan->attr.num_subbuf = attr->num_subbuf;
                ua_chan->attr.overwrite = attr->overwrite;
@@ -1266,13 +1266,16 @@ static struct ust_app_event_notifier_rule *alloc_ust_app_event_notifier_rule(
 
        condition = lttng_trigger_get_condition(trigger);
        assert(condition);
-       assert(lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_ON_EVENT);
+       assert(lttng_condition_get_type(condition) ==
+                       LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
 
-       assert(LTTNG_CONDITION_STATUS_OK == lttng_condition_on_event_get_rule(condition, &event_rule));
+       assert(LTTNG_CONDITION_STATUS_OK ==
+                       lttng_condition_event_rule_matches_get_rule(
+                                       condition, &event_rule));
        assert(event_rule);
 
        ua_event_notifier_rule->error_counter_index =
-                       lttng_condition_on_event_get_error_counter_index(condition);
+                       lttng_condition_event_rule_matches_get_error_counter_index(condition);
        /* Acquire the event notifier's reference to the trigger. */
        lttng_trigger_get(trigger);
 
@@ -1518,7 +1521,7 @@ int create_ust_channel_context(struct ust_app_channel *ua_chan,
        health_code_update();
 
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_add_context(app->sock, &ua_ctx->ctx,
+       ret = lttng_ust_ctl_add_context(app->sock, &ua_ctx->ctx,
                        ua_chan->obj, &ua_ctx->obj);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
@@ -1565,7 +1568,7 @@ static int set_ust_object_filter(struct ust_app *app,
                goto error;
        }
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_set_filter(app->sock, ust_bytecode,
+       ret = lttng_ust_ctl_set_filter(app->sock, ust_bytecode,
                        ust_object);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
@@ -1619,7 +1622,7 @@ static int set_ust_capture(struct ust_app *app,
        ust_bytecode->seqnum = capture_seqnum;
 
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_set_capture(app->sock, ust_bytecode,
+       ret = lttng_ust_ctl_set_capture(app->sock, ust_bytecode,
                        ust_object);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
@@ -1689,7 +1692,7 @@ static int set_ust_object_exclusions(struct ust_app *app,
                goto error;
        }
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_set_exclusion(app->sock, ust_exclusions, ust_object);
+       ret = lttng_ust_ctl_set_exclusion(app->sock, ust_exclusions, ust_object);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
                if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
@@ -1726,7 +1729,7 @@ static int disable_ust_object(struct ust_app *app,
        health_code_update();
 
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_disable(app->sock, object);
+       ret = lttng_ust_ctl_disable(app->sock, object);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
                if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
@@ -1763,7 +1766,7 @@ static int disable_ust_channel(struct ust_app *app,
        health_code_update();
 
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_disable(app->sock, ua_chan->obj);
+       ret = lttng_ust_ctl_disable(app->sock, ua_chan->obj);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
                if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
@@ -1801,7 +1804,7 @@ static int enable_ust_channel(struct ust_app *app,
        health_code_update();
 
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_enable(app->sock, ua_chan->obj);
+       ret = lttng_ust_ctl_enable(app->sock, ua_chan->obj);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
                if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
@@ -1841,7 +1844,7 @@ static int enable_ust_object(
        health_code_update();
 
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_enable(app->sock, ust_object);
+       ret = lttng_ust_ctl_enable(app->sock, ust_object);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
                if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
@@ -1934,7 +1937,7 @@ int create_ust_event(struct ust_app *app, struct ust_app_session *ua_sess,
 
        /* Create UST event on tracer */
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_create_event(app->sock, &ua_event->attr, ua_chan->obj,
+       ret = lttng_ust_ctl_create_event(app->sock, &ua_event->attr, ua_chan->obj,
                        &ua_event->obj);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
@@ -2019,9 +2022,6 @@ static int init_ust_event_notifier_from_event_rule(
        int loglevel = -1, ret = 0;
        const char *pattern;
 
-       /* For now only LTTNG_EVENT_RULE_TYPE_TRACEPOINT are supported. */
-       assert(lttng_event_rule_get_type(rule) ==
-                       LTTNG_EVENT_RULE_TYPE_TRACEPOINT);
 
        memset(event_notifier, 0, sizeof(*event_notifier));
 
@@ -2039,13 +2039,16 @@ static int init_ust_event_notifier_from_event_rule(
        } else {
                const struct lttng_log_level_rule *log_level_rule;
 
-               status = lttng_event_rule_tracepoint_get_pattern(rule, &pattern);
+               assert(lttng_event_rule_get_type(rule) ==
+                               LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT);
+
+               status = lttng_event_rule_user_tracepoint_get_name_pattern(rule, &pattern);
                if (status != LTTNG_EVENT_RULE_STATUS_OK) {
                        /* At this point, this is a fatal error. */
                        abort();
                }
 
-               status = lttng_event_rule_tracepoint_get_log_level_rule(
+               status = lttng_event_rule_user_tracepoint_get_log_level_rule(
                                rule, &log_level_rule);
                if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
                        ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_ALL;
@@ -2103,6 +2106,7 @@ static int create_ust_event_notifier(struct ust_app *app,
        const struct lttng_event_rule *event_rule = NULL;
        unsigned int capture_bytecode_count = 0, i;
        enum lttng_condition_status cond_status;
+       enum lttng_event_rule_type event_rule_type;
 
        health_code_update();
        assert(app->event_notifier_group.object);
@@ -2110,14 +2114,22 @@ static int create_ust_event_notifier(struct ust_app *app,
        condition = lttng_trigger_get_const_condition(
                        ua_event_notifier_rule->trigger);
        assert(condition);
-       assert(lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_ON_EVENT);
+       assert(lttng_condition_get_type(condition) ==
+                       LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
 
-       condition_status = lttng_condition_on_event_get_rule(
+       condition_status = lttng_condition_event_rule_matches_get_rule(
                        condition, &event_rule);
        assert(condition_status == LTTNG_CONDITION_STATUS_OK);
 
        assert(event_rule);
-       assert(lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_TRACEPOINT);
+
+       event_rule_type = lttng_event_rule_get_type(event_rule);
+       assert(event_rule_type == LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT ||
+                       event_rule_type == LTTNG_EVENT_RULE_TYPE_JUL_LOGGING ||
+                       event_rule_type ==
+                                       LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING ||
+                       event_rule_type ==
+                                       LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING);
 
        init_ust_event_notifier_from_event_rule(event_rule, &event_notifier);
        event_notifier.event.token = ua_event_notifier_rule->token;
@@ -2125,7 +2137,7 @@ static int create_ust_event_notifier(struct ust_app *app,
 
        /* Create UST event notifier against the tracer. */
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_create_event_notifier(app->sock, &event_notifier,
+       ret = lttng_ust_ctl_create_event_notifier(app->sock, &event_notifier,
                        app->event_notifier_group.object,
                        &ua_event_notifier_rule->obj);
        pthread_mutex_unlock(&app->sock_lock);
@@ -2176,13 +2188,13 @@ static int create_ust_event_notifier(struct ust_app *app,
        }
 
        /* Set the capture bytecodes. */
-       cond_status = lttng_condition_on_event_get_capture_descriptor_count(
+       cond_status = lttng_condition_event_rule_matches_get_capture_descriptor_count(
                        condition, &capture_bytecode_count);
        assert(cond_status == LTTNG_CONDITION_STATUS_OK);
 
        for (i = 0; i < capture_bytecode_count; i++) {
                const struct lttng_bytecode *capture_bytecode =
-                               lttng_condition_on_event_get_capture_bytecode_at_index(
+                               lttng_condition_event_rule_matches_get_capture_bytecode_at_index(
                                                condition, i);
 
                ret = set_ust_capture(app, capture_bytecode, i,
@@ -2568,7 +2580,7 @@ error:
  * be NULL.
  *
  * Returns 0 on success or else a negative code which is either -ENOMEM or
- * -ENOTCONN which is the default code if the ustctl_create_session fails.
+ * -ENOTCONN which is the default code if the lttng_ust_ctl_create_session fails.
  */
 static int find_or_create_ust_app_session(struct ltt_ust_session *usess,
                struct ust_app *app, struct ust_app_session **ua_sess_ptr,
@@ -2624,7 +2636,7 @@ static int find_or_create_ust_app_session(struct ltt_ust_session *usess,
 
        if (ua_sess->handle == -1) {
                pthread_mutex_lock(&app->sock_lock);
-               ret = ustctl_create_session(app->sock);
+               ret = lttng_ust_ctl_create_session(app->sock);
                pthread_mutex_unlock(&app->sock_lock);
                if (ret < 0) {
                        if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
@@ -3009,7 +3021,7 @@ static int duplicate_stream_object(struct buffer_reg_stream *reg_stream,
        }
 
        /* Duplicate object for stream once the original is in the registry. */
-       ret = ustctl_duplicate_ust_object_data(&stream->obj,
+       ret = lttng_ust_ctl_duplicate_ust_object_data(&stream->obj,
                        reg_stream->obj.ust);
        if (ret < 0) {
                ERR("Duplicate stream obj from %p to %p failed with ret %d",
@@ -3045,7 +3057,7 @@ static int duplicate_channel_object(struct buffer_reg_channel *buf_reg_chan,
        }
 
        /* Duplicate object for stream once the original is in the registry. */
-       ret = ustctl_duplicate_ust_object_data(&ua_chan->obj, buf_reg_chan->obj.ust);
+       ret = lttng_ust_ctl_duplicate_ust_object_data(&ua_chan->obj, buf_reg_chan->obj.ust);
        if (ret < 0) {
                ERR("Duplicate channel obj from %p to %p failed with ret: %d",
                                buf_reg_chan->obj.ust, ua_chan->obj, ret);
@@ -3989,7 +4001,7 @@ int ust_app_version(struct ust_app *app)
        assert(app);
 
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_tracer_version(app->sock, &app->version);
+       ret = lttng_ust_ctl_tracer_version(app->sock, &app->version);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
                if (ret != -LTTNG_UST_ERR_EXITING && ret != -EPIPE) {
@@ -4002,6 +4014,16 @@ int ust_app_version(struct ust_app *app)
        return ret;
 }
 
+bool ust_app_supports_notifiers(const struct ust_app *app)
+{
+       return app->v_major >= 9;
+}
+
+bool ust_app_supports_counters(const struct ust_app *app)
+{
+       return app->v_major >= 9;
+}
+
 /*
  * Setup the base event notifier group.
  *
@@ -4018,12 +4040,17 @@ int ust_app_setup_event_notifier_group(struct ust_app *app)
 
        assert(app);
 
+       if (!ust_app_supports_notifiers(app)) {
+               ret = -ENOSYS;
+               goto error;
+       }
+
        /* Get the write side of the pipe. */
        event_pipe_write_fd = lttng_pipe_get_writefd(
                        app->event_notifier_group.event_pipe);
 
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_create_event_notifier_group(app->sock,
+       ret = lttng_ust_ctl_create_event_notifier_group(app->sock,
                        event_pipe_write_fd, &event_notifier_group);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
@@ -4065,15 +4092,22 @@ int ust_app_setup_event_notifier_group(struct ust_app *app)
        /* Assign handle only when the complete setup is valid. */
        app->event_notifier_group.object = event_notifier_group;
 
-       event_notifier_error_accounting_status = event_notifier_error_accounting_register_app(app);
-       if (event_notifier_error_accounting_status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
-               if (event_notifier_error_accounting_status == EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_APP_DEAD) {
-                       DBG3("Failed to setup event notifier error accounting (application is dead): app socket fd = %d",
-                                       app->sock);
-                       ret = 0;
-                       goto error_accounting;
-               }
-
+       event_notifier_error_accounting_status =
+                       event_notifier_error_accounting_register_app(app);
+       switch (event_notifier_error_accounting_status) {
+       case EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK:
+               break;
+       case EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_UNSUPPORTED:
+               DBG3("Failed to setup event notifier error accounting (application does not support notifier error accounting): app socket fd = %d, app name = '%s', app ppid = %d",
+                               app->sock, app->name, (int) app->ppid);
+               ret = 0;
+               goto error_accounting;
+       case EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_APP_DEAD:
+               DBG3("Failed to setup event notifier error accounting (application is dead): app socket fd = %d, app name = '%s', app ppid = %d",
+                               app->sock, app->name, (int) app->ppid);
+               ret = 0;
+               goto error_accounting;
+       default:
                ERR("Failed to setup event notifier error accounting for app");
                ret = -1;
                goto error_accounting;
@@ -4091,7 +4125,7 @@ error_accounting:
        }
 
 error:
-       ustctl_release_object(app->sock, app->event_notifier_group.object);
+       lttng_ust_ctl_release_object(app->sock, app->event_notifier_group.object);
        free(app->event_notifier_group.object);
        app->event_notifier_group.object = NULL;
        return ret;
@@ -4251,7 +4285,7 @@ int ust_app_list_events(struct lttng_event **events)
                        continue;
                }
                pthread_mutex_lock(&app->sock_lock);
-               handle = ustctl_tracepoint_list(app->sock);
+               handle = lttng_ust_ctl_tracepoint_list(app->sock);
                if (handle < 0) {
                        if (handle != -EPIPE && handle != -LTTNG_UST_ERR_EXITING) {
                                ERR("UST app list events getting handle failed for app pid %d",
@@ -4261,7 +4295,7 @@ int ust_app_list_events(struct lttng_event **events)
                        continue;
                }
 
-               while ((ret = ustctl_tracepoint_list_get(app->sock, handle,
+               while ((ret = lttng_ust_ctl_tracepoint_list_get(app->sock, handle,
                                        &uiter)) != -LTTNG_UST_ERR_NOENT) {
                        /* Handle ustctl error. */
                        if (ret < 0) {
@@ -4280,7 +4314,7 @@ int ust_app_list_events(struct lttng_event **events)
                                        break;
                                }
                                free(tmp_event);
-                               release_ret = ustctl_release_handle(app->sock, handle);
+                               release_ret = lttng_ust_ctl_release_handle(app->sock, handle);
                                if (release_ret < 0 &&
                                                release_ret != -LTTNG_UST_ERR_EXITING &&
                                                release_ret != -EPIPE) {
@@ -4307,7 +4341,7 @@ int ust_app_list_events(struct lttng_event **events)
                                        PERROR("realloc ust app events");
                                        free(tmp_event);
                                        ret = -ENOMEM;
-                                       release_ret = ustctl_release_handle(app->sock, handle);
+                                       release_ret = lttng_ust_ctl_release_handle(app->sock, handle);
                                        if (release_ret < 0 &&
                                                        release_ret != -LTTNG_UST_ERR_EXITING &&
                                                        release_ret != -EPIPE) {
@@ -4329,7 +4363,7 @@ int ust_app_list_events(struct lttng_event **events)
                        tmp_event[count].enabled = -1;
                        count++;
                }
-               ret = ustctl_release_handle(app->sock, handle);
+               ret = lttng_ust_ctl_release_handle(app->sock, handle);
                pthread_mutex_unlock(&app->sock_lock);
                if (ret < 0 && ret != -LTTNG_UST_ERR_EXITING && ret != -EPIPE) {
                        ERR("Error releasing app handle for app %d with ret %d", app->sock, ret);
@@ -4382,7 +4416,7 @@ int ust_app_list_event_fields(struct lttng_event_field **fields)
                        continue;
                }
                pthread_mutex_lock(&app->sock_lock);
-               handle = ustctl_tracepoint_field_list(app->sock);
+               handle = lttng_ust_ctl_tracepoint_field_list(app->sock);
                if (handle < 0) {
                        if (handle != -EPIPE && handle != -LTTNG_UST_ERR_EXITING) {
                                ERR("UST app list field getting handle failed for app pid %d",
@@ -4392,7 +4426,7 @@ int ust_app_list_event_fields(struct lttng_event_field **fields)
                        continue;
                }
 
-               while ((ret = ustctl_tracepoint_field_list_get(app->sock, handle,
+               while ((ret = lttng_ust_ctl_tracepoint_field_list_get(app->sock, handle,
                                        &uiter)) != -LTTNG_UST_ERR_NOENT) {
                        /* Handle ustctl error. */
                        if (ret < 0) {
@@ -4411,7 +4445,7 @@ int ust_app_list_event_fields(struct lttng_event_field **fields)
                                        break;
                                }
                                free(tmp_event);
-                               release_ret = ustctl_release_handle(app->sock, handle);
+                               release_ret = lttng_ust_ctl_release_handle(app->sock, handle);
                                pthread_mutex_unlock(&app->sock_lock);
                                if (release_ret < 0 &&
                                                release_ret != -LTTNG_UST_ERR_EXITING &&
@@ -4438,7 +4472,7 @@ int ust_app_list_event_fields(struct lttng_event_field **fields)
                                        PERROR("realloc ust app event fields");
                                        free(tmp_event);
                                        ret = -ENOMEM;
-                                       release_ret = ustctl_release_handle(app->sock, handle);
+                                       release_ret = lttng_ust_ctl_release_handle(app->sock, handle);
                                        pthread_mutex_unlock(&app->sock_lock);
                                        if (release_ret &&
                                                        release_ret != -LTTNG_UST_ERR_EXITING &&
@@ -4466,7 +4500,7 @@ int ust_app_list_event_fields(struct lttng_event_field **fields)
                        tmp_event[count].event.enabled = -1;
                        count++;
                }
-               ret = ustctl_release_handle(app->sock, handle);
+               ret = lttng_ust_ctl_release_handle(app->sock, handle);
                pthread_mutex_unlock(&app->sock_lock);
                if (ret < 0 &&
                                ret != -LTTNG_UST_ERR_EXITING &&
@@ -5009,7 +5043,7 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app)
 skip_setup:
        /* This starts the UST tracing */
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_start_session(app->sock, ua_sess->handle);
+       ret = lttng_ust_ctl_start_session(app->sock, ua_sess->handle);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
                if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
@@ -5038,7 +5072,7 @@ skip_setup:
 
        /* Quiescent wait after starting trace */
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_wait_quiescent(app->sock);
+       ret = lttng_ust_ctl_wait_quiescent(app->sock);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
                ERR("UST app wait quiescent failed for app pid %d ret %d",
@@ -5101,7 +5135,7 @@ int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app)
 
        /* This inhibits UST tracing */
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_stop_session(app->sock, ua_sess->handle);
+       ret = lttng_ust_ctl_stop_session(app->sock, ua_sess->handle);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
                if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
@@ -5124,7 +5158,7 @@ int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app)
 
        /* Quiescent wait after stopping trace */
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_wait_quiescent(app->sock);
+       ret = lttng_ust_ctl_wait_quiescent(app->sock);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
                ERR("UST app wait quiescent failed for app pid %d ret %d",
@@ -5474,7 +5508,7 @@ static int destroy_trace(struct ltt_ust_session *usess, struct ust_app *app)
 
        /* Quiescent wait after stopping trace */
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_wait_quiescent(app->sock);
+       ret = lttng_ust_ctl_wait_quiescent(app->sock);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
                ERR("UST app wait quiescent failed for app pid %d ret %d",
@@ -5650,6 +5684,10 @@ void ust_app_synchronize_event_notifier_rules(struct ust_app *app)
        struct ust_app_event_notifier_rule *event_notifier_rule;
        unsigned int count, i;
 
+       if (!ust_app_supports_notifiers(app)) {
+               goto end;
+       }
+
        /*
         * Currrently, registering or unregistering a trigger with an
         * event rule condition causes a full synchronization of the event
@@ -5671,7 +5709,6 @@ void ust_app_synchronize_event_notifier_rules(struct ust_app *app)
        ret_code = notification_thread_command_list_triggers(
                        the_notification_thread_handle, 0, &triggers);
        if (ret_code != LTTNG_OK) {
-               ret = -1;
                goto end;
        }
 
@@ -5679,7 +5716,6 @@ void ust_app_synchronize_event_notifier_rules(struct ust_app *app)
 
        t_status = lttng_triggers_get_count(triggers, &count);
        if (t_status != LTTNG_TRIGGER_STATUS_OK) {
-               ret = -1;
                goto end;
        }
 
@@ -5697,12 +5733,15 @@ void ust_app_synchronize_event_notifier_rules(struct ust_app *app)
                token = lttng_trigger_get_tracer_token(trigger);
                condition = lttng_trigger_get_condition(trigger);
 
-               if (lttng_condition_get_type(condition) != LTTNG_CONDITION_TYPE_ON_EVENT) {
+               if (lttng_condition_get_type(condition) !=
+                               LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES) {
                        /* Does not apply */
                        continue;
                }
 
-               condition_status = lttng_condition_on_event_borrow_rule_mutable(condition, &event_rule);
+               condition_status =
+                               lttng_condition_event_rule_matches_borrow_rule_mutable(
+                                               condition, &event_rule);
                assert(condition_status == LTTNG_CONDITION_STATUS_OK);
 
                if (lttng_event_rule_get_domain_type(event_rule) == LTTNG_DOMAIN_KERNEL) {
@@ -5870,7 +5909,6 @@ void ust_app_synchronize(struct ltt_ust_session *usess,
 
        pthread_mutex_lock(&ua_sess->lock);
        if (ua_sess->deleted) {
-               pthread_mutex_unlock(&ua_sess->lock);
                goto end;
        }
 
@@ -5968,7 +6006,7 @@ void ust_app_global_update_event_notifier_rules(struct ust_app *app)
        DBG2("UST application global event notifier rules update: app = '%s' (ppid: %d)",
                        app->name, app->ppid);
 
-       if (!app->compatible) {
+       if (!app->compatible || !ust_app_supports_notifiers(app)) {
                return;
        }
 
@@ -6077,7 +6115,7 @@ int ust_app_recv_registration(int sock, struct ust_register_msg *msg)
 
        assert(msg);
 
-       ret = ustctl_recv_reg_msg(sock, &msg->type, &msg->major, &msg->minor,
+       ret = lttng_ust_ctl_recv_reg_msg(sock, &msg->type, &msg->major, &msg->minor,
                        &pid, &ppid, &uid, &gid,
                        &msg->bits_per_long,
                        &msg->uint8_t_alignment,
@@ -6177,12 +6215,12 @@ error:
  * On success 0 is returned else a negative value.
  */
 static int reply_ust_register_channel(int sock, int cobjd,
-               size_t nr_fields, struct ustctl_field *fields)
+               size_t nr_fields, struct lttng_ust_ctl_field *fields)
 {
        int ret, ret_code = 0;
        uint32_t chan_id;
        uint64_t chan_reg_key;
-       enum ustctl_channel_header type;
+       enum lttng_ust_ctl_channel_header type;
        struct ust_app *app;
        struct ust_app_channel *ua_chan;
        struct ust_app_session *ua_sess;
@@ -6237,7 +6275,7 @@ static int reply_ust_register_channel(int sock, int cobjd,
                 * this channel to better guess header type for per-pid
                 * buffers.
                 */
-               type = USTCTL_CHANNEL_HEADER_LARGE;
+               type = LTTNG_UST_CTL_CHANNEL_HEADER_LARGE;
                ust_reg_chan->nr_ctx_fields = nr_fields;
                ust_reg_chan->ctx_fields = fields;
                fields = NULL;
@@ -6263,7 +6301,7 @@ reply:
                        " with id %u, type: %d, ret: %d", chan_reg_key, chan_id, type,
                        ret_code);
 
-       ret = ustctl_reply_register_channel(sock, chan_id, type, ret_code);
+       ret = lttng_ust_ctl_reply_register_channel(sock, chan_id, type, ret_code);
        if (ret < 0) {
                if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
                        ERR("UST app reply channel failed with ret %d", ret);
@@ -6294,7 +6332,7 @@ error_rcu_unlock:
  * On success 0 is returned else a negative value.
  */
 static int add_event_ust_registry(int sock, int sobjd, int cobjd, char *name,
-               char *sig, size_t nr_fields, struct ustctl_field *fields,
+               char *sig, size_t nr_fields, struct lttng_ust_ctl_field *fields,
                int loglevel_value, char *model_emf_uri)
 {
        int ret, ret_code;
@@ -6360,7 +6398,7 @@ static int add_event_ust_registry(int sock, int sobjd, int cobjd, char *name,
         * application can be notified. In case of an error, it's important not to
         * return a negative error or else the application will get closed.
         */
-       ret = ustctl_reply_register_event(sock, event_id, ret_code);
+       ret = lttng_ust_ctl_reply_register_event(sock, event_id, ret_code);
        if (ret < 0) {
                if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
                        ERR("UST app reply event failed with ret %d", ret);
@@ -6396,7 +6434,7 @@ error_rcu_unlock:
  * On success 0 is returned else a negative value.
  */
 static int add_enum_ust_registry(int sock, int sobjd, char *name,
-               struct ustctl_enum_entry *entries, size_t nr_entries)
+               struct lttng_ust_ctl_enum_entry *entries, size_t nr_entries)
 {
        int ret = 0, ret_code;
        struct ust_app *app;
@@ -6448,7 +6486,7 @@ static int add_enum_ust_registry(int sock, int sobjd, char *name,
         * application can be notified. In case of an error, it's important not to
         * return a negative error or else the application will get closed.
         */
-       ret = ustctl_reply_register_enum(sock, enum_id, ret_code);
+       ret = lttng_ust_ctl_reply_register_enum(sock, enum_id, ret_code);
        if (ret < 0) {
                if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
                        ERR("UST app reply enum failed with ret %d", ret);
@@ -6479,11 +6517,11 @@ error_rcu_unlock:
 int ust_app_recv_notify(int sock)
 {
        int ret;
-       enum ustctl_notify_cmd cmd;
+       enum lttng_ust_ctl_notify_cmd cmd;
 
        DBG3("UST app receiving notify from sock %d", sock);
 
-       ret = ustctl_recv_notify(sock, &cmd);
+       ret = lttng_ust_ctl_recv_notify(sock, &cmd);
        if (ret < 0) {
                if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
                        ERR("UST app recv notify failed with ret %d", ret);
@@ -6494,16 +6532,16 @@ int ust_app_recv_notify(int sock)
        }
 
        switch (cmd) {
-       case USTCTL_NOTIFY_CMD_EVENT:
+       case LTTNG_UST_CTL_NOTIFY_CMD_EVENT:
        {
                int sobjd, cobjd, loglevel_value;
                char name[LTTNG_UST_ABI_SYM_NAME_LEN], *sig, *model_emf_uri;
                size_t nr_fields;
-               struct ustctl_field *fields;
+               struct lttng_ust_ctl_field *fields;
 
                DBG2("UST app ustctl register event received");
 
-               ret = ustctl_recv_register_event(sock, &sobjd, &cobjd, name,
+               ret = lttng_ust_ctl_recv_register_event(sock, &sobjd, &cobjd, name,
                                &loglevel_value, &sig, &nr_fields, &fields,
                                &model_emf_uri);
                if (ret < 0) {
@@ -6529,15 +6567,15 @@ int ust_app_recv_notify(int sock)
 
                break;
        }
-       case USTCTL_NOTIFY_CMD_CHANNEL:
+       case LTTNG_UST_CTL_NOTIFY_CMD_CHANNEL:
        {
                int sobjd, cobjd;
                size_t nr_fields;
-               struct ustctl_field *fields;
+               struct lttng_ust_ctl_field *fields;
 
                DBG2("UST app ustctl register channel received");
 
-               ret = ustctl_recv_register_channel(sock, &sobjd, &cobjd, &nr_fields,
+               ret = lttng_ust_ctl_recv_register_channel(sock, &sobjd, &cobjd, &nr_fields,
                                &fields);
                if (ret < 0) {
                        if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
@@ -6561,16 +6599,16 @@ int ust_app_recv_notify(int sock)
 
                break;
        }
-       case USTCTL_NOTIFY_CMD_ENUM:
+       case LTTNG_UST_CTL_NOTIFY_CMD_ENUM:
        {
                int sobjd;
                char name[LTTNG_UST_ABI_SYM_NAME_LEN];
                size_t nr_entries;
-               struct ustctl_enum_entry *entries;
+               struct lttng_ust_ctl_enum_entry *entries;
 
                DBG2("UST app ustctl register enum received");
 
-               ret = ustctl_recv_register_enum(sock, &sobjd, name,
+               ret = lttng_ust_ctl_recv_register_enum(sock, &sobjd, name,
                                &entries, &nr_entries);
                if (ret < 0) {
                        if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
@@ -6736,7 +6774,7 @@ enum lttng_error_code ust_app_snapshot_record(
 
                        memset(pathname, 0, sizeof(pathname));
                        ret = snprintf(pathname, sizeof(pathname),
-                                       DEFAULT_UST_TRACE_DIR "/" DEFAULT_UST_TRACE_UID_PATH,
+                                       DEFAULT_UST_TRACE_UID_PATH,
                                        reg->uid, reg->bits_per_long);
                        if (ret < 0) {
                                PERROR("snprintf snapshot path");
@@ -6800,7 +6838,7 @@ enum lttng_error_code ust_app_snapshot_record(
 
                        /* Add the UST default trace dir to path. */
                        memset(pathname, 0, sizeof(pathname));
-                       ret = snprintf(pathname, sizeof(pathname), DEFAULT_UST_TRACE_DIR "/%s",
+                       ret = snprintf(pathname, sizeof(pathname), "%s",
                                        ua_sess->path);
                        if (ret < 0) {
                                status = LTTNG_ERR_INVALID;
@@ -7054,7 +7092,7 @@ int ust_app_regenerate_statedump(struct ltt_ust_session *usess,
        }
 
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_regenerate_statedump(app->sock, ua_sess->handle);
+       ret = lttng_ust_ctl_regenerate_statedump(app->sock, ua_sess->handle);
        pthread_mutex_unlock(&app->sock_lock);
 
 end_unlock:
This page took 0.050425 seconds and 5 git commands to generate.