X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fconfig%2Fconfig.c;h=e61791b7d03b01eafad109b66f319421bb1f7e16;hb=0f0a81b5a7ec4416774fb49ece29a8483ecdade4;hp=088d5b55a1b7e7c926f9ee4c0e1444a41b94ac38;hpb=4af16958eb0d60aacd7cd82d7034d0f658e00f9d;p=lttng-tools.git diff --git a/src/common/config/config.c b/src/common/config/config.c index 088d5b55a..e61791b7d 100644 --- a/src/common/config/config.c +++ b/src/common/config/config.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -1187,9 +1186,6 @@ int create_session(const char *name, xmlNodePtr consumer_output_node; assert(name); - assert(kernel_domain); - assert(ust_domain); - assert(jul_domain); if (output_node) { consumer_output_node = xmlFirstElementChild(output_node); @@ -1226,11 +1222,12 @@ int create_session(const char *name, /* network destination */ if (live_timer_interval && live_timer_interval != UINT64_MAX) { - const char *url = output.control_uri ? - output.control_uri : output.data_uri; - - /* URL has to be provided, even if we'll overwrite it after. */ - ret = lttng_create_session_live(name, url, live_timer_interval); + /* + * URLs are provided for sure since the test above make sure that + * with a live timer the data and control URIs are provided. So, + * NULL is passed here and will be set right after. + */ + ret = lttng_create_session_live(name, NULL, live_timer_interval); } else { ret = lttng_create_session(name, NULL); } @@ -2176,7 +2173,7 @@ int process_session_node(xmlNodePtr session_node, const char *session_name, if (session_name && strcmp(name, session_name)) { /* This is not the session we are looking for */ - ret = -LTTNG_ERR_LOAD_SESSION_NOT_FOUND; + ret = -LTTNG_ERR_LOAD_SESSION_NOENT; goto end; } @@ -2328,7 +2325,7 @@ int load_session_from_file(const char *path, const char *session_name, end: xmlFreeDoc(doc); if (!ret) { - ret = session_found ? 0 : -LTTNG_ERR_LOAD_SESSION_NOT_FOUND; + ret = session_found ? 0 : -LTTNG_ERR_LOAD_SESSION_NOENT; } return ret; } @@ -2345,7 +2342,14 @@ int load_session_from_path(const char *path, const char *session_name, directory = opendir(path); if (!directory) { - if (errno != ENOTDIR) { + switch (errno) { + case ENOTDIR: + /* Try the file loading. */ + break; + case ENOENT: + ret = -LTTNG_ERR_LOAD_SESSION_NOENT; + goto end; + default: ret = -LTTNG_ERR_LOAD_IO_FAIL; goto end; } @@ -2430,7 +2434,7 @@ end: } if (!session_found) { - ret = -LTTNG_ERR_LOAD_SESSION_NOT_FOUND; + ret = -LTTNG_ERR_LOAD_SESSION_NOENT; } return ret; @@ -2460,9 +2464,10 @@ int config_load_session(const char *path, const char *session_name, goto end; } - ret = load_session_from_path(path, NULL, + ret = load_session_from_path(path, session_name, &validation_ctx, 0); - if (ret && ret != -LTTNG_ERR_LOAD_SESSION_NOENT) { + if (!ret || (ret && ret != -LTTNG_ERR_LOAD_SESSION_NOENT)) { + /* Session found or an error occured */ free(path); goto end; } @@ -2471,9 +2476,10 @@ int config_load_session(const char *path, const char *session_name, } /* Try system session configuration path */ - ret = load_session_from_path(DEFAULT_SESSION_SYSTEM_CONFIGPATH, NULL, - &validation_ctx, 0); - if (ret && ret != -LTTNG_ERR_LOAD_SESSION_NOENT) { + ret = load_session_from_path(DEFAULT_SESSION_SYSTEM_CONFIGPATH, + session_name, &validation_ctx, 0); + if (!ret || (ret && ret != -LTTNG_ERR_LOAD_SESSION_NOENT)) { + /* Session found or an error occured */ goto end; } } else {