From: David Goulet Date: Wed, 12 Sep 2012 19:19:05 +0000 (-0400) Subject: Fix: Returned error code in consumer on read buffer X-Git-Tag: v2.1.0-rc4~30 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=21073eaa900a731710832c1897d6200637d7ddb0;p=lttng-tools.git Fix: Returned error code in consumer on read buffer Signed-off-by: David Goulet --- diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index 11701aebf..fe93c2e21 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -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; } diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 5e2f7692b..1544ddb91 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -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,