X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Flttng-ctl.c;h=1b9f3a8ab99a95d54e6ffcd6b8465092dfe4da17;hp=8f63bf3e85e367285f9c599176040a4cd266dcd5;hb=8991668e5aee318628b29aa36904855461dad07a;hpb=5d2e1e66a968d9e555f9b8b00d0589ebfaf3de32 diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 8f63bf3e8..1b9f3a8ab 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "filter/filter-ast.h" @@ -73,6 +74,33 @@ static int connected; int lttng_opt_quiet; int lttng_opt_verbose; +/* + * Compare two URL destination. + * + * Return 0 is equal else is not equal. + */ +static int compare_destination(struct lttng_uri *ctrl, struct lttng_uri *data) +{ + int ret; + + assert(ctrl); + assert(data); + + switch (ctrl->dtype) { + case LTTNG_DST_IPV4: + ret = strncmp(ctrl->dst.ipv4, data->dst.ipv4, sizeof(ctrl->dst.ipv4)); + break; + case LTTNG_DST_IPV6: + ret = strncmp(ctrl->dst.ipv6, data->dst.ipv6, sizeof(ctrl->dst.ipv6)); + break; + default: + ret = -1; + break; + } + + return ret; +} + static void set_default_url_attr(struct lttng_uri *uri, enum lttng_stream_type stype) { @@ -158,6 +186,8 @@ static ssize_t parse_str_urls_to_uri(const char *ctrl_url, const char *data_url, } if (data_url) { + int ret; + /* We have to parse the data URL in this case */ size_data = uri_parse(data_url, &data_uris); if (size_data < 1) { @@ -169,6 +199,12 @@ static ssize_t parse_str_urls_to_uri(const char *ctrl_url, const char *data_url, } set_default_url_attr(&data_uris[0], LTTNG_STREAM_DATA); + + ret = compare_destination(&ctrl_uris[0], &data_uris[0]); + if (ret != 0) { + ERR("Control and data destination mismatch"); + goto error; + } } /* Compute total size */ @@ -450,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; } @@ -1351,30 +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_CHANNEL_SWITCH_TIMER; - attr->read_timer_interval = DEFAULT_CHANNEL_READ_TIMER; - + 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; break; case LTTNG_DOMAIN_UST: -#if 0 - case LTTNG_DOMAIN_UST_EXEC_NAME: - case LTTNG_DOMAIN_UST_PID: - case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: -#endif - attr->overwrite = DEFAULT_CHANNEL_OVERWRITE; - attr->switch_timer_interval = DEFAULT_CHANNEL_SWITCH_TIMER; - attr->read_timer_interval = DEFAULT_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; - 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; @@ -1455,7 +1498,7 @@ int lttng_set_consumer_url(struct lttng_handle *handle, } /* - * [OBSELETE] + * [OBSOLETE] */ int lttng_enable_consumer(struct lttng_handle *handle) { @@ -1463,7 +1506,7 @@ int lttng_enable_consumer(struct lttng_handle *handle) } /* - * [OBSELETE] + * [OBSOLETE] */ int lttng_disable_consumer(struct lttng_handle *handle) { @@ -1501,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"; @@ -1557,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; @@ -1608,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;