Fix: remove unused path variables from session obj
authorDavid Goulet <dgoulet@efficios.com>
Fri, 12 Apr 2013 15:13:42 +0000 (11:13 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 12 Apr 2013 15:13:42 +0000 (11:13 -0400)
Furthermore, this patch also removes useless '/' in the stream path
which was creating duplicates in the trace file path.

Fixes #496

Signed-off-by: David Goulet <dgoulet@efficios.com>
16 files changed:
src/bin/lttng-sessiond/channel.c
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/kernel-consumer.c
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/main.c
src/bin/lttng-sessiond/session.c
src/bin/lttng-sessiond/session.h
src/bin/lttng-sessiond/trace-kernel.c
src/bin/lttng-sessiond/trace-kernel.h
src/bin/lttng-sessiond/trace-ust.c
src/bin/lttng-sessiond/trace-ust.h
src/bin/lttng-sessiond/ust-app.c
src/bin/lttng-sessiond/ust-consumer.c
tests/unit/test_kernel_data.c
tests/unit/test_session.c
tests/unit/test_ust_data.c

index bb5b3d1de32cc00c19cba668a060d26982dc774f..db653dcb4f2901bd397fd22a3947f6499e8460bf 100644 (file)
@@ -293,7 +293,7 @@ int channel_ust_create(struct ltt_ust_session *usess,
        }
 
        /* Create UST channel */
-       uchan = trace_ust_create_channel(attr, usess->pathname);
+       uchan = trace_ust_create_channel(attr);
        if (uchan == NULL) {
                ret = LTTNG_ERR_FATAL;
                goto error;
index 7819002d04472b3f67cfd2501f3f87deb0cf251c..4fcd6a4feafdf2eae0b1e4393dd69ecfd6716d5e 100644 (file)
@@ -1667,7 +1667,6 @@ int cmd_create_session_uri(char *name, struct lttng_uri *uris,
                size_t nb_uri, lttng_sock_cred *creds)
 {
        int ret;
-       char *path = NULL;
        struct ltt_session *session;
 
        assert(name);
@@ -1692,7 +1691,7 @@ int cmd_create_session_uri(char *name, struct lttng_uri *uris,
        }
 
        /* Create tracing session in the registry */
-       ret = session_create(name, path, LTTNG_SOCK_GET_UID_CRED(creds),
+       ret = session_create(name, LTTNG_SOCK_GET_UID_CRED(creds),
                        LTTNG_SOCK_GET_GID_CRED(creds));
        if (ret != LTTNG_OK) {
                goto session_error;
@@ -2066,9 +2065,9 @@ void cmd_list_lttng_sessions(struct lttng_session *sessions, uid_t uid,
                                (ksess && ksess->consumer->type == CONSUMER_DST_NET) ||
                                (usess && usess->consumer->type == CONSUMER_DST_NET)) {
                        ret = build_network_session_path(sessions[i].path,
-                                       sizeof(session[i].path), session);
+                                       sizeof(sessions[i].path), session);
                } else {
-                       ret = snprintf(sessions[i].path, sizeof(session[i].path), "%s",
+                       ret = snprintf(sessions[i].path, sizeof(sessions[i].path), "%s",
                                        session->consumer->dst.trace_path);
                }
                if (ret < 0) {
index 05e30e49cb0b9ff65e88534ae9cec25de2222693..f30c11ccc2fa2be882e77218220b5da7b746ed10 100644 (file)
@@ -54,7 +54,7 @@ int kernel_consumer_add_channel(struct consumer_socket *sock,
        /* Get the right path name destination */
        if (consumer->type == CONSUMER_DST_LOCAL) {
                /* Set application path to the destination path */
-               ret = snprintf(tmp_path, sizeof(tmp_path), "%s/%s",
+               ret = snprintf(tmp_path, sizeof(tmp_path), "%s%s",
                                consumer->dst.trace_path, consumer->subdir);
                if (ret < 0) {
                        PERROR("snprintf metadata path");
@@ -136,7 +136,7 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock,
        /* Get the right path name destination */
        if (consumer->type == CONSUMER_DST_LOCAL) {
                /* Set application path to the destination path */
-               ret = snprintf(tmp_path, sizeof(tmp_path), "%s/%s",
+               ret = snprintf(tmp_path, sizeof(tmp_path), "%s%s",
                                consumer->dst.trace_path, consumer->subdir);
                if (ret < 0) {
                        PERROR("snprintf metadata path");
index 95194113243dcf4dbf426e0dfaac19b192cd46ba..856d4231004b02c558ea32f7cc86a7e315734331 100644 (file)
@@ -81,7 +81,7 @@ int kernel_create_session(struct ltt_session *session, int tracer_fd)
        assert(session);
 
        /* Allocate data structure */
-       lks = trace_kernel_create_session(session->path);
+       lks = trace_kernel_create_session();
        if (lks == NULL) {
                ret = -1;
                goto error;
index 15bb7255a882dab71abe546e9d8e95bc631f92ea..f6a051aa1cb52f8080cc9b2209a71044f052e860 100644 (file)
@@ -2238,7 +2238,7 @@ static int create_ust_session(struct ltt_session *session,
 
        DBG("Creating UST session");
 
-       lus = trace_ust_create_session(session->path, session->id);
+       lus = trace_ust_create_session(session->id);
        if (lus == NULL) {
                ret = LTTNG_ERR_UST_SESS_FAIL;
                goto error;
index 076d2cbc46ea9243dbe636350d01592e6d40a880..17dc3544dbe55a4dac884b5af9f178e2f1c44991 100644 (file)
@@ -168,7 +168,7 @@ int session_destroy(struct ltt_session *session)
 /*
  * Create a brand new session and add it to the session list.
  */
-int session_create(char *name, char *path, uid_t uid, gid_t gid)
+int session_create(char *name, uid_t uid, gid_t gid)
 {
        int ret;
        struct ltt_session *new_session;
@@ -193,14 +193,6 @@ int session_create(char *name, char *path, uid_t uid, gid_t gid)
                goto error;
        }
 
-       /* Define session system path */
-       if (path != NULL) {
-               if (snprintf(new_session->path, PATH_MAX, "%s", path) < 0) {
-                       ret = LTTNG_ERR_FATAL;
-                       goto error_asprintf;
-               }
-       }
-
        /* Init kernel session */
        new_session->kernel_session = NULL;
        new_session->ust_session = NULL;
@@ -211,19 +203,6 @@ int session_create(char *name, char *path, uid_t uid, gid_t gid)
        new_session->uid = uid;
        new_session->gid = gid;
 
-       /* Mkdir if we have a valid path and length */
-       if (strlen(new_session->path) > 0) {
-               ret = run_as_mkdir_recursive(new_session->path, S_IRWXU | S_IRWXG,
-                               new_session->uid, new_session->gid);
-               if (ret < 0) {
-                       if (ret != -EEXIST) {
-                               ERR("Trace directory creation error");
-                               ret = LTTNG_ERR_CREATE_DIR_FAIL;
-                               goto error;
-                       }
-               }
-       }
-
        /* Add new session to the session list */
        session_lock_list();
        new_session->id = add_session_list(new_session);
@@ -234,8 +213,8 @@ int session_create(char *name, char *path, uid_t uid, gid_t gid)
         * up and, if valid, assign it to the session.
         */
 
-       DBG("Tracing session %s created in %s with ID %u by UID %d GID %d", name,
-                       path, new_session->id, new_session->uid, new_session->gid);
+       DBG("Tracing session %s created with ID %u by UID %d GID %d", name,
+                       new_session->id, new_session->uid, new_session->gid);
 
        return LTTNG_OK;
 
index fd23ab05ed90bb422779446d7dd3961bc862f1da..a0b24b2d70259af1afc4067518ffcf78b9fb094d 100644 (file)
@@ -56,7 +56,6 @@ struct ltt_session_list {
  */
 struct ltt_session {
        char name[NAME_MAX];
-       char path[PATH_MAX];
        struct ltt_kernel_session *kernel_session;
        struct ltt_ust_session *ust_session;
        /*
@@ -89,7 +88,7 @@ struct ltt_session {
 };
 
 /* Prototypes */
-int session_create(char *name, char *path, uid_t uid, gid_t gid);
+int session_create(char *name, uid_t uid, gid_t gid);
 int session_destroy(struct ltt_session *session);
 
 void session_lock(struct ltt_session *session);
index 6a17776aa4fc10a8337c1aa9ea3383515d9f480a..afb578cfde886754321d7a1c16c9d9d2ce89ec6b 100644 (file)
@@ -77,7 +77,7 @@ struct ltt_kernel_event *trace_kernel_get_event_by_name(
  *
  * Return pointer to structure or NULL.
  */
-struct ltt_kernel_session *trace_kernel_create_session(char *path)
+struct ltt_kernel_session *trace_kernel_create_session(void)
 {
        struct ltt_kernel_session *lks = NULL;
 
@@ -109,25 +109,6 @@ struct ltt_kernel_session *trace_kernel_create_session(char *path)
         */
        lks->tmp_consumer = NULL;
 
-       if (*path != '\0') {
-               int ret;
-
-               /* Use the default consumer output which is the tracing session path. */
-               ret = snprintf(lks->consumer->dst.trace_path, PATH_MAX,
-                               "%s" DEFAULT_KERNEL_TRACE_DIR, path);
-               if (ret < 0) {
-                       PERROR("snprintf consumer trace path");
-                       goto error;
-               }
-
-               /* Set session path */
-               ret = asprintf(&lks->trace_path, "%s" DEFAULT_KERNEL_TRACE_DIR, path);
-               if (ret < 0) {
-                       PERROR("asprintf kernel traces path");
-                       goto error;
-               }
-       }
-
        return lks;
 
 error:
@@ -477,6 +458,5 @@ void trace_kernel_destroy_session(struct ltt_kernel_session *session)
        consumer_destroy_output(session->consumer);
        consumer_destroy_output(session->tmp_consumer);
 
-       free(session->trace_path);
        free(session);
 }
index 87807d989c12645946b03c4b9d01fb0feb7b42d5..d1f6e5f00a82b42ff177a7883a59ef4f29143c4e 100644 (file)
@@ -94,7 +94,6 @@ struct ltt_kernel_session {
        int consumer_fds_sent;
        unsigned int channel_count;
        unsigned int stream_count_global;
-       char *trace_path;
        struct ltt_kernel_metadata *metadata;
        struct ltt_kernel_channel_list channel_list;
        /* UID/GID of the user owning the session */
@@ -125,7 +124,7 @@ struct ltt_kernel_channel *trace_kernel_get_channel_by_name(
 /*
  * Create functions malloc() the data structure.
  */
-struct ltt_kernel_session *trace_kernel_create_session(char *path);
+struct ltt_kernel_session *trace_kernel_create_session(void);
 struct ltt_kernel_channel *trace_kernel_create_channel(
                struct lttng_channel *chan);
 struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev);
index cd8ff1053caa7c6163fe7686288d071e5dedafc0..0c97d37f1c86883474dc731c7d329638a4d47e8b 100644 (file)
@@ -180,8 +180,7 @@ error:
  *
  * Return pointer to structure or NULL.
  */
-struct ltt_ust_session *trace_ust_create_session(char *path,
-               unsigned int session_id)
+struct ltt_ust_session *trace_ust_create_session(unsigned int session_id)
 {
        struct ltt_ust_session *lus;
 
@@ -224,24 +223,10 @@ struct ltt_ust_session *trace_ust_create_session(char *path,
         */
        lus->tmp_consumer = NULL;
 
-       /* Use the default consumer output which is the tracing session path. */
-       if (*path != '\0') {
-               int ret;
-
-               ret = snprintf(lus->consumer->dst.trace_path, PATH_MAX,
-                               "%s" DEFAULT_UST_TRACE_DIR, path);
-               if (ret < 0) {
-                       PERROR("snprintf UST consumer trace path");
-                       goto error_path;
-               }
-       }
-
        DBG2("UST trace session create successful");
 
        return lus;
 
-error_path:
-       consumer_destroy_output(lus->consumer);
 error_consumer:
        lttng_ht_destroy(lus->domain_global.channels);
        free(lus);
@@ -254,13 +239,11 @@ error:
  *
  * Return pointer to structure or NULL.
  */
-struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan,
-               char *path)
+struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan)
 {
        struct ltt_ust_channel *luc;
 
        assert(chan);
-       assert(path);
 
        luc = zmalloc(sizeof(struct ltt_ust_channel));
        if (luc == NULL) {
index 92d6aaaf416d5af7c5c1f5184854c99d2c30fbf6..b21d8c2a712bad7e2622b033e2761651905d2182 100644 (file)
@@ -54,7 +54,6 @@ struct ltt_ust_channel {
        uint64_t id;    /* unique id per session. */
        unsigned int enabled;
        char name[LTTNG_UST_SYM_NAME_LEN];
-       char pathname[PATH_MAX];
        struct lttng_ust_channel_attr attr;
        struct lttng_ht *ctx;
        struct lttng_ht *events;
@@ -82,7 +81,6 @@ struct ltt_ust_domain_global {
 struct ltt_ust_session {
        int id;    /* Unique identifier of session */
        int start_trace;
-       char pathname[PATH_MAX];
        struct ltt_ust_domain_global domain_global;
        /* UID/GID of the user owning the session */
        uid_t uid;
@@ -155,10 +153,8 @@ struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
 /*
  * Create functions malloc() the data structure.
  */
-struct ltt_ust_session *trace_ust_create_session(char *path,
-               unsigned int session_id);
-struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
-               char *path);
+struct ltt_ust_session *trace_ust_create_session(unsigned int session_id);
+struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr);
 struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev,
                struct lttng_filter_bytecode *filter);
 struct ltt_ust_metadata *trace_ust_create_metadata(char *path);
@@ -194,14 +190,12 @@ struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
 }
 
 static inline
-struct ltt_ust_session *trace_ust_create_session(char *path,
-               unsigned int session_id)
+struct ltt_ust_session *trace_ust_create_session(unsigned int session_id)
 {
        return NULL;
 }
 static inline
-struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
-               char *path)
+struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr)
 {
        return NULL;
 }
index 8016d8ba5357512a07d38ac18485186d1798d20e..9bd622d87e80df2d50165ae00c5a54c2b8b70d4e 100644 (file)
@@ -1381,7 +1381,7 @@ static void shadow_copy_session(struct ust_app_session *ua_sess,
        switch (ua_sess->buffer_type) {
        case LTTNG_BUFFER_PER_PID:
                ret = snprintf(ua_sess->path, sizeof(ua_sess->path),
-                               DEFAULT_UST_TRACE_PID_PATH "/%s-%d-%s/", app->name, app->pid,
+                               DEFAULT_UST_TRACE_PID_PATH "/%s-%d-%s", app->name, app->pid,
                                datetime);
                break;
        case LTTNG_BUFFER_PER_UID:
index 93c1f713562b016f7147ba16e402dae18ce88e0d..ca96ff727bbd6705b84cc6f88c2e3826929bda9f 100644 (file)
@@ -61,7 +61,7 @@ static char *setup_trace_path(struct consumer_output *consumer,
        /* Get correct path name destination */
        if (consumer->type == CONSUMER_DST_LOCAL) {
                /* Set application path to the destination path */
-               ret = snprintf(pathname, PATH_MAX, "%s/%s/%s",
+               ret = snprintf(pathname, PATH_MAX, "%s%s%s",
                                consumer->dst.trace_path, consumer->subdir, ua_sess->path);
                if (ret < 0) {
                        PERROR("snprintf channel path");
@@ -78,7 +78,7 @@ static char *setup_trace_path(struct consumer_output *consumer,
                        }
                }
        } else {
-               ret = snprintf(pathname, PATH_MAX, "%s/%s", consumer->subdir,
+               ret = snprintf(pathname, PATH_MAX, "%s%s", consumer->subdir,
                                ua_sess->path);
                if (ret < 0) {
                        PERROR("snprintf channel path");
index f3687456424cd8af8ff88a99bf317b06c58c429a..0b4bb08c948c4ac375ef9765b94705aef5ccfa24 100644 (file)
@@ -30,9 +30,6 @@
 
 #include <tap/tap.h>
 
-/* This path will NEVER be created in this test */
-#define PATH1 "/tmp/.test-junk-lttng"
-
 #define RANDOM_STRING_LEN      11
 
 /* Number of TAP tests in this file */
@@ -72,7 +69,7 @@ static char *get_random_string(void)
 
 static void test_create_one_kernel_session(void)
 {
-       kern = trace_kernel_create_session(PATH1);
+       kern = trace_kernel_create_session();
        ok(kern != NULL, "Create kernel session");
 
        ok(kern->fd == -1 &&
index 61db187f1ccff351e93cee8c08297fcefac31639..8e1da214806d105975bc5853270a68444246da03 100644 (file)
 
 #define SESSION1 "test1"
 
-/* This path will NEVER be created in this test */
-#define PATH1 "/tmp/.test-junk-lttng"
-
 #define MAX_SESSIONS 10000
 #define RANDOM_STRING_LEN      11
 
 /* Number of TAP tests in this file */
-#define NUM_TESTS 12
+#define NUM_TESTS 11
 
 static struct ltt_session_list *session_list;
 
@@ -122,11 +119,11 @@ static void empty_session_list(void)
 /*
  * Test creation of 1 session
  */
-static int create_one_session(char *name, char *path)
+static int create_one_session(char *name)
 {
        int ret;
 
-       ret = session_create(name, path, geteuid(), getegid());
+       ret = session_create(name, geteuid(), getegid());
        if (ret == LTTNG_OK) {
                /* Validate */
                ret = find_session_name(name);
@@ -184,7 +181,7 @@ static int two_session_same_name(void)
        int ret;
        struct ltt_session *sess;
 
-       ret = create_one_session(SESSION1, PATH1);
+       ret = create_one_session(SESSION1);
        if (ret < 0) {
                /* Fail */
                return -1;
@@ -208,7 +205,7 @@ void test_session_list(void)
 
 void test_create_one_session(void)
 {
-       ok(create_one_session(SESSION1, PATH1) == 0,
+       ok(create_one_session(SESSION1) == 0,
           "Create session: %s",
           SESSION1);
 }
@@ -223,7 +220,6 @@ void test_validate_session(void)
           "Validating session: session found");
 
        ok(tmp->kernel_session == NULL &&
-          strlen(tmp->path) &&
           strlen(tmp->name),
           "Validating session: basic sanity check");
 
@@ -253,12 +249,8 @@ void test_duplicate_session(void)
 
 void test_bogus_session_param(void)
 {
-       ok(create_one_session(NULL, NULL) < 0,
-          "Create session with bogus param: NULL, NULL should fail");
-
-       ok(create_one_session(NULL, PATH1) < 0,
-          "Create session with bogus param: NULL, %s should fail",
-          PATH1);
+       ok(create_one_session(NULL) < 0,
+          "Create session with bogus param: NULL should fail");
 
        ok(session_list_count() == 0,
           "Create session with bogus param: session list empty");
@@ -271,7 +263,7 @@ void test_large_session_number(void)
 
        for (i = 0; i < MAX_SESSIONS; i++) {
                char *tmp_name = get_random_string();
-               ret = create_one_session(tmp_name, PATH1);
+               ret = create_one_session(tmp_name);
                if (ret < 0) {
                        diag("session %d (name: %s) creation failed", i, tmp_name);
                        ++failed;
index 294b5c58941d7ab8eee7ee4b2d34f33ae0ca9fa7..a79e2eb58129f643dd8880420577601dd8f73e5b 100644 (file)
@@ -80,7 +80,7 @@ static void test_create_one_ust_session(void)
 {
        dom.type = LTTNG_DOMAIN_UST;
 
-       usess = trace_ust_create_session(PATH1, 42);
+       usess = trace_ust_create_session(42);
        ok(usess != NULL, "Create UST session");
 
        ok(usess->id == 42 &&
@@ -129,7 +129,7 @@ static void test_create_ust_channel(void)
 
        strncpy(attr.name, "channel0", 8);
 
-       uchan = trace_ust_create_channel(&attr, PATH1);
+       uchan = trace_ust_create_channel(&attr);
        ok(uchan != NULL, "Create UST channel");
 
        ok(uchan->enabled == 0 &&
This page took 0.037223 seconds and 4 git commands to generate.