X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.c;h=ae0a56ac67e0d249953ec39d28718323484dbbad;hb=6beb3779248926b2c75175b18e90ac883d528e3c;hp=cc26e6dae004baeab4177f3589a0e837e7deba34;hpb=019e9d1b3f94f345fd7a5275ce712302ae5715d8;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index cc26e6dae..ae0a56ac6 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -1333,16 +1333,6 @@ int cmd_enable_channel(struct ltt_session *session, attr->attr.switch_timer_interval = 0; } - /* - * The ringbuffer (both in user space and kernel) behave badly in overwrite - * mode and with less than 2 subbuf so block it right away and send back an - * invalid attribute error. - */ - if (attr->attr.overwrite && attr->attr.num_subbuf < 2) { - ret = LTTNG_ERR_INVALID; - goto error; - } - switch (domain->type) { case LTTNG_DOMAIN_KERNEL: { @@ -3362,14 +3352,14 @@ ssize_t cmd_snapshot_list_outputs(struct ltt_session *session, if (lttng_strncpy(list[idx].name, output->name, sizeof(list[idx].name))) { ret = -LTTNG_ERR_INVALID; - goto error; + goto error_unlock; } if (output->consumer->type == CONSUMER_DST_LOCAL) { if (lttng_strncpy(list[idx].ctrl_url, output->consumer->dst.trace_path, sizeof(list[idx].ctrl_url))) { ret = -LTTNG_ERR_INVALID; - goto error; + goto error_unlock; } } else { /* Control URI. */ @@ -3377,7 +3367,7 @@ ssize_t cmd_snapshot_list_outputs(struct ltt_session *session, list[idx].ctrl_url, sizeof(list[idx].ctrl_url)); if (ret < 0) { ret = -LTTNG_ERR_NOMEM; - goto error; + goto error_unlock; } /* Data URI. */ @@ -3385,7 +3375,7 @@ ssize_t cmd_snapshot_list_outputs(struct ltt_session *session, list[idx].data_url, sizeof(list[idx].data_url)); if (ret < 0) { ret = -LTTNG_ERR_NOMEM; - goto error; + goto error_unlock; } } idx++; @@ -3394,9 +3384,10 @@ ssize_t cmd_snapshot_list_outputs(struct ltt_session *session, *outputs = list; list = NULL; ret = session->snapshot.nb_output; +error_unlock: + rcu_read_unlock(); error: free(list); - rcu_read_unlock(); return ret; } @@ -3445,6 +3436,27 @@ end: return ret; } +static +int clear_metadata_file(int fd) +{ + int ret; + + ret = lseek(fd, 0, SEEK_SET); + if (ret < 0) { + PERROR("lseek"); + goto end; + } + + ret = ftruncate(fd, 0); + if (ret < 0) { + PERROR("ftruncate"); + goto end; + } + +end: + return ret; +} + static int ust_metadata_regenerate(struct ltt_ust_session *usess) { @@ -3466,6 +3478,15 @@ int ust_metadata_regenerate(struct ltt_ust_session *usess) memset(registry->metadata, 0, registry->metadata_alloc_len); registry->metadata_len = 0; registry->metadata_version++; + if (registry->metadata_fd > 0) { + /* Clear the metadata file's content. */ + ret = clear_metadata_file(registry->metadata_fd); + if (ret) { + pthread_mutex_unlock(®istry->lock); + goto end; + } + } + ret = ust_metadata_session_statedump(registry, NULL, registry->major, registry->minor); if (ret) {