Add CPU hotplug support
[lttng-tools.git] / ltt-sessiond / session.c
index a4101d2ee8fed3076364b8283504345669c78681..92111ffed981cc5f2593bc0770efc8c5f8e893aa 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 #include <urcu/list.h>
 
 #include "lttngerr.h"
@@ -82,35 +83,6 @@ static void del_session_list(struct ltt_session *ls)
        }
 }
 
-/*
- *     find_session_by_uuid
- *
- *     Return a ltt_session structure ptr that matches the uuid.
- */
-struct ltt_session *find_session_by_uuid(uuid_t session_id)
-{
-       int found = 0;
-       struct ltt_session *iter;
-
-       /* Sanity check for NULL session_id */
-       if (uuid_is_null(session_id)) {
-               goto end;
-       }
-
-       cds_list_for_each_entry(iter, &ltt_session_list.head, list) {
-               if (uuid_compare(iter->uuid, session_id) == 0) {
-                       found = 1;
-                       break;
-               }
-       }
-
-end:
-       if (!found) {
-               iter = NULL;
-       }
-       return iter;
-}
-
 /*
  *     find_session_by_name
  *
@@ -171,9 +143,10 @@ int destroy_session(char *name)
 int create_session(char *name, char *path)
 {
        int ret;
+       char date_time[NAME_MAX];
        struct ltt_session *new_session;
-
-       DBG("Creating session %s at %s", name, path);
+       time_t rawtime;
+       struct tm *timeinfo;
 
        new_session = find_session_by_name(name);
        if (new_session != NULL) {
@@ -203,7 +176,15 @@ int create_session(char *name, char *path)
 
        /* Define session system path */
        if (path != NULL) {
-               if (asprintf(&new_session->path, "%s", path) < 0) {
+               if (strstr(name, "auto-") == NULL) {
+                       time(&rawtime);
+                       timeinfo = localtime(&rawtime);
+                       strftime(date_time, sizeof(date_time), "-%Y%m%d-%H%M%S", timeinfo);
+               } else {
+                       date_time[0] = '\0';
+               }
+
+               if (asprintf(&new_session->path, "%s/%s%s", path, name, date_time) < 0) {
                        ret = -ENOMEM;
                        goto error_asprintf;
                }
@@ -213,9 +194,6 @@ int create_session(char *name, char *path)
                goto error;
        }
 
-       /* UUID generation */
-       uuid_generate(new_session->uuid);
-
        /*
         * Set consumer (identifier) to 0. This means that there is
         * NO consumer attach to that session yet.
@@ -224,7 +202,6 @@ int create_session(char *name, char *path)
 
        /* Init kernel session */
        new_session->kernel_session = NULL;
-       new_session->kern_session_count = 0;
 
        /* Init list */
        CDS_INIT_LIST_HEAD(&new_session->ust_traces);
@@ -235,6 +212,8 @@ int create_session(char *name, char *path)
        /* Add new session to the global session list */
        add_session_list(new_session);
 
+       DBG("Tracing session %s created in %s", name, new_session->path);
+
        return 0;
 
 error:
This page took 0.02429 seconds and 4 git commands to generate.