Add new API call lttng_channel_set_default_attr
[lttng-tools.git] / liblttngctl / lttngctl.c
index 4c4cf80d33d866916510d774910a4ca231fca156..fc6ff3cc1ac92b41e28184dd04dc03944ba054ce 100644 (file)
@@ -334,6 +334,10 @@ static int ask_sessiond(struct lttcomm_session_msg *lsm, void **buf)
 
        size = llm.data_size;
        if (size == 0) {
+               /* If client free with size 0 */
+               if (buf != NULL) {
+                       *buf = NULL;
+               }
                ret = 0;
                goto end;
        }
@@ -636,7 +640,7 @@ int lttng_list_tracepoints(struct lttng_handle *handle,
 /*
  *  Return a human readable string of code
  */
-const char *lttng_get_readable_code(int code)
+const char *lttng_strerror(int code)
 {
        if (code > -LTTCOMM_OK) {
                return "Ended with errors";
@@ -780,10 +784,8 @@ int lttng_list_events(struct lttng_handle *handle,
 }
 
 /*
- *  lttng_set_tracing_group
- *
- *  Set tracing group variable with name. This function
- *  allocate memory pointed by tracing_group.
+ * Set tracing group variable with name. This function allocate memory pointed
+ * by tracing_group.
  */
 int lttng_set_tracing_group(const char *name)
 {
@@ -814,6 +816,46 @@ int lttng_calibrate(struct lttng_handle *handle,
        return ask_sessiond(&lsm, NULL);
 }
 
+/*
+ * Set default channel attributes.
+ */
+void lttng_channel_set_default_attr(struct lttng_domain *domain,
+               struct lttng_channel_attr *attr)
+{
+       /* Safety check */
+       if (attr == NULL || domain == NULL) {
+               return;
+       }
+
+       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->subbuf_size = DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE;
+               attr->num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM;
+               attr->output = DEFAULT_KERNEL_CHANNEL_OUTPUT;
+               break;
+       case LTTNG_DOMAIN_UST:
+       case LTTNG_DOMAIN_UST_EXEC_NAME:
+       case LTTNG_DOMAIN_UST_PID:
+       case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
+               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_UST_CHANNEL_SUBBUF_SIZE;
+               attr->num_subbuf = DEFAULT_UST_CHANNEL_SUBBUF_NUM;
+               attr->output = DEFAULT_UST_CHANNEL_OUTPUT;
+               break;
+       default:
+               /* Default behavior */
+               memset(attr, 0, sizeof(struct lttng_channel_attr));
+               break;
+       }
+}
+
 /*
  * Check if session daemon is alive.
  *
This page took 0.024182 seconds and 4 git commands to generate.