ret = LTTNG_ERR_SESSION_FAIL;
goto error;
}
- if (strncmp(opt_session_name, DEFAULT_SESSION_NAME,
+ /*
+ * Check if the session name begins with "auto-" or is exactly "auto".
+ * Both are reserved for the default session name. See bug #449 to
+ * understand why we need to check both here.
+ */
+ if ((strncmp(opt_session_name, DEFAULT_SESSION_NAME "-",
+ strlen(DEFAULT_SESSION_NAME) + 1) == 0) ||
+ (strncmp(opt_session_name, DEFAULT_SESSION_NAME,
strlen(DEFAULT_SESSION_NAME)) == 0 &&
- strlen(opt_session_name) == strlen(DEFAULT_SESSION_NAME)) {
+ strlen(opt_session_name) == strlen(DEFAULT_SESSION_NAME))) {
ERR("%s is a reserved keyword for default session(s)",
DEFAULT_SESSION_NAME);
ret = CMD_ERROR;
} else if (opt_url) { /* Handling URL (-U opt) */
url = opt_url;
print_str_url = url;
- } else if (opt_ctrl_url == NULL && opt_data_url == NULL) {
+ } else {
/* Auto output path */
alloc_path = config_get_default_path();
if (alloc_path == NULL) {
}
url = alloc_url;
- print_str_url = alloc_url + strlen("file://");
+ if (!opt_data_url && !opt_ctrl_url) {
+ print_str_url = alloc_url + strlen("file://");
+ }
}
- assert(url);
+ if ((!opt_ctrl_url && opt_data_url) || (opt_ctrl_url && !opt_data_url)) {
+ ERR("You need both control and data URL.");
+ ret = CMD_ERROR;
+ goto error;
+ }
ret = _lttng_create_session_ext(session_name, url, datetime);
if (ret < 0) {
WARN("Session %s already exists", session_name);
break;
default:
- ERR("%s", lttng_strerror(ret));
break;
}
goto error;
}
- MSG("Session %s created.", session_name);
- if (print_str_url) {
- MSG("Traces will be written in %s", print_str_url);
- }
-
if (opt_ctrl_url && opt_data_url) {
/* Setting up control URI (-C or/and -D opt) */
ret = set_consumer_url(session_name, opt_ctrl_url, opt_data_url);
if (ret < 0) {
+ /* Destroy created session because the URL are not valid. */
+ lttng_destroy_session(session_name);
goto error;
}
- } else if ((!opt_ctrl_url && opt_data_url) ||
- (opt_ctrl_url && !opt_data_url)) {
- ERR("You need both control and data URL.");
- ret = CMD_ERROR;
- goto error;
+ }
+
+ MSG("Session %s created.", session_name);
+ if (print_str_url) {
+ MSG("Traces will be written in %s", print_str_url);
}
/* Init lttng session config */
goto error;
}
-
ret = CMD_SUCCESS;
error: