From 6612d11aed331c0141a040dfd0442534406a9b7e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 23 Apr 2015 13:07:38 -0400 Subject: [PATCH] Fix: Don't wait during registration if clock_gettime() fails MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit get_constructor_timeout() currently returns -1 which, according to the lttng-ust(3) man page and lttng_ust_init() implementation, "waits forever". This changes the behavior to match what is expressed in the comments. Comments in get_constructor_timeout() and get_timeout() are also modified to match the following convention: -1: wait forever 0: don't wait 1: wait for "constructor_delay_ms" Signed-off-by: Jérémie Galarneau Signed-off-by: Mathieu Desnoyers --- liblttng-ust/lttng-ust-comm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index 378ca21c..f40683d3 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -399,7 +399,7 @@ int setup_local_apps(void) /* * Get notify_sock timeout, in ms. - * -1: don't wait. 0: wait forever. >0: timeout, in ms. + * -1: wait forever. 0: don't wait. >0: timeout, in ms. */ static long get_timeout(void) @@ -422,7 +422,7 @@ long get_notify_sock_timeout(void) } /* - * Return values: -1: don't wait. 0: wait forever. 1: timeout wait. + * Return values: -1: wait forever. 0: don't wait. 1: timeout wait. */ static int get_constructor_timeout(struct timespec *constructor_timeout) @@ -445,7 +445,8 @@ int get_constructor_timeout(struct timespec *constructor_timeout) */ ret = clock_gettime(CLOCK_REALTIME, constructor_timeout); if (ret) { - return -1; + /* Don't wait. */ + return 0; } constructor_timeout->tv_sec += constructor_delay_ms / 1000UL; constructor_timeout->tv_nsec += @@ -454,6 +455,7 @@ int get_constructor_timeout(struct timespec *constructor_timeout) constructor_timeout->tv_sec++; constructor_timeout->tv_nsec -= 1000000000UL; } + /* Timeout wait (constructor_delay_ms). */ return 1; } -- 2.34.1