summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhong Tran <tranmanphong@gmail.com>2019-06-27 09:07:01 +0700
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2019-06-27 11:07:01 +0900
commitc232148a950c536b99bf91033a78ada6ee6f1771 (patch)
tree39705dc37d9fde70e7a503d2bd647ca66a474848
parentd073bf322cf2f8129c9bce24a3473bf7ddc2b09c (diff)
downloadDLT-daemon-c232148a950c536b99bf91033a78ada6ee6f1771.tar.gz
libdlt: Use posix nanosleep (#144)
Change to use nanosleep instead of usleep. Signed-off-by: Phong Tran <tranmanphong@gmail.com>
-rw-r--r--src/lib/dlt_user.c11
1 files 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 */