From: David Goulet Date: Fri, 23 Aug 2013 19:00:36 +0000 (-0400) Subject: Fix: snapshot record error handling X-Git-Tag: v2.3.0-rc3~29 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2a06df8de565dc46491480d4f2e8d4113492c3de;p=lttng-tools.git Fix: snapshot record error handling Fixes #617 Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 17dcfc416..6a195e1bd 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -2577,13 +2577,7 @@ static int record_kernel_snapshot(struct ltt_kernel_session *ksess, } ret = kernel_snapshot_record(ksess, output, wait, nb_streams); - if (ret < 0) { - if (ret == -EINVAL) { - ret = LTTNG_ERR_INVALID; - goto error_snapshot; - } - - ret = LTTNG_ERR_SNAPSHOT_FAIL; + if (ret != LTTNG_OK) { goto error_snapshot; } diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index ddf01044c..bf1a52171 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -819,12 +819,12 @@ void kernel_destroy_channel(struct ltt_kernel_channel *kchan) /* * Take a snapshot for a given kernel session. * - * Return 0 on success or else a negative value. + * Return 0 on success or else return a LTTNG_ERR code. */ int kernel_snapshot_record(struct ltt_kernel_session *ksess, struct snapshot_output *output, int wait, unsigned int nb_streams) { - int ret, saved_metadata_fd; + int err, ret, saved_metadata_fd; struct consumer_socket *socket; struct lttng_ht_iter iter; struct ltt_kernel_metadata *saved_metadata; @@ -892,6 +892,8 @@ int kernel_snapshot_record(struct ltt_kernel_session *ksess, DBG3("Kernel snapshot record maximum stream size %" PRIu64 " is smaller than subbuffer size of %" PRIu64, max_size_per_stream, chan->channel->attr.subbuf_size); + (void) kernel_consumer_destroy_metadata(socket, + ksess->metadata); goto error_consumer; } @@ -903,6 +905,8 @@ int kernel_snapshot_record(struct ltt_kernel_session *ksess, pthread_mutex_unlock(socket->lock); if (ret < 0) { ret = LTTNG_ERR_KERN_CONSUMER_FAIL; + (void) kernel_consumer_destroy_metadata(socket, + ksess->metadata); goto error_consumer; } } @@ -927,8 +931,8 @@ int kernel_snapshot_record(struct ltt_kernel_session *ksess, error_consumer: /* Close newly opened metadata stream. It's now on the consumer side. */ - ret = close(ksess->metadata_stream_fd); - if (ret < 0) { + err = close(ksess->metadata_stream_fd); + if (err < 0) { PERROR("close snapshot kernel"); }