Better debug and fix an error handling
[lttng-tools.git] / ltt-sessiond / main.c
index 29e05b9e9ed23cbcaf6b5c9b770caf1388a574b2..3f9d0eb5e4d55e97a5e6f2440e3b210597ae7c64 100644 (file)
@@ -214,7 +214,7 @@ static void cleanup(void)
        DBG("Cleaning up");
 
        /* <fun> */
-       MSG("\n%c[%d;%dm*** assert failed *** ==> %c[%dm%c[%d;%dm"
+       MSG("%c[%d;%dm*** assert failed *** ==> %c[%dm%c[%d;%dm"
                "Matthew, BEET driven development works!%c[%dm",
                27, 1, 31, 27, 0, 27, 1, 33, 27, 0);
        /* </fun> */
@@ -252,8 +252,10 @@ static void cleanup(void)
        DBG("Closing kernel fd");
        close(kernel_tracer_fd);
 
-       DBG("Unloading kernel modules");
-       modprobe_remove_kernel_modules();
+       if (is_root) {
+               DBG("Unloading kernel modules");
+               modprobe_remove_kernel_modules();
+       }
 }
 
 /*
@@ -1003,8 +1005,12 @@ static void *thread_dispatch_ust_registration(void *data)
 
                        ust_cmd = caa_container_of(node, struct ust_command, node);
 
-                       DBG("Dispatching UST registration pid:%d sock:%d",
-                                       ust_cmd->reg_msg.pid, ust_cmd->sock);
+                       DBG("Dispatching UST registration pid:%d ppid:%d uid:%d"
+                                       " gid:%d sock:%d name:%s (version %d.%d)",
+                                       ust_cmd->reg_msg.pid, ust_cmd->reg_msg.ppid,
+                                       ust_cmd->reg_msg.uid, ust_cmd->reg_msg.gid,
+                                       ust_cmd->sock, ust_cmd->reg_msg.name,
+                                       ust_cmd->reg_msg.major, ust_cmd->reg_msg.minor);
                        /*
                         * Inform apps thread of the new application registration. This
                         * call is blocking so we can be assured that the data will be read
@@ -1102,8 +1108,12 @@ static void *thread_registration_apps(void *data)
                 */
                ret = lttcomm_recv_unix_sock(sock, &ust_cmd->reg_msg,
                                sizeof(struct ust_register_msg));
-               if (ret < 0 || ret != sizeof(struct ust_register_msg)) {
-                       perror("lttcomm_recv_unix_sock register apps");
+               if (ret < 0 || ret < sizeof(struct ust_register_msg)) {
+                       if (ret < 0) {
+                               perror("lttcomm_recv_unix_sock register apps");
+                       } else {
+                               ERR("Wrong size received on apps register");
+                       }
                        free(ust_cmd);
                        close(sock);
                        continue;
@@ -1111,6 +1121,12 @@ static void *thread_registration_apps(void *data)
 
                ust_cmd->sock = sock;
 
+               DBG("UST registration received with pid:%d ppid:%d uid:%d"
+                               " gid:%d sock:%d name:%s (version %d.%d)",
+                               ust_cmd->reg_msg.pid, ust_cmd->reg_msg.ppid,
+                               ust_cmd->reg_msg.uid, ust_cmd->reg_msg.gid,
+                               ust_cmd->sock, ust_cmd->reg_msg.name,
+                               ust_cmd->reg_msg.major, ust_cmd->reg_msg.minor);
                /*
                 * Lock free enqueue the registration request.
                 * The red pill has been taken! This apps will be part of the *system*
@@ -1122,9 +1138,6 @@ static void *thread_registration_apps(void *data)
                 * Implicit memory barrier with the exchange in cds_wfq_enqueue.
                 */
                futex_nto1_wake(&ust_cmd_queue.futex);
-
-               DBG("Thread manage apps informed of queued node with sock:%d pid:%d",
-                               sock, ust_cmd->reg_msg.pid);
        }
 
 error:
@@ -1561,13 +1574,6 @@ static int create_kernel_session(struct ltt_session *session)
                session->kernel_session->consumer_fd = kconsumerd_cmd_sock;
        }
 
-       ret = asprintf(&session->kernel_session->trace_path, "%s/kernel",
-                       session->path);
-       if (ret < 0) {
-               perror("asprintf kernel traces path");
-               goto error;
-       }
-
        ret = mkdir_recursive(session->kernel_session->trace_path,
                        S_IRWXU | S_IRWXG, geteuid(), allowed_group());
        if (ret < 0) {
This page took 0.02376 seconds and 4 git commands to generate.