Fix: consumerd: add missing put_subbuf for ust and kernel errors
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 11 Jan 2017 20:49:49 +0000 (15:49 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 23 Jan 2017 22:29:56 +0000 (17:29 -0500)
While reading a sub-buffer, error handling need to put the sub-buffer,
else all future attempts to use the stream will trigger warnings.

The affects recent features added to UST and kernel tracing.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/kernel-consumer/kernel-consumer.c
src/common/ust-consumer/ust-consumer.c

index d03ff701533fdab938082a1d551efdeff4140428..cc06847c9d8f57ecd8f1467d49e9cd3b0f2c1f2f 100644 (file)
@@ -1315,12 +1315,34 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
                }
                ret = update_stream_stats(stream);
                if (ret < 0) {
+                       err = kernctl_put_subbuf(infd);
+                       if (err != 0) {
+                               if (err == -EFAULT) {
+                                       PERROR("Error in unreserving sub buffer\n");
+                               } else if (err == -EIO) {
+                                       /* Should never happen with newer LTTng versions */
+                                       PERROR("Reader has been pushed by the writer, last sub-buffer corrupted.");
+                               }
+                               ret = err;
+                               goto end;
+                       }
                        goto end;
                }
        } else {
                write_index = 0;
                ret = metadata_stream_check_version(infd, stream);
                if (ret < 0) {
+                       err = kernctl_put_subbuf(infd);
+                       if (err != 0) {
+                               if (err == -EFAULT) {
+                                       PERROR("Error in unreserving sub buffer\n");
+                               } else if (err == -EIO) {
+                                       /* Should never happen with newer LTTng versions */
+                                       PERROR("Reader has been pushed by the writer, last sub-buffer corrupted.");
+                               }
+                               ret = err;
+                               goto end;
+                       }
                        goto end;
                }
        }
index faf069c0df6f9319a53751a532cc5e88e769ca26..7fbba8a9080f066ed001996c8081a42befa96fcb 100644 (file)
@@ -2496,6 +2496,8 @@ retry:
                index.offset = htobe64(stream->out_fd_offset);
                ret = get_index_values(&index, ustream);
                if (ret < 0) {
+                       err = ustctl_put_subbuf(ustream);
+                       assert(err == 0);
                        goto end;
                }
 
@@ -2503,6 +2505,8 @@ retry:
                ret = update_stream_stats(stream);
                if (ret < 0) {
                        PERROR("kernctl_get_events_discarded");
+                       err = ustctl_put_subbuf(ustream);
+                       assert(err == 0);
                        goto end;
                }
        } else {
This page took 0.029955 seconds and 5 git commands to generate.