Lttng-ctl: Expose sessiond cmd_clear_session command
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
index a8c6c9b24adc33a3b13a14b2f206ffea5edc8230..48d7f8890c9b0184f1e08299a7122b9211fde689 100644 (file)
@@ -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;
This page took 0.029413 seconds and 5 git commands to generate.