Fix: Returned error code in consumer on read buffer
authorDavid Goulet <dgoulet@efficios.com>
Wed, 12 Sep 2012 19:19:05 +0000 (15:19 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 12 Sep 2012 19:19:26 +0000 (15:19 -0400)
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/common/kernel-consumer/kernel-consumer.c
src/common/ust-consumer/ust-consumer.c

index 11701aebfb9869b7e6dbac8deb26828bd3d8cebe..fe93c2e21feed3f63c3f2def9d6af91cdd65ac4a 100644 (file)
@@ -304,6 +304,7 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
        /* Get the next subbuffer */
        err = kernctl_get_next_subbuf(infd);
        if (err != 0) {
+               ret = -err;
                /*
                 * This is a debug message even for single-threaded consumer,
                 * because poll() have more relaxed criterions than get subbuf,
@@ -320,8 +321,9 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
                        /* read the whole subbuffer */
                        err = kernctl_get_padded_subbuf_size(infd, &len);
                        if (err != 0) {
-                               errno = -ret;
+                               errno = -err;
                                perror("Getting sub-buffer len failed.");
+                               ret = -err;
                                goto end;
                        }
 
@@ -341,8 +343,9 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
                        /* read the used subbuffer size */
                        err = kernctl_get_padded_subbuf_size(infd, &len);
                        if (err != 0) {
-                               errno = -ret;
+                               errno = -err;
                                perror("Getting sub-buffer len failed.");
+                               ret = -err;
                                goto end;
                        }
                        /* write the subbuffer to the tracefile */
@@ -362,13 +365,15 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
 
        err = kernctl_put_next_subbuf(infd);
        if (err != 0) {
-               errno = -ret;
+               errno = -err;
                if (errno == EFAULT) {
                        perror("Error in unreserving sub buffer\n");
                } else if (errno == EIO) {
                        /* Should never happen with newer LTTng versions */
                        perror("Reader has been pushed by the writer, last sub-buffer corrupted.");
                }
+
+               ret = -err;
                goto end;
        }
 
index 5e2f7692b1e6e7c35ffbc574fa45f974c4e9f117..1544ddb914eff5eb9b6bc69727034d880cd18cf6 100644 (file)
@@ -426,7 +426,7 @@ int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
        /* Get the next subbuffer */
        err = ustctl_get_next_subbuf(handle, buf);
        if (err != 0) {
-               ret = -ret;     /* ustctl_get_next_subbuf returns negative, caller expect positive. */
+               ret = -err;     /* ustctl_get_next_subbuf returns negative, caller expect positive. */
                /*
                 * This is a debug message even for single-threaded consumer,
                 * because poll() have more relaxed criterions than get subbuf,
This page took 0.028592 seconds and 4 git commands to generate.