From: Mathieu Desnoyers Date: Fri, 26 Sep 2014 00:49:45 +0000 (-0400) Subject: Fix: kernel consumer: issue put_subbuf on error X-Git-Tag: v2.6.0-rc1~34 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8265f19e4002c6826f9b96e55075d3382602e0c3;p=lttng-tools.git Fix: kernel consumer: issue put_subbuf on error Signed-off-by: Mathieu Desnoyers Signed-off-by: David Goulet --- diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index cca522dad..e5595a1c3 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -1084,6 +1084,17 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream, err = kernctl_get_padded_subbuf_size(infd, &len); if (err != 0) { perror("Getting sub-buffer len failed."); + err = kernctl_put_subbuf(infd); + if (err != 0) { + 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 = -errno; + goto end; + } ret = -errno; goto end; } @@ -1091,6 +1102,17 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream, if (!stream->metadata_flag) { ret = get_index_values(&index, infd); if (ret < 0) { + err = kernctl_put_subbuf(infd); + if (err != 0) { + 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 = -errno; + goto end; + } goto end; } } else { @@ -1129,6 +1151,17 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream, err = kernctl_get_subbuf_size(infd, &subbuf_size); if (err != 0) { perror("Getting sub-buffer len failed."); + err = kernctl_put_subbuf(infd); + if (err != 0) { + 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 = -errno; + goto end; + } ret = -errno; goto end; }