Fix: restart consumerd and sessiond when interrupted in poll()
[lttng-tools.git] / src / common / consumer.c
index 80dedd5c6cfd057397eef3706ec62ef9717889e7..ec59401053a18bf510c2748fff843b137e5ccee2 100644 (file)
@@ -19,6 +19,7 @@
 
 #define _GNU_SOURCE
 #include <assert.h>
+#include <fcntl.h>
 #include <poll.h>
 #include <pthread.h>
 #include <stdlib.h>
@@ -491,8 +492,15 @@ int lttng_consumer_poll_socket(struct pollfd *consumer_sockpoll)
 {
        int num_rdy;
 
+restart:
        num_rdy = poll(consumer_sockpoll, 2, -1);
        if (num_rdy == -1) {
+               /*
+                * Restart interrupted system call.
+                */
+               if (errno == EINTR) {
+                       goto restart;
+               }
                perror("Poll error");
                goto exit;
        }
@@ -600,7 +608,7 @@ void lttng_consumer_sync_trace_file(
        if (orig_offset < stream->chan->max_sb_size) {
                return;
        }
-       lttng_sync_file_range(outfd, orig_offset - stream->chan->max_sb_size,
+       sync_file_range(outfd, orig_offset - stream->chan->max_sb_size,
                        stream->chan->max_sb_size,
                        SYNC_FILE_RANGE_WAIT_BEFORE
                        | SYNC_FILE_RANGE_WRITE
@@ -741,8 +749,6 @@ int lttng_consumer_on_read_subbuffer_mmap(
                ERR("Unknown consumer_data type");
                assert(0);
        }
-
-       return 0;
 }
 
 /*
@@ -897,10 +903,17 @@ void *lttng_consumer_thread_poll_fds(void *data)
                pthread_mutex_unlock(&consumer_data.lock);
 
                /* poll on the array of fds */
+       restart:
                DBG("polling on %d fd", nb_fd + 1);
                num_rdy = poll(pollfd, nb_fd + 1, consumer_poll_timeout);
                DBG("poll num_rdy : %d", num_rdy);
                if (num_rdy == -1) {
+                       /*
+                        * Restart interrupted system call.
+                        */
+                       if (errno == EINTR) {
+                               goto restart;
+                       }
                        perror("Poll error");
                        lttng_consumer_send_error(ctx, CONSUMERD_POLL_ERROR);
                        goto end;
This page took 0.024667 seconds and 4 git commands to generate.