Add app context support to lttng client
[lttng-tools.git] / src / bin / lttng-sessiond / context.c
index cd4b85f2a9d576ff828617075e1f305120d69659..ffd6e3ad50f3d3702da54903c6b7afc703360494 100644 (file)
@@ -15,7 +15,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#define _GNU_SOURCE
 #define _LGPL_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
@@ -88,7 +87,8 @@ error:
 /*
  * Add UST context to channel.
  */
-static int add_uctx_to_channel(struct ltt_ust_session *usess, int domain,
+static int add_uctx_to_channel(struct ltt_ust_session *usess,
+               enum lttng_domain_type domain,
                struct ltt_ust_channel *uchan, struct lttng_event_context *ctx)
 {
        int ret;
@@ -97,6 +97,7 @@ static int add_uctx_to_channel(struct ltt_ust_session *usess, int domain,
        assert(usess);
        assert(uchan);
        assert(ctx);
+       assert(domain == LTTNG_DOMAIN_UST);
 
        /* Check if context is duplicate */
        cds_list_for_each_entry(uctx, &uchan->ctx_list, list) {
@@ -113,15 +114,8 @@ static int add_uctx_to_channel(struct ltt_ust_session *usess, int domain,
                goto error;
        }
 
-       switch (domain) {
-       case LTTNG_DOMAIN_UST:
-               ret = ust_app_add_ctx_channel_glb(usess, uchan, uctx);
-               if (ret < 0) {
-                       goto error;
-               }
-               break;
-       default:
-               ret = -ENOSYS;
+       ret = ust_app_add_ctx_channel_glb(usess, uchan, uctx);
+       if (ret < 0) {
                goto error;
        }
 
@@ -240,8 +234,9 @@ error:
 /*
  * Add UST context to tracer.
  */
-int context_ust_add(struct ltt_ust_session *usess, int domain,
-               struct lttng_event_context *ctx, char *channel_name)
+int context_ust_add(struct ltt_ust_session *usess,
+               enum lttng_domain_type domain, struct lttng_event_context *ctx,
+               char *channel_name)
 {
        int ret = LTTNG_OK;
        struct lttng_ht_iter iter;
@@ -251,26 +246,11 @@ int context_ust_add(struct ltt_ust_session *usess, int domain,
        assert(usess);
        assert(ctx);
        assert(channel_name);
+       assert(domain == LTTNG_DOMAIN_UST);
 
        rcu_read_lock();
 
-       /*
-        * Define which channel's hashtable to use from the domain or quit if
-        * unknown domain.
-        */
-       switch (domain) {
-       case LTTNG_DOMAIN_UST:
-               chan_ht = usess->domain_global.channels;
-               break;
-#if 0
-       case LTTNG_DOMAIN_UST_EXEC_NAME:
-       case LTTNG_DOMAIN_UST_PID:
-       case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
-#endif
-       default:
-               ret = LTTNG_ERR_UND;
-               goto error;
-       }
+       chan_ht = usess->domain_global.channels;
 
        /* Get UST channel if defined */
        if (channel_name[0] != '\0') {
@@ -290,7 +270,8 @@ int context_ust_add(struct ltt_ust_session *usess, int domain,
                cds_lfht_for_each_entry(chan_ht->ht, &iter.iter, uchan, node.node) {
                        ret = add_uctx_to_channel(usess, domain, uchan, ctx);
                        if (ret < 0) {
-                               ERR("Context failed for channel %s", uchan->name);
+                               ERR("Failed to add context to channel %s",
+                                               uchan->name);
                                continue;
                        }
                }
This page took 0.023886 seconds and 4 git commands to generate.