Fix: standardize man pages building/installing
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
index fe0527d425b0e32e86b75d6b415a0e2aebf5e65b..4df1bdf3f46050f9ae00a279e1024693c6a995b7 100644 (file)
@@ -736,9 +736,16 @@ int lttng_add_context(struct lttng_handle *handle,
                memcpy(buf + provider_len, ctx_name, ctx_len);
        }
        memcpy(&lsm.u.context.ctx, ctx, sizeof(struct lttng_event_context));
-       /* Don't leak application addresses to the sessiond. */
-       lsm.u.context.ctx.u.app_ctx.provider_name = NULL;
-       lsm.u.context.ctx.u.app_ctx.ctx_name = NULL;
+
+       if (ctx->ctx == LTTNG_EVENT_CONTEXT_APP_CONTEXT) {
+               /*
+                * Don't leak application addresses to the sessiond.
+                * This is only necessary when ctx is for an app ctx otherwise
+                * the values inside the union (type & config) are overwritten.
+                */
+               lsm.u.context.ctx.u.app_ctx.provider_name = NULL;
+               lsm.u.context.ctx.u.app_ctx.ctx_name = NULL;
+       }
 
        ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, buf, len, NULL);
 end:
@@ -1554,6 +1561,7 @@ int lttng_create_session(const char *name, const char *url)
  * Destroy session using name.
  * Returns size of returned session payload data or a negative error code.
  */
+static
 int _lttng_destroy_session(const char *session_name)
 {
        struct lttcomm_session_msg lsm;
@@ -2374,6 +2382,36 @@ int lttng_list_tracker_pids(struct lttng_handle *handle,
        return 0;
 }
 
+/*
+ * Regenerate the metadata for a session.
+ * Return 0 on success, a negative error code on error.
+ */
+int lttng_metadata_regenerate(const char *session_name)
+{
+       int ret;
+       struct lttcomm_session_msg lsm;
+
+       if (!session_name) {
+               ret = -LTTNG_ERR_INVALID;
+               goto end;
+       }
+
+       memset(&lsm, 0, sizeof(lsm));
+       lsm.cmd_type = LTTNG_METADATA_REGENERATE;
+
+       lttng_ctl_copy_string(lsm.session.name, session_name,
+                       sizeof(lsm.session.name));
+
+       ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+       if (ret < 0) {
+               goto end;
+       }
+
+       ret = 0;
+end:
+       return ret;
+}
+
 /*
  * lib constructor.
  */
This page took 0.024902 seconds and 5 git commands to generate.