Fix: sessions with agent channels fail to load
[lttng-tools.git] / src / common / config / session-config.c
index 389d05427692210e5c483b8c62fb9ae465ee0d83..13f29eefdace3ea17832cdf9ca5cad7d87c54d31 100644 (file)
@@ -2105,6 +2105,31 @@ int process_channel_attr_node(xmlNodePtr attr_node,
                        ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
                        goto end;
                }
+       } else if (!strcmp((const char *) attr_node->name,
+                       config_element_blocking_timeout)) {
+               xmlChar *content;
+               int64_t blocking_timeout = 0;
+
+               /* blocking_timeout */
+               content = xmlNodeGetContent(attr_node);
+               if (!content) {
+                       ret = -LTTNG_ERR_NOMEM;
+                       goto end;
+               }
+
+               ret = parse_int(content, &blocking_timeout);
+               free(content);
+               if (ret) {
+                       ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
+                       goto end;
+               }
+
+               ret = lttng_channel_set_blocking_timeout(channel,
+                       blocking_timeout);
+               if (ret) {
+                       ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
+                       goto end;
+               }
        } else if (!strcmp((const char *) attr_node->name,
                        config_element_events)) {
                /* events */
@@ -2407,10 +2432,31 @@ int process_domain_node(xmlNodePtr domain_node, const char *session_name)
        /* create all channels */
        for (node = xmlFirstElementChild(channels_node); node;
                node = xmlNextElementSibling(node)) {
+               const enum lttng_domain_type original_domain = domain.type;
                xmlNodePtr contexts_node = NULL;
                xmlNodePtr events_node = NULL;
                xmlNodePtr channel_attr_node;
 
+               /*
+                * Channels of the "agent" types cannot be created directly.
+                * They are meant to be created implicitly through the
+                * activation of events in their domain. However, a user
+                * can override the default channel configuration attributes
+                * by creating the underlying UST channel _before_ enabling
+                * an agent domain event.
+                *
+                * Hence, the channel's type is substituted before the creation
+                * and restored by the time the events are created.
+                */
+               switch (domain.type) {
+               case LTTNG_DOMAIN_JUL:
+               case LTTNG_DOMAIN_LOG4J:
+               case LTTNG_DOMAIN_PYTHON:
+                       domain.type = LTTNG_DOMAIN_UST;
+               default:
+                       break;
+               }
+
                channel = lttng_channel_create(&domain);
                if (!channel) {
                        ret = -1;
@@ -2432,6 +2478,9 @@ int process_domain_node(xmlNodePtr domain_node, const char *session_name)
                        goto end;
                }
 
+               /* Restore the original channel domain. */
+               domain.type = original_domain;
+
                ret = process_events_node(events_node, handle, channel->name);
                if (ret) {
                        goto end;
@@ -2977,7 +3026,6 @@ static int validate_path_creds(const char *path)
                if (errno != ENOENT) {
                        PERROR("stat");
                }
-               ret = -LTTNG_ERR_INVALID;
                goto valid;
        }
 
This page took 0.025085 seconds and 4 git commands to generate.