X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Flttng-ctl.c;h=48d7f8890c9b0184f1e08299a7122b9211fde689;hb=a03e83c35e9b1534952a57d64bab6beb728a990e;hp=6bd3f80ec3f8f3a77941d30c67936b98c05efed3;hpb=7955af2dca5ddbcce6fa2afa6be862318ba46b44;p=lttng-tools.git diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 6bd3f80ec..48d7f8890 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -1659,6 +1659,26 @@ int lttng_create_session(const char *name, const char *url) return ret; } +/* + * Clear the session + */ +int lttng_clear_session(const char *session_name) +{ + struct lttcomm_session_msg lsm; + + if (session_name == NULL) { + return -LTTNG_ERR_INVALID; + } + + memset(&lsm, 0, sizeof(lsm)); + + lsm.cmd_type = LTTNG_CLEAR_SESSION; + lttng_ctl_copy_string(lsm.session.name, session_name, + sizeof(lsm.session.name)); + + return lttng_ctl_ask_sessiond(&lsm, NULL); +} + /* * Destroy session using name. * Returns size of returned session payload data or a negative error code. @@ -2073,6 +2093,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 +2110,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 +2126,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 +2229,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 +2578,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 +2595,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; @@ -2607,7 +2691,7 @@ int lttng_register_trigger(struct lttng_trigger *trigger) } if (!lttng_trigger_validate(trigger)) { - ret = -LTTNG_ERR_INVALID; + ret = -LTTNG_ERR_INVALID_TRIGGER; goto end; }