Generalize set_ust_event_filter to support multiple types of ust object
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.c
index 28313cb937acbe667266126352790086787687cb..8372a5dc51f61b89fa372e13688ccb152258f0c2 100644 (file)
@@ -1194,7 +1194,7 @@ error:
  * Return allocated filter or NULL on error.
  */
 static struct lttng_ust_filter_bytecode *create_ust_bytecode_from_bytecode(
-               struct lttng_filter_bytecode *orig_f)
+               const struct lttng_filter_bytecode *orig_f)
 {
        struct lttng_ust_filter_bytecode *filter = NULL;
 
@@ -1343,33 +1343,28 @@ error:
 /*
  * Set the filter on the tracer.
  */
-static
-int set_ust_event_filter(struct ust_app_event *ua_event,
-               struct ust_app *app)
+static int set_ust_object_filter(struct ust_app *app,
+               const struct lttng_filter_bytecode *bytecode,
+               struct lttng_ust_object_data *ust_object)
 {
        int ret;
        struct lttng_ust_filter_bytecode *ust_bytecode = NULL;
 
        health_code_update();
 
-       if (!ua_event->filter) {
-               ret = 0;
-               goto error;
-       }
-
-       ust_bytecode = create_ust_bytecode_from_bytecode(ua_event->filter);
+       ust_bytecode = create_ust_bytecode_from_bytecode(bytecode);
        if (!ust_bytecode) {
                ret = -LTTNG_ERR_NOMEM;
                goto error;
        }
        pthread_mutex_lock(&app->sock_lock);
        ret = ustctl_set_filter(app->sock, ust_bytecode,
-                       ua_event->obj);
+                       ust_object);
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
                if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
-                       ERR("UST app event %s filter failed for app (pid: %d) "
-                                       "with ret %d", ua_event->attr.name, app->pid, ret);
+                       ERR("UST app set object filter failed for object %p of app (pid: %d) "
+                                       "with ret %d", ust_object, app->pid, ret);
                } else {
                        /*
                         * This is normal behavior, an application can die during the
@@ -1377,12 +1372,12 @@ int set_ust_event_filter(struct ust_app_event *ua_event,
                         * continue normally.
                         */
                        ret = 0;
-                       DBG3("UST app filter event failed. Application is dead.");
+                       DBG3("Failed to set UST app object filter. Application is dead.");
                }
                goto error;
        }
 
-       DBG2("UST filter set successfully for event %s", ua_event->name);
+       DBG2("UST filter successfully set for object %p", ust_object);
 
 error:
        health_code_update();
@@ -1711,7 +1706,7 @@ int create_ust_event(struct ust_app *app, struct ust_app_session *ua_sess,
 
        /* Set filter if one is present. */
        if (ua_event->filter) {
-               ret = set_ust_event_filter(ua_event, app);
+               ret = set_ust_object_filter(app, ua_event->filter, ua_event->obj);
                if (ret < 0) {
                        goto error;
                }
@@ -4359,15 +4354,6 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app)
                goto skip_setup;
        }
 
-       /*
-        * Create the metadata for the application. This returns gracefully if a
-        * metadata was already set for the session.
-        */
-       ret = create_ust_app_metadata(ua_sess, app, usess->consumer);
-       if (ret < 0) {
-               goto error_unlock;
-       }
-
        health_code_update();
 
 skip_setup:
@@ -5035,6 +5021,7 @@ void ust_app_synchronize(struct ltt_ust_session *usess,
        }
 
        rcu_read_lock();
+
        cds_lfht_for_each_entry(usess->domain_global.channels->ht, &uchan_iter,
                        uchan, node.node) {
                struct ust_app_channel *ua_chan;
@@ -5078,6 +5065,21 @@ void ust_app_synchronize(struct ltt_ust_session *usess,
                        }
                }
        }
+
+       /*
+        * Create the metadata for the application. This returns gracefully if a
+        * metadata was already set for the session.
+        *
+        * The metadata channel must be created after the data channels as the
+        * consumer daemon assumes this ordering. When interacting with a relay
+        * daemon, the consumer will use this assumption to send the
+        * "STREAMS_SENT" message to the relay daemon.
+        */
+       ret = create_ust_app_metadata(ua_sess, app, usess->consumer);
+       if (ret < 0) {
+               goto error_unlock;
+       }
+
        rcu_read_unlock();
 
 end:
This page took 0.029182 seconds and 4 git commands to generate.