Merge branch 'master' into compat-freebsd
[lttng-tools.git] / src / common / ust-consumer / ust-consumer.c
index 9a5775b8ed3bff1bf996dc244516b1dce2685257..c8ba084606180790b51fc7d11ba8ea5075f019c4 100644 (file)
@@ -19,7 +19,6 @@
 
 #define _GNU_SOURCE
 #include <assert.h>
-#include <fcntl.h>
 #include <poll.h>
 #include <pthread.h>
 #include <stdlib.h>
@@ -44,9 +43,9 @@ extern volatile int consumer_quit;
 /*
  * Mmap the ring buffer, read it and write the data to the tracefile.
  *
- * Returns the number of bytes written
+ * Returns the number of bytes written, else negative value on error.
  */
-int lttng_ustconsumer_on_read_subbuffer_mmap(
+ssize_t lttng_ustconsumer_on_read_subbuffer_mmap(
                struct lttng_consumer_local_data *ctx,
                struct lttng_consumer_stream *stream, unsigned long len)
 {
@@ -59,7 +58,7 @@ int lttng_ustconsumer_on_read_subbuffer_mmap(
        ret = ustctl_get_mmap_read_offset(stream->chan->handle,
                stream->buf, &mmap_offset);
        if (ret != 0) {
-               ret = -errno;
+               errno = -ret;
                perror("ustctl_get_mmap_read_offset");
                goto end;
        }
@@ -68,7 +67,7 @@ int lttng_ustconsumer_on_read_subbuffer_mmap(
                if (ret >= len) {
                        len = 0;
                } else if (ret < 0) {
-                       ret = -errno;
+                       errno = -ret;
                        perror("Error in file write");
                        goto end;
                }
@@ -91,7 +90,7 @@ end:
  *
  * Returns the number of bytes spliced.
  */
-int lttng_ustconsumer_on_read_subbuffer_splice(
+ssize_t lttng_ustconsumer_on_read_subbuffer_splice(
                struct lttng_consumer_local_data *ctx,
                struct lttng_consumer_stream *stream, unsigned long len)
 {
@@ -110,7 +109,7 @@ int lttng_ustconsumer_take_snapshot(struct lttng_consumer_local_data *ctx,
 
        ret = ustctl_snapshot(stream->chan->handle, stream->buf);
        if (ret != 0) {
-               ret = errno;
+               errno = -ret;
                perror("Getting sub-buffer snapshot.");
        }
 
@@ -132,7 +131,7 @@ int lttng_ustconsumer_get_produced_snapshot(
        ret = ustctl_snapshot_get_produced(stream->chan->handle,
                        stream->buf, pos);
        if (ret != 0) {
-               ret = errno;
+               errno = -ret;
                perror("kernctl_snapshot_get_produced");
        }
 
@@ -348,7 +347,7 @@ int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
        if (!stream->hangup_flush_done) {
                do {
                        readlen = read(stream->wait_fd, &dummy, 1);
-               } while (readlen == -1 && errno == -EINTR);
+               } while (readlen == -1 && errno == EINTR);
                if (readlen == -1) {
                        ret = readlen;
                        goto end;
This page took 0.024323 seconds and 4 git commands to generate.