Merge branch 'master' into benchmark
authorDavid Goulet <david.goulet@polymtl.ca>
Fri, 9 Dec 2011 15:48:50 +0000 (10:48 -0500)
committerDavid Goulet <david.goulet@polymtl.ca>
Fri, 9 Dec 2011 15:48:50 +0000 (10:48 -0500)
include/lttng-consumerd.h
include/lttng-sessiond-comm.h
lttng-consumerd/lttng-consumerd.c
lttng-sessiond/channel.c
lttng-sessiond/kernel.c
lttng-sessiond/lttng-ust-ctl.h
lttng-sessiond/main.c
lttng-sessiond/ust-app.c
lttng/conf.c

index 1cd78571bba2704f4c42c1e157c95ef5836646ef..e42b2fea5b9eddc9ec2cd5300c5606b25999aeaa 100644 (file)
 #ifndef _LTTNG_CONSUMERD_H
 #define _LTTNG_CONSUMERD_H
 
+#define CONSUMERD_RUNDIR                    "%s"
+
 /* Kernel consumer path */
-#define KCONSUMERD_PATH                     LTTNG_RUNDIR "/kconsumerd"
+#define KCONSUMERD_PATH                     CONSUMERD_RUNDIR "/kconsumerd"
 #define KCONSUMERD_CMD_SOCK_PATH            KCONSUMERD_PATH "/command"
 #define KCONSUMERD_ERR_SOCK_PATH            KCONSUMERD_PATH "/error"
 
 /* UST 64-bit consumer path */
-#define USTCONSUMERD64_PATH                 LTTNG_RUNDIR "/ustconsumerd64"
+#define USTCONSUMERD64_PATH                 CONSUMERD_RUNDIR "/ustconsumerd64"
 #define USTCONSUMERD64_CMD_SOCK_PATH        USTCONSUMERD64_PATH "/command"
 #define USTCONSUMERD64_ERR_SOCK_PATH        USTCONSUMERD64_PATH "/error"
 
 /* UST 32-bit consumer path */
-#define USTCONSUMERD32_PATH                 LTTNG_RUNDIR "/ustconsumerd32"
+#define USTCONSUMERD32_PATH                 CONSUMERD_RUNDIR "/ustconsumerd32"
 #define USTCONSUMERD32_CMD_SOCK_PATH        USTCONSUMERD32_PATH "/command"
 #define USTCONSUMERD32_ERR_SOCK_PATH        USTCONSUMERD32_PATH "/error"
 
index 3d31ff842c4f0fcc0015b894b72ff1a7d557b63d..74d7dc99cef1385c518e13286f6085313292da3a 100644 (file)
 #include <lttng/lttng.h>
 
 #define LTTNG_RUNDIR                        "/var/run/lttng"
+#define LTTNG_HOME_RUNDIR                   "%s/.lttng"
 
 /* Default unix socket path */
 #define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK     LTTNG_RUNDIR "/client-lttng-sessiond"
 #define DEFAULT_GLOBAL_APPS_UNIX_SOCK       LTTNG_RUNDIR "/apps-lttng-sessiond"
-#define DEFAULT_HOME_APPS_UNIX_SOCK         "%s/.apps-lttng-sessiond"
-#define DEFAULT_HOME_CLIENT_UNIX_SOCK       "%s/.client-lttng-sessiond"
+#define DEFAULT_HOME_APPS_UNIX_SOCK         LTTNG_HOME_RUNDIR "/apps-lttng-sessiond"
+#define DEFAULT_HOME_CLIENT_UNIX_SOCK       LTTNG_HOME_RUNDIR "/client-lttng-sessiond"
 
 /* Queue size of listen(2) */
 #define LTTNG_SESSIOND_COMM_MAX_LISTEN 64
index dce188aced643c282f71f4f7d114ad92f05374e8..cf515a9df7cae5090f4f2537b1fda39342fcfffc 100644 (file)
@@ -251,13 +251,16 @@ int main(int argc, char **argv)
        if (strlen(command_sock_path) == 0) {
                switch (opt_type) {
                case LTTNG_CONSUMER_KERNEL:
-                       strcpy(command_sock_path, KCONSUMERD_CMD_SOCK_PATH);
+                       snprintf(command_sock_path, PATH_MAX, KCONSUMERD_CMD_SOCK_PATH,
+                                       LTTNG_RUNDIR);
                        break;
                case LTTNG_CONSUMER64_UST:
-                       strcpy(command_sock_path, USTCONSUMERD64_CMD_SOCK_PATH);
+                       snprintf(command_sock_path, PATH_MAX,
+                                       USTCONSUMERD64_CMD_SOCK_PATH, LTTNG_RUNDIR);
                        break;
                case LTTNG_CONSUMER32_UST:
-                       strcpy(command_sock_path, USTCONSUMERD32_CMD_SOCK_PATH);
+                       snprintf(command_sock_path, PATH_MAX,
+                                       USTCONSUMERD32_CMD_SOCK_PATH, LTTNG_RUNDIR);
                        break;
                default:
                        WARN("Unknown consumerd type");
@@ -275,13 +278,16 @@ int main(int argc, char **argv)
        if (strlen(error_sock_path) == 0) {
                switch (opt_type) {
                case LTTNG_CONSUMER_KERNEL:
-                       strcpy(error_sock_path, KCONSUMERD_ERR_SOCK_PATH);
+                       snprintf(error_sock_path, PATH_MAX, KCONSUMERD_ERR_SOCK_PATH,
+                                       LTTNG_RUNDIR);
                        break;
                case LTTNG_CONSUMER64_UST:
-                       strcpy(error_sock_path, USTCONSUMERD64_ERR_SOCK_PATH);
+                       snprintf(error_sock_path, PATH_MAX,
+                                       USTCONSUMERD64_ERR_SOCK_PATH, LTTNG_RUNDIR);
                        break;
                case LTTNG_CONSUMER32_UST:
-                       strcpy(error_sock_path, USTCONSUMERD32_ERR_SOCK_PATH);
+                       snprintf(error_sock_path, PATH_MAX,
+                                       USTCONSUMERD32_ERR_SOCK_PATH, LTTNG_RUNDIR);
                        break;
                default:
                        WARN("Unknown consumerd type");
index 5a22d2937f22a9d95de60f6a7126ff28671402b7..06b799db1d2132aab97e10ca2ad7e8970be1c10c 100644 (file)
@@ -279,7 +279,6 @@ int channel_ust_disable(struct ltt_ust_session *usess, int domain,
                struct ltt_ust_channel *uchan)
 {
        int ret = LTTCOMM_OK;
-       struct cds_lfht *chan_ht;
 
        /* Already disabled */
        if (uchan->enabled == 0) {
@@ -291,8 +290,6 @@ int channel_ust_disable(struct ltt_ust_session *usess, int domain,
        switch (domain) {
        case LTTNG_DOMAIN_UST:
                DBG2("Channel %s being disabled in UST global domain", uchan->name);
-               chan_ht = usess->domain_global.channels;
-
                /* Disable channel for global domain */
                ret = ust_app_disable_channel_glb(usess, uchan);
                break;
index 16334a83b26122b4096ddf9dc71c473095549867..67c0d6fe9c965dac6a551c381e844be8a90582d0 100644 (file)
@@ -591,6 +591,7 @@ ssize_t kernel_list_events(int tracer_fd, struct lttng_event **events)
                }
                strncpy(elist[count].name, event, LTTNG_SYMBOL_NAME_LEN);
                elist[count].name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
+               elist[count].enabled = -1;
                count++;
        }
 
index 687379448d11511d6c86af243b1f88d8202d129c..66c84c9ddb195e1426070973659df236b33c4896 100644 (file)
@@ -59,6 +59,8 @@ int ustctl_tracepoint_list_get(int sock, int tp_list_handle,
 int ustctl_tracer_version(int sock, struct lttng_ust_tracer_version *v);
 int ustctl_wait_quiescent(int sock);
 
+int ustctl_sock_flush_buffer(int sock, struct lttng_ust_object_data *object);
+
 /* not implemented yet */
 struct lttng_ust_calibrate;
 int ustctl_calibrate(int sock, struct lttng_ust_calibrate *calibrate);
index f4f69969b8ce926c20d360f995fa4932e464c67f..d8f2125a4834066761d41cd6a0133ecfaddeb87c 100644 (file)
@@ -96,6 +96,7 @@ static int opt_sig_parent;
 static int opt_daemon;
 static int is_root;                    /* Set to 1 if the daemon is running as root */
 static pid_t ppid;          /* Parent PID for --sig-parent option */
+static char *rundir;
 
 /* Consumer daemon specific control data */
 static struct consumer_data kconsumer_data = {
@@ -425,19 +426,18 @@ static void cleanup(void)
 
        DBG("Cleaning up");
 
-       if (is_root) {
-               DBG("Removing %s directory", LTTNG_RUNDIR);
-               ret = asprintf(&cmd, "rm -rf " LTTNG_RUNDIR);
-               if (ret < 0) {
-                       ERR("asprintf failed. Something is really wrong!");
-               }
+       DBG("Removing %s directory", rundir);
+       ret = asprintf(&cmd, "rm -rf %s", rundir);
+       if (ret < 0) {
+               ERR("asprintf failed. Something is really wrong!");
+       }
 
-               /* Remove lttng run directory */
-               ret = system(cmd);
-               if (ret < 0) {
-                       ERR("Unable to clean " LTTNG_RUNDIR);
-               }
+       /* Remove lttng run directory */
+       ret = system(cmd);
+       if (ret < 0) {
+               ERR("Unable to clean %s", rundir);
        }
+       free(cmd);
 
        DBG("Cleaning up all session");
 
@@ -4067,14 +4067,16 @@ static int create_apps_cmd_pipe(void)
 /*
  * Create the lttng run directory needed for all global sockets and pipe.
  */
-static int create_lttng_rundir(void)
+static int create_lttng_rundir(const char *rundir)
 {
        int ret;
 
-       ret = mkdir(LTTNG_RUNDIR, S_IRWXU | S_IRWXG );
+       DBG3("Creating LTTng run directory: %s", rundir);
+
+       ret = mkdir(rundir, S_IRWXU | S_IRWXG );
        if (ret < 0) {
                if (errno != EEXIST) {
-                       ERR("Unable to create " LTTNG_RUNDIR);
+                       ERR("Unable to create %s", rundir);
                        goto error;
                } else {
                        ret = 0;
@@ -4089,20 +4091,21 @@ error:
  * Setup sockets and directory needed by the kconsumerd communication with the
  * session daemon.
  */
-static int set_consumer_sockets(struct consumer_data *consumer_data)
+static int set_consumer_sockets(struct consumer_data *consumer_data,
+               const char *rundir)
 {
        int ret;
-       const char *path;
+       char path[PATH_MAX];
 
-       switch (consumer_data->type) {
+    switch (consumer_data->type) {
        case LTTNG_CONSUMER_KERNEL:
-               path = KCONSUMERD_PATH;
+               snprintf(path, PATH_MAX, KCONSUMERD_PATH, rundir);
                break;
        case LTTNG_CONSUMER64_UST:
-               path = USTCONSUMERD64_PATH;
+               snprintf(path, PATH_MAX, USTCONSUMERD64_PATH, rundir);
                break;
        case LTTNG_CONSUMER32_UST:
-               path = USTCONSUMERD32_PATH;
+               snprintf(path, PATH_MAX, USTCONSUMERD32_PATH, rundir);
                break;
        default:
                ERR("Consumer type unknown");
@@ -4110,6 +4113,8 @@ static int set_consumer_sockets(struct consumer_data *consumer_data)
                goto error;
        }
 
+       DBG2("Creating consumer directory: %s", path);
+
        ret = mkdir(path, S_IRWXU | S_IRWXG);
        if (ret < 0) {
                if (errno != EEXIST) {
@@ -4133,7 +4138,7 @@ static int set_consumer_sockets(struct consumer_data *consumer_data)
                        S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
        if (ret < 0) {
                ERR("Set file permissions failed: %s", consumer_data->err_unix_sock_path);
-               perror("chmod");
+               PERROR("chmod");
                goto error;
        }
 
@@ -4261,7 +4266,10 @@ int main(int argc, char **argv)
        is_root = !getuid();
 
        if (is_root) {
-               ret = create_lttng_rundir();
+               rundir = strdup(LTTNG_RUNDIR);
+
+               /* Create global run dir with root access */
+               ret = create_lttng_rundir(rundir);
                if (ret < 0) {
                        goto error;
                }
@@ -4281,6 +4289,17 @@ int main(int argc, char **argv)
                        snprintf(wait_shm_path, PATH_MAX,
                                        DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH);
                }
+
+               /* Setup kernel consumerd path */
+               snprintf(kconsumer_data.err_unix_sock_path, PATH_MAX,
+                               KCONSUMERD_ERR_SOCK_PATH, rundir);
+               snprintf(kconsumer_data.cmd_unix_sock_path, PATH_MAX,
+                               KCONSUMERD_CMD_SOCK_PATH, rundir);
+
+               DBG2("Kernel consumer err path: %s",
+                               kconsumer_data.err_unix_sock_path);
+               DBG2("Kernel consumer cmd path: %s",
+                               kconsumer_data.cmd_unix_sock_path);
        } else {
                home_path = get_home_dir();
                if (home_path == NULL) {
@@ -4290,6 +4309,21 @@ int main(int argc, char **argv)
                        goto error;
                }
 
+               /*
+                * Create rundir from home path. This will create something like
+                * $HOME/.lttng
+                */
+               ret = asprintf(&rundir, LTTNG_HOME_RUNDIR, home_path);
+               if (ret < 0) {
+                       ret = -ENOMEM;
+                       goto error;
+               }
+
+               ret = create_lttng_rundir(rundir);
+               if (ret < 0) {
+                       goto error;
+               }
+
                if (strlen(apps_unix_sock_path) == 0) {
                        snprintf(apps_unix_sock_path, PATH_MAX,
                                        DEFAULT_HOME_APPS_UNIX_SOCK, home_path);
@@ -4310,6 +4344,29 @@ int main(int argc, char **argv)
 
        DBG("Client socket path %s", client_unix_sock_path);
        DBG("Application socket path %s", apps_unix_sock_path);
+       DBG("LTTng run directory path: %s", rundir);
+
+       /* 32 bits consumerd path setup */
+       snprintf(ustconsumer32_data.err_unix_sock_path, PATH_MAX,
+                       USTCONSUMERD32_ERR_SOCK_PATH, rundir);
+       snprintf(ustconsumer32_data.cmd_unix_sock_path, PATH_MAX,
+                       USTCONSUMERD32_CMD_SOCK_PATH, rundir);
+
+       DBG2("UST consumer 32 bits err path: %s",
+                       ustconsumer32_data.err_unix_sock_path);
+       DBG2("UST consumer 32 bits cmd path: %s",
+                       ustconsumer32_data.cmd_unix_sock_path);
+
+       /* 64 bits consumerd path setup */
+       snprintf(ustconsumer64_data.err_unix_sock_path, PATH_MAX,
+                       USTCONSUMERD64_ERR_SOCK_PATH, rundir);
+       snprintf(ustconsumer64_data.cmd_unix_sock_path, PATH_MAX,
+                       USTCONSUMERD64_CMD_SOCK_PATH, rundir);
+
+       DBG2("UST consumer 64 bits err path: %s",
+                       ustconsumer64_data.err_unix_sock_path);
+       DBG2("UST consumer 64 bits cmd path: %s",
+                       ustconsumer64_data.cmd_unix_sock_path);
 
        /*
         * See if daemon already exist.
@@ -4332,17 +4389,7 @@ int main(int argc, char **argv)
         * kernel tracer.
         */
        if (is_root) {
-               ret = set_consumer_sockets(&kconsumer_data);
-               if (ret < 0) {
-                       goto exit;
-               }
-
-               ret = set_consumer_sockets(&ustconsumer64_data);
-               if (ret < 0) {
-                       goto exit;
-               }
-
-               ret = set_consumer_sockets(&ustconsumer32_data);
+               ret = set_consumer_sockets(&kconsumer_data, rundir);
                if (ret < 0) {
                        goto exit;
                }
@@ -4354,6 +4401,16 @@ int main(int argc, char **argv)
                set_ulimit();
        }
 
+       ret = set_consumer_sockets(&ustconsumer64_data, rundir);
+       if (ret < 0) {
+               goto exit;
+       }
+
+       ret = set_consumer_sockets(&ustconsumer32_data, rundir);
+       if (ret < 0) {
+               goto exit;
+       }
+
        if ((ret = set_signal_handler()) < 0) {
                goto exit;
        }
@@ -4489,8 +4546,9 @@ exit:
        cleanup();
        rcu_thread_offline();
        rcu_unregister_thread();
-       if (!ret)
+       if (!ret) {
                exit(EXIT_SUCCESS);
+       }
 error:
        exit(EXIT_FAILURE);
 }
index 2ed9d002d49f444df38662f3cf26e335d10f0b41..616a7ae2f50c04ebf1365bc20d218d3ec28b256e 100644 (file)
@@ -565,6 +565,8 @@ static int open_ust_metadata(struct ust_app *app,
                goto error;
        }
 
+       ua_sess->metadata->handle = ua_sess->metadata->obj->handle;
+
 error:
        return ret;
 }
@@ -1160,6 +1162,7 @@ static int create_ust_app_metadata(struct ust_app_session *ua_sess,
                char *pathname, struct ust_app *app)
 {
        int ret = 0;
+       mode_t old_umask;
 
        if (ua_sess->metadata == NULL) {
                /* Allocate UST metadata */
@@ -1185,11 +1188,13 @@ static int create_ust_app_metadata(struct ust_app_session *ua_sess,
                        goto error;
                }
 
+               old_umask = umask(0);
                ret = mkdir(ua_sess->path, S_IRWXU | S_IRWXG);
                if (ret < 0) {
                        PERROR("mkdir UST metadata");
                        goto error;
                }
+               umask(old_umask);
 
                ret = snprintf(ua_sess->metadata->pathname, PATH_MAX,
                                "%s/metadata", ua_sess->path);
@@ -1922,7 +1927,9 @@ error_rcu_unlock:
 int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app)
 {
        int ret = 0;
+       struct cds_lfht_iter iter;
        struct ust_app_session *ua_sess;
+       struct ust_app_channel *ua_chan;
 
        DBG("Stopping tracing for ust app pid %d", app->key.pid);
 
@@ -1934,21 +1941,23 @@ int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app)
                goto error_rcu_unlock;
        }
 
-#if 0  /* only useful when periodical flush will be supported */
-       /* need to keep a handle on shm in session for this. */
        /* Flush all buffers before stopping */
-       ret = ustctl_flush_buffer(usess->sock, usess->metadata->obj);
+       ret = ustctl_sock_flush_buffer(app->key.sock, ua_sess->metadata->obj);
        if (ret < 0) {
-               ERR("UST metadata flush failed");
+               ERR("UST app PID %d metadata flush failed", app->key.pid);
+               ERR("Ended with ret %d", ret);
        }
 
-       cds_list_for_each_entry(ustchan, &usess->channels.head, list) {
-               ret = ustctl_flush_buffer(usess->sock, ustchan->obj);
+       cds_lfht_for_each_entry(ua_sess->channels, &iter, ua_chan, node) {
+               ret = ustctl_sock_flush_buffer(app->key.sock, ua_chan->obj);
                if (ret < 0) {
-                       ERR("UST flush buffer error");
+                       ERR("UST app PID %d channel %s flush failed",
+                                       app->key.pid, ua_chan->name);
+                       ERR("Ended with ret %d", ret);
+                       /* Continuing flushing all buffers */
+                       continue;
                }
        }
-#endif
 
        /* This inhibits UST tracing */
        ret = ustctl_stop_session(app->key.sock, ua_sess->handle);
index 5479a3cd016e740100d14198e210d45769da013d..7337d92cade22a4b143ad57932390cd5ad779cea 100644 (file)
@@ -63,7 +63,6 @@ static FILE *open_config(char *path, const char *mode)
 
        fp = fopen(file_path, mode);
        if (fp == NULL) {
-               perror("config file");
                goto error;
        }
 
@@ -171,6 +170,7 @@ char *config_read_session_name(char *path)
        fp = open_config(path, "r");
        if (fp == NULL) {
                ERR("Can't find valid lttng config %s/.lttngrc", path);
+               MSG("Did you create a session? (lttng create <my_sesion>)");
                goto error;
        }
 
This page took 0.076898 seconds and 4 git commands to generate.