X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.c;h=be493fd8a5527f7795446592016c44f47eaa6d09;hb=433f5ba9ca8e445c979b49703ac195f77a94c684;hp=71c0789b3421c5ff4ef9bfc0fa8de354b9104f61;hpb=3156892b9633c1fbee3ace6cc2b013e678343083;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 71c0789b3..be493fd8a 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -2739,6 +2739,45 @@ error: return ret; } +/* + * Set the base_path of the session only if subdir of a control uris is set. + * Return LTTNG_OK on success, otherwise LTTNG_ERR_*. + */ +static int set_session_base_path_from_uris(struct ltt_session *session, + size_t nb_uri, + struct lttng_uri *uris) +{ + int ret; + size_t i; + + for (i = 0; i < nb_uri; i++) { + if (uris[i].stype != LTTNG_STREAM_CONTROL || + uris[i].subdir[0] == '\0') { + /* Not interested in these URIs */ + continue; + } + + if (session->base_path != NULL) { + free(session->base_path); + session->base_path = NULL; + } + + /* Set session base_path */ + session->base_path = strdup(uris[i].subdir); + if (!session->base_path) { + PERROR("Failed to copy base path \"%s\" to session \"%s\"", + uris[i].subdir, session->name); + ret = LTTNG_ERR_NOMEM; + goto error; + } + DBG2("Setting base path \"%s\" for session \"%s\"", + session->base_path, session->name); + } + ret = LTTNG_OK; +error: + return ret; +} + /* * Command LTTNG_SET_CONSUMER_URI processed by the client thread. */ @@ -2759,11 +2798,20 @@ int cmd_set_consumer_uri(struct ltt_session *session, size_t nb_uri, goto error; } + /* + * Set the session base path if any. This is done inside + * cmd_set_consumer_uri to preserve backward compatibility of the + * previous session creation api vs the session descriptor api. + */ + ret = set_session_base_path_from_uris(session, nb_uri, uris); + if (ret != LTTNG_OK) { + goto error; + } + /* Set the "global" consumer URIs */ for (i = 0; i < nb_uri; i++) { - ret = add_uri_to_consumer(session, - session->consumer, - &uris[i], LTTNG_DOMAIN_NONE); + ret = add_uri_to_consumer(session, session->consumer, &uris[i], + LTTNG_DOMAIN_NONE); if (ret != LTTNG_OK) { goto error; } @@ -2894,7 +2942,6 @@ enum lttng_error_code cmd_create_session_from_descriptor( const char *session_name; struct ltt_session *new_session = NULL; enum lttng_session_descriptor_status descriptor_status; - const char *base_path; session_lock_list(); if (home_path) { @@ -2917,13 +2964,9 @@ enum lttng_error_code cmd_create_session_from_descriptor( ret_code = LTTNG_ERR_INVALID; goto end; } - ret = lttng_session_descriptor_get_base_path(descriptor, &base_path); - if (ret) { - ret_code = LTTNG_ERR_INVALID; - goto end; - } + ret_code = session_create(session_name, creds->uid, creds->gid, - base_path, &new_session); + &new_session); if (ret_code != LTTNG_OK) { goto end; } @@ -4983,7 +5026,7 @@ int cmd_rotate_get_info(struct ltt_session *session, switch (rotation_state) { case LTTNG_ROTATION_STATE_NO_ROTATION: - DBG("Reporting that no rotation has occured within the lifetime of session \"%s\"", + DBG("Reporting that no rotation has occurred within the lifetime of session \"%s\"", session->name); goto end; case LTTNG_ROTATION_STATE_EXPIRED: