X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fcreate.c;h=d66f0309e28de3613468fdd4f3ba06d4ccf51040;hb=0ab619061fcf5f38193da3b2839c7d0963b61ac9;hp=2c58075b4646cde144763ae30542608fa698eb4e;hpb=61b35a5aa71d4c0715f390a32cb4e967e817c81f;p=lttng-tools.git diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c index 2c58075b4..d66f0309e 100644 --- a/src/bin/lttng/commands/create.c +++ b/src/bin/lttng/commands/create.c @@ -112,7 +112,7 @@ static void usage(FILE *ofp) fprintf(ofp, " TCP for both control (PORT1) and data port (PORT2).\n"); fprintf(ofp, " The default ports are respectively 5342 and 5343.\n"); fprintf(ofp, "\n"); - fprintf(ofp, " > tcp[4|6]://...\n"); + fprintf(ofp, " > tcp[6]://...\n"); fprintf(ofp, " Can only be used with -C and -D together\n"); fprintf(ofp, "\n"); fprintf(ofp, "NOTE: IPv6 address MUST be enclosed in brackets '[]' (rfc2732)\n"); @@ -271,11 +271,7 @@ static int create_session(void) PERROR("snprintf session name"); goto error; } - session_name = strdup(DEFAULT_SESSION_NAME); - if (session_name == NULL) { - PERROR("strdup session name"); - goto error; - } + session_name = session_name_date; DBG("Auto session name set to %s", session_name_date); } else { if (strncmp(opt_session_name, DEFAULT_SESSION_NAME, @@ -353,14 +349,12 @@ static int create_session(void) goto error; } - if (opt_session_name == NULL) { - MSG("Session %s created.", session_name_date); - } else { - MSG("Session %s created.", session_name); + MSG("Session %s created.", session_name); + if (print_str_url) { + MSG("Traces will be written in %s", print_str_url); } - MSG("Traces will be written in %s", print_str_url); - if (opt_ctrl_url || opt_data_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) { @@ -371,6 +365,11 @@ static int create_session(void) if (ret < 0) { 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; } if (opt_disable_consumer && !opt_no_consumer) { @@ -380,11 +379,6 @@ static int create_session(void) } } - if (opt_session_name == NULL) { - free(session_name); - session_name = session_name_date; - } - /* Init lttng session config */ ret = config_init(session_name); if (ret < 0) { @@ -396,10 +390,6 @@ static int create_session(void) ret = CMD_SUCCESS; error: - if (opt_session_name == NULL && session_name != session_name_date) { - free(session_name); - } - if (alloc_url) { free(alloc_url); }