From c232148a950c536b99bf91033a78ada6ee6f1771 Mon Sep 17 00:00:00 2001 From: Phong Tran Date: Thu, 27 Jun 2019 09:07:01 +0700 Subject: libdlt: Use posix nanosleep (#144) Change to use nanosleep instead of usleep. Signed-off-by: Phong Tran --- src/lib/dlt_user.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index c5be77c..e0939b1 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -2798,8 +2798,12 @@ void dlt_user_trace_network_segmented_thread(void *unused) if (read < 0) { if (errno != EINTR) { + struct timespec req; + long sec = (DLT_USER_MQ_ERROR_RETRY_INTERVAL / 1000000); dlt_vlog(LOG_WARNING, "NWTSegmented: Error while reading queue: %s\n", strerror(errno)); - usleep(DLT_USER_MQ_ERROR_RETRY_INTERVAL); + req.tv_sec = sec; + req.tv_nsec = (DLT_USER_MQ_ERROR_RETRY_INTERVAL - sec * 1000000) * 1000; + nanosleep(&req, NULL); } continue; @@ -2816,8 +2820,11 @@ void dlt_user_trace_network_segmented_thread(void *unused) /* Indicator just to try to flush the buffer */ /* DLT_NW_TRACE_RESEND custom type is used to mark a resend */ if(data->nw_trace_type == DLT_NW_TRACE_RESEND) { + struct timespec req; /* Sleep 100ms, to allow other process to read FIFO */ - usleep(100 * 1000); + req.tv_sec = 0; + req.tv_nsec = 100 * 1000 * 1000; + nanosleep(&req, NULL); if (dlt_user_log_resend_buffer() < 0) { /* Requeue if still not empty */ -- cgit v1.2.1