Fix: snapshot record error handling
authorDavid Goulet <dgoulet@efficios.com>
Fri, 23 Aug 2013 19:00:36 +0000 (15:00 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 23 Aug 2013 19:48:09 +0000 (15:48 -0400)
Fixes #617

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/kernel.c

index 17dcfc41685a2562aa7d01f297cabe324af7354c..6a195e1bdd8352c752ab1b22de82bd08ac573faf 100644 (file)
@@ -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;
        }
 
index ddf01044c816f179b668525c5463c60a6f3483c2..bf1a52171ace5fd378d66a0beae2df458839e87b 100644 (file)
@@ -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");
        }
 
This page took 0.030306 seconds and 4 git commands to generate.