Generalize set_ust_event_exclusion to support multiple types of ust object
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 16 Dec 2019 21:01:03 +0000 (16:01 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 18 Dec 2020 21:32:23 +0000 (16:32 -0500)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ibe8f6b2c459afc698971b23b3f1a72d0a45e036f

src/bin/lttng-sessiond/ust-app.c

index 8372a5dc51f61b89fa372e13688ccb152258f0c2..8807aac261583e164d14cd98b7bf7ed26c2ab45e 100644 (file)
@@ -1387,7 +1387,7 @@ error:
 
 static
 struct lttng_ust_event_exclusion *create_ust_exclusion_from_exclusion(
 
 static
 struct lttng_ust_event_exclusion *create_ust_exclusion_from_exclusion(
-               struct lttng_event_exclusion *exclusion)
+               const struct lttng_event_exclusion *exclusion)
 {
        struct lttng_ust_event_exclusion *ust_exclusion = NULL;
        size_t exclusion_alloc_size = sizeof(struct lttng_ust_event_exclusion) +
 {
        struct lttng_ust_event_exclusion *ust_exclusion = NULL;
        size_t exclusion_alloc_size = sizeof(struct lttng_ust_event_exclusion) +
@@ -1409,33 +1409,30 @@ end:
 /*
  * Set event exclusions on the tracer.
  */
 /*
  * Set event exclusions on the tracer.
  */
-static
-int set_ust_event_exclusion(struct ust_app_event *ua_event,
-               struct ust_app *app)
+static int set_ust_object_exclusions(struct ust_app *app,
+               const struct lttng_event_exclusion *exclusions,
+               struct lttng_ust_object_data *ust_object)
 {
        int ret;
 {
        int ret;
-       struct lttng_ust_event_exclusion *ust_exclusion = NULL;
+       struct lttng_ust_event_exclusion *ust_exclusions = NULL;
 
 
-       health_code_update();
+       assert(exclusions && exclusions->count > 0);
 
 
-       if (!ua_event->exclusion || !ua_event->exclusion->count) {
-               ret = 0;
-               goto error;
-       }
+       health_code_update();
 
 
-       ust_exclusion = create_ust_exclusion_from_exclusion(
-                       ua_event->exclusion);
-       if (!ust_exclusion) {
+       ust_exclusions = create_ust_exclusion_from_exclusion(
+                       exclusions);
+       if (!ust_exclusions) {
                ret = -LTTNG_ERR_NOMEM;
                goto error;
        }
        pthread_mutex_lock(&app->sock_lock);
                ret = -LTTNG_ERR_NOMEM;
                goto error;
        }
        pthread_mutex_lock(&app->sock_lock);
-       ret = ustctl_set_exclusion(app->sock, ust_exclusion, ua_event->obj);
+       ret = ustctl_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) {
        pthread_mutex_unlock(&app->sock_lock);
        if (ret < 0) {
                if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
-                       ERR("UST app event %s exclusions failed for app (pid: %d) "
-                                       "with ret %d", ua_event->attr.name, app->pid, ret);
+                       ERR("Failed to set UST app exclusions 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
                } else {
                        /*
                         * This is normal behavior, an application can die during the
@@ -1443,16 +1440,16 @@ int set_ust_event_exclusion(struct ust_app_event *ua_event,
                         * continue normally.
                         */
                        ret = 0;
                         * continue normally.
                         */
                        ret = 0;
-                       DBG3("UST app event exclusion failed. Application is dead.");
+                       DBG3("Failed to set UST app object exclusions. Application is dead.");
                }
                goto error;
        }
 
                }
                goto error;
        }
 
-       DBG2("UST exclusion set successfully for event %s", ua_event->name);
+       DBG2("UST exclusions set successfully for object %p", ust_object);
 
 error:
        health_code_update();
 
 error:
        health_code_update();
-       free(ust_exclusion);
+       free(ust_exclusions);
        return ret;
 }
 
        return ret;
 }
 
@@ -1714,7 +1711,7 @@ int create_ust_event(struct ust_app *app, struct ust_app_session *ua_sess,
 
        /* Set exclusions for the event */
        if (ua_event->exclusion) {
 
        /* Set exclusions for the event */
        if (ua_event->exclusion) {
-               ret = set_ust_event_exclusion(ua_event, app);
+               ret = set_ust_object_exclusions(app, ua_event->exclusion, ua_event->obj);
                if (ret < 0) {
                        goto error;
                }
                if (ret < 0) {
                        goto error;
                }
This page took 0.029797 seconds and 4 git commands to generate.