goto error;
}
+ 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("Copying base path: %s", uris[i].subdir);
+ goto error;
+ }
+ DBG2("Setting base path for session %" PRIu64 ": %s",
+ session->id, session->base_path);
+ }
+
/* 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;
}
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) {
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;
}
* Session list lock must be held by the caller.
*/
enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid,
- const char *base_path, struct ltt_session **out_session)
+ struct ltt_session **out_session)
{
int ret;
enum lttng_error_code ret_code;
}
}
- if (base_path) {
- new_session->base_path = strdup(base_path);
- if (!new_session->base_path) {
- ERR("Failed to allocate base path of session \"%s\"",
- name);
- ret_code = LTTNG_ERR_SESSION_FAIL;
- goto error;
- }
- }
-
new_session->uid = uid;
new_session->gid = gid;
/* Prototypes */
enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid,
- const char *base_path, struct ltt_session **out_session);
+ struct ltt_session **out_session);
void session_lock(struct ltt_session *session);
void session_lock_list(void);
int session_trylock_list(void);
struct ltt_session *session = NULL;
session_lock_list();
- ret_code = session_create(name, geteuid(), getegid(), NULL, &session);
+ ret_code = session_create(name, geteuid(), getegid(), &session);
session_put(session);
if (ret_code == LTTNG_OK) {
/* Validate */
const char *expected_session_name_prefix = DEFAULT_SESSION_NAME;
session_lock_list();
- ret_code = session_create(NULL, geteuid(), getegid(), NULL, &session);
+ ret_code = session_create(NULL, geteuid(), getegid(), &session);
ok(ret_code == LTTNG_OK,
"Create session with a NULL name (auto-generate a name)");
if (!session) {