Fix: restart consumerd and sessiond when interrupted in poll()
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 24 Feb 2012 19:26:30 +0000 (14:26 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 24 Feb 2012 19:26:30 +0000 (14:26 -0500)
When poll() is interrupted (e.g. by a debugger attaching), it should
restart instead of exiting with an error.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/bin/lttng-sessiond/main.c
src/common/consumer.c

index dfe608cba27e29259ff29ca953edf8e6596d5cf6..1fc875576dd0a4ebd28ef715e2b1313f6db95522 100644 (file)
@@ -839,8 +839,15 @@ static void *thread_manage_kernel(void *data)
                lttng_poll_reset(&events);
 
                /* Poll infinite value of time */
+       restart:
                ret = lttng_poll_wait(&events, -1);
                if (ret < 0) {
+                       /*
+                        * Restart interrupted system call.
+                        */
+                       if (errno == EINTR) {
+                               goto restart;
+                       }
                        goto error;
                } else if (ret == 0) {
                        /* Should not happen since timeout is infinite */
@@ -930,8 +937,15 @@ static void *thread_manage_consumer(void *data)
        nb_fd = LTTNG_POLL_GETNB(&events);
 
        /* Inifinite blocking call, waiting for transmission */
+restart:
        ret = lttng_poll_wait(&events, -1);
        if (ret < 0) {
+               /*
+                * Restart interrupted system call.
+                */
+               if (errno == EINTR) {
+                       goto restart;
+               }
                goto error;
        }
 
@@ -1001,8 +1015,15 @@ static void *thread_manage_consumer(void *data)
        nb_fd = LTTNG_POLL_GETNB(&events);
 
        /* Inifinite blocking call, waiting for transmission */
+restart_poll:
        ret = lttng_poll_wait(&events, -1);
        if (ret < 0) {
+               /*
+                * Restart interrupted system call.
+                */
+               if (errno == EINTR) {
+                       goto restart_poll;
+               }
                goto error;
        }
 
@@ -1085,8 +1106,15 @@ static void *thread_manage_apps(void *data)
                DBG("Apps thread polling on %d fds", nb_fd);
 
                /* Inifinite blocking call, waiting for transmission */
+       restart:
                ret = lttng_poll_wait(&events, -1);
                if (ret < 0) {
+                       /*
+                        * Restart interrupted system call.
+                        */
+                       if (errno == EINTR) {
+                               goto restart;
+                       }
                        goto error;
                }
 
@@ -1304,8 +1332,15 @@ static void *thread_registration_apps(void *data)
                nb_fd = LTTNG_POLL_GETNB(&events);
 
                /* Inifinite blocking call, waiting for transmission */
+       restart:
                ret = lttng_poll_wait(&events, -1);
                if (ret < 0) {
+                       /*
+                        * Restart interrupted system call.
+                        */
+                       if (errno == EINTR) {
+                               goto restart;
+                       }
                        goto error;
                }
 
@@ -3607,8 +3642,15 @@ static void *thread_manage_clients(void *data)
                nb_fd = LTTNG_POLL_GETNB(&events);
 
                /* Inifinite blocking call, waiting for transmission */
+       restart:
                ret = lttng_poll_wait(&events, -1);
                if (ret < 0) {
+                       /*
+                        * Restart interrupted system call.
+                        */
+                       if (errno == EINTR) {
+                               goto restart;
+                       }
                        goto error;
                }
 
index 80dedd5c6cfd057397eef3706ec62ef9717889e7..2e5ec5c35de08459d0b77b2d224f14ae90632bb3 100644 (file)
@@ -491,8 +491,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;
        }
@@ -897,10 +904,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.041602 seconds and 4 git commands to generate.