#include "lttng-sessiond.h"
#include "utils.h"
#include <common/utils.h>
+#include <pthread.h>
/*
* Quit pipe for all threads. This permits a single cancellation point
/*
* Wait for a notification on the quit pipe (with a timeout).
*
+ * A timeout value of -1U means no timeout.
+ *
* Returns 1 if the caller should quit, 0 if the timeout was reached, and
* -1 if an error was encountered.
*/
FD_ZERO(&read_fds);
FD_SET(thread_quit_pipe[0], &read_fds);
memset(&timeout, 0, sizeof(timeout));
- timeout.tv_usec = timeout_us;
+ timeout.tv_sec = timeout_us / USEC_PER_SEC;
+ timeout.tv_usec = timeout_us % USEC_PER_SEC;
while (true) {
ret = select(thread_quit_pipe[0] + 1, &read_fds, NULL, NULL,
- &timeout);
+ timeout_us != -1U ? &timeout : NULL);
if (ret < 0 && errno == EINTR) {
/* Retry on interrupt. */
continue;