X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Flttng-ctl.c;h=bcd59f0c637979cccb09ce923db97d9146e35508;hb=18e29540021469e0b0c515b4c3198b7be8fb0072;hp=4df1bdf3f46050f9ae00a279e1024693c6a995b7;hpb=8fd2c92c9864fd139539b7acbd31fbe4d2689ceb;p=lttng-tools.git diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 4df1bdf3f..bcd59f0c6 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -519,10 +519,6 @@ struct lttng_handle *lttng_create_handle(const char *session_name, { struct lttng_handle *handle = NULL; - if (domain == NULL) { - goto end; - } - handle = zmalloc(sizeof(struct lttng_handle)); if (handle == NULL) { PERROR("malloc handle"); @@ -533,8 +529,10 @@ struct lttng_handle *lttng_create_handle(const char *session_name, lttng_ctl_copy_string(handle->session_name, session_name, sizeof(handle->session_name)); - /* Copy lttng domain */ - lttng_ctl_copy_lttng_domain(&handle->domain, domain); + /* Copy lttng domain or leave initialized to 0. */ + if (domain) { + lttng_ctl_copy_lttng_domain(&handle->domain, domain); + } end: return handle; @@ -2386,7 +2384,45 @@ int lttng_list_tracker_pids(struct lttng_handle *handle, * Regenerate the metadata for a session. * Return 0 on success, a negative error code on error. */ +int lttng_regenerate_metadata(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_REGENERATE_METADATA; + + 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; +} + +/* + * Deprecated, replaced by lttng_regenerate_metadata. + */ int lttng_metadata_regenerate(const char *session_name) +{ + return lttng_regenerate_metadata(session_name); +} + +/* + * Regenerate the statedump of a session. + * Return 0 on success, a negative error code on error. + */ +int lttng_regenerate_statedump(const char *session_name) { int ret; struct lttcomm_session_msg lsm; @@ -2397,7 +2433,7 @@ int lttng_metadata_regenerate(const char *session_name) } memset(&lsm, 0, sizeof(lsm)); - lsm.cmd_type = LTTNG_METADATA_REGENERATE; + lsm.cmd_type = LTTNG_REGENERATE_STATEDUMP; lttng_ctl_copy_string(lsm.session.name, session_name, sizeof(lsm.session.name)); @@ -2415,7 +2451,7 @@ end: /* * lib constructor. */ -static void __attribute__((constructor)) init() +static void __attribute__((constructor)) init(void) { /* Set default session group */ lttng_set_tracing_group(DEFAULT_TRACING_GROUP); @@ -2424,7 +2460,7 @@ static void __attribute__((constructor)) init() /* * lib destructor. */ -static void __attribute__((destructor)) lttng_ctl_exit() +static void __attribute__((destructor)) lttng_ctl_exit(void) { free(tracing_group); }