Update version to v2.2.0
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
index 55c0ea19d3a40bfeff226c5037383fc363687713..1b9f3a8ab99a95d54e6ffcd6b8465092dfe4da17 100644 (file)
@@ -32,6 +32,7 @@
 #include <common/defaults.h>
 #include <common/sessiond-comm/sessiond-comm.h>
 #include <common/uri.h>
+#include <common/utils.h>
 #include <lttng/lttng.h>
 
 #include "filter/filter-ast.h"
@@ -485,7 +486,7 @@ static int set_session_daemon_path(void)
                 * With GNU C >= 2.1, snprintf returns the required size (excluding closing null)
                 */
                ret = snprintf(sessiond_sock_path, sizeof(sessiond_sock_path),
-                               DEFAULT_HOME_CLIENT_UNIX_SOCK, getenv("HOME"));
+                               DEFAULT_HOME_CLIENT_UNIX_SOCK, utils_get_home_dir());
                if ((ret < 0) || (ret >= sizeof(sessiond_sock_path))) {
                        goto error;
                }
@@ -1386,29 +1387,37 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain,
 
        memset(attr, 0, sizeof(struct lttng_channel_attr));
 
+       /* Same for all domains. */
+       attr->overwrite = DEFAULT_CHANNEL_OVERWRITE;
+       attr->tracefile_size = DEFAULT_CHANNEL_TRACEFILE_SIZE;
+       attr->tracefile_count = DEFAULT_CHANNEL_TRACEFILE_COUNT;
+
        switch (domain->type) {
        case LTTNG_DOMAIN_KERNEL:
-               attr->overwrite = DEFAULT_CHANNEL_OVERWRITE;
                attr->switch_timer_interval = DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER;
                attr->read_timer_interval = DEFAULT_KERNEL_CHANNEL_READ_TIMER;
-
                attr->subbuf_size = default_get_kernel_channel_subbuf_size();
                attr->num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM;
                attr->output = DEFAULT_KERNEL_CHANNEL_OUTPUT;
-               attr->tracefile_size = DEFAULT_KERNEL_CHANNEL_TRACEFILE_SIZE;
-               attr->tracefile_count = DEFAULT_KERNEL_CHANNEL_TRACEFILE_COUNT;
                break;
        case LTTNG_DOMAIN_UST:
-               attr->overwrite = DEFAULT_CHANNEL_OVERWRITE;
-               attr->switch_timer_interval = DEFAULT_UST_CHANNEL_SWITCH_TIMER;
-               attr->read_timer_interval = DEFAULT_UST_CHANNEL_READ_TIMER;
-
-               attr->subbuf_size = default_get_ust_channel_subbuf_size();
-               attr->num_subbuf = DEFAULT_UST_CHANNEL_SUBBUF_NUM;
-               attr->output = DEFAULT_UST_CHANNEL_OUTPUT;
-               attr->tracefile_size = DEFAULT_UST_CHANNEL_TRACEFILE_SIZE;
-               attr->tracefile_count = DEFAULT_UST_CHANNEL_TRACEFILE_COUNT;
-               break;
+               switch (domain->buf_type) {
+               case LTTNG_BUFFER_PER_UID:
+                       attr->subbuf_size = default_get_ust_uid_channel_subbuf_size();
+                       attr->num_subbuf = DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM;
+                       attr->output = DEFAULT_UST_UID_CHANNEL_OUTPUT;
+                       attr->switch_timer_interval = DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER;
+                       attr->read_timer_interval = DEFAULT_UST_UID_CHANNEL_READ_TIMER;
+                       break;
+               case LTTNG_BUFFER_PER_PID:
+               default:
+                       attr->subbuf_size = default_get_ust_pid_channel_subbuf_size();
+                       attr->num_subbuf = DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM;
+                       attr->output = DEFAULT_UST_PID_CHANNEL_OUTPUT;
+                       attr->switch_timer_interval = DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER;
+                       attr->read_timer_interval = DEFAULT_UST_PID_CHANNEL_READ_TIMER;
+                       break;
+               }
        default:
                /* Default behavior: leave set to 0. */
                break;
@@ -1535,7 +1544,7 @@ static int set_health_socket_path(void)
                 * With GNU C <  2.1, snprintf returns -1 if the target buffer is too small;
                 * With GNU C >= 2.1, snprintf returns the required size (excluding closing null)
                 */
-               home = getenv("HOME");
+               home = utils_get_home_dir();
                if (home == NULL) {
                        /* Fallback in /tmp .. */
                        home = "/tmp";
@@ -1591,7 +1600,12 @@ int lttng_health_check(enum lttng_health_component c)
        ret = reply.ret_code;
 
 close_error:
-       close(sock);
+       {
+               int closeret;
+
+               closeret = close(sock);
+               assert(!closeret);
+       }
 
 error:
        return ret;
@@ -1642,8 +1656,14 @@ int _lttng_create_session_ext(const char *name, const char *url,
        lsm.u.uri.size = size;
 
        if (size > 0 && uris[0].dtype != LTTNG_DST_PATH && strlen(uris[0].subdir) == 0) {
-               ret = snprintf(uris[0].subdir, sizeof(uris[0].subdir), "%s-%s", name,
-                               datetime);
+               /* Don't append datetime if the name was automatically created. */
+               if (strncmp(name, DEFAULT_SESSION_NAME "-",
+                                       strlen(DEFAULT_SESSION_NAME) + 1)) {
+                       ret = snprintf(uris[0].subdir, sizeof(uris[0].subdir), "%s-%s",
+                                       name, datetime);
+               } else {
+                       ret = snprintf(uris[0].subdir, sizeof(uris[0].subdir), "%s", name);
+               }
                if (ret < 0) {
                        PERROR("snprintf uri subdir");
                        ret = -LTTNG_ERR_FATAL;
This page took 0.026294 seconds and 5 git commands to generate.