X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Flttng-ctl.c;h=561b0bcfba4e39a76eee320968985d8f09a18ef5;hb=d7458e2fdfda5824bb5406c8e05dc48276bf433f;hp=a8c6c9b24adc33a3b13a14b2f206ffea5edc8230;hpb=0bf690bb0b65ad846d30ccb0507ef2ea6acc44b9;p=lttng-tools.git diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index a8c6c9b24..561b0bcfb 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -208,15 +208,13 @@ end: LTTNG_HIDDEN int lttng_check_tracing_group(void) { - struct group *grp_tracing; /* no free(). See getgrnam(3) */ - gid_t *grp_list; + gid_t *grp_list, tracing_gid; int grp_list_size, grp_id, i; int ret = -1; const char *grp_name = tracing_group; /* Get GID of group 'tracing' */ - grp_tracing = getgrnam(grp_name); - if (!grp_tracing) { + if (utils_get_group_id(grp_name, false, &tracing_gid)) { /* If grp_tracing is NULL, the group does not exist. */ goto end; } @@ -241,7 +239,7 @@ int lttng_check_tracing_group(void) } for (i = 0; i < grp_list_size; i++) { - if (grp_list[i] == grp_tracing->gr_gid) { + if (grp_list[i] == tracing_gid) { ret = 1; break; } @@ -2073,6 +2071,8 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain, if (extended) { extended->monitor_timer_interval = DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER; + extended->blocking_timeout = + DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT; } break; case LTTNG_DOMAIN_UST: @@ -2088,6 +2088,8 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain, if (extended) { extended->monitor_timer_interval = DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER; + extended->blocking_timeout = + DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT; } break; case LTTNG_BUFFER_PER_PID: @@ -2102,6 +2104,8 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain, if (extended) { extended->monitor_timer_interval = DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER; + extended->blocking_timeout = + DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT; } break; } @@ -2203,6 +2207,61 @@ end: return ret; } +int lttng_channel_get_blocking_timeout(struct lttng_channel *chan, + int64_t *blocking_timeout) +{ + int ret = 0; + + if (!chan || !blocking_timeout) { + ret = -LTTNG_ERR_INVALID; + goto end; + } + + if (!chan->attr.extended.ptr) { + ret = -LTTNG_ERR_INVALID; + goto end; + } + + *blocking_timeout = ((struct lttng_channel_extended *) + chan->attr.extended.ptr)->blocking_timeout; +end: + return ret; +} + +int lttng_channel_set_blocking_timeout(struct lttng_channel *chan, + int64_t blocking_timeout) +{ + int ret = 0; + int64_t msec_timeout; + + if (!chan || !chan->attr.extended.ptr) { + ret = -LTTNG_ERR_INVALID; + goto end; + } + + if (blocking_timeout < 0 && blocking_timeout != -1) { + ret = -LTTNG_ERR_INVALID; + goto end; + } + + /* + * LTTng-ust's use of poll() to implement this timeout mechanism forces + * us to accept a narrower range of values (msecs expressed as a signed + * 32-bit integer). + */ + msec_timeout = blocking_timeout / 1000; + if (msec_timeout != (int32_t) msec_timeout) { + ret = -LTTNG_ERR_INVALID; + goto end; + } + + ((struct lttng_channel_extended *) + chan->attr.extended.ptr)->blocking_timeout = + blocking_timeout; +end: + return ret; +} + /* * Check if session daemon is alive. * @@ -2497,7 +2556,7 @@ int lttng_list_tracker_pids(struct lttng_handle *handle, int enabled = 1; struct lttcomm_session_msg lsm; size_t nr_pids; - int32_t *pids; + int32_t *pids = NULL; if (handle == NULL) { return -LTTNG_ERR_INVALID; @@ -2514,6 +2573,9 @@ int lttng_list_tracker_pids(struct lttng_handle *handle, return ret; } nr_pids = ret / sizeof(int32_t); + if (nr_pids > 0 && !pids) { + return -LTTNG_ERR_UNK; + } if (nr_pids == 1 && pids[0] == -1) { free(pids); pids = NULL;