From: Mathieu Desnoyers Date: Fri, 24 Feb 2012 19:26:30 +0000 (-0500) Subject: Fix: restart consumerd and sessiond when interrupted in poll() X-Git-Tag: v2.0.0-rc2~23 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=a8b0b34167a4d7a46373b463d0744d75f2416bbb;p=lttng-tools.git Fix: restart consumerd and sessiond when interrupted in poll() When poll() is interrupted (e.g. by a debugger attaching), it should restart instead of exiting with an error. Signed-off-by: Mathieu Desnoyers Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index a8156cf12..93417bca0 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -831,8 +831,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 */ @@ -922,8 +929,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; } @@ -993,8 +1007,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; } @@ -1077,8 +1098,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; } @@ -1296,8 +1324,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; } @@ -3594,8 +3629,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; } diff --git a/src/common/consumer.c b/src/common/consumer.c index b605591e4..ec5940105 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -492,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; } @@ -896,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;