summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Mohr <alexander.m.mohr@daimler.com>2020-12-16 17:27:58 +0100
committerSaya Sugiura <ssugiura@jp.adit-jv.com>2021-01-06 09:11:21 +0900
commite7858cfa226f760b6f7ba9a43501ac071b2fd8a8 (patch)
treeb035695899bd750af075ac2fd3d1112134e1b5bf
parent6fade05719508d563c083c13e4c9e17257090526 (diff)
downloadDLT-daemon-e7858cfa226f760b6f7ba9a43501ac071b2fd8a8.tar.gz
dlt_user: fix invalid poll timeout
The poll timeout was only set for fifo. TCP connections require this timeout as well. dlt_user_log_check_user_message also validated the file descriptor to be greater 0. Because 0 is a valid file descriptor this check has been changed to greater or equal 0. poll receives a timeout in milliseconds. The given paramter was in nanoseconds. An additional define takes adds the delay in miliseconds. Signed-off-by: Alexander Mohr <alexander.m.mohr@daimler.com>
-rw-r--r--src/lib/dlt_user.c9
-rw-r--r--src/lib/dlt_user_cfg.h3
2 files changed, 5 insertions, 7 deletions
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c
index ccebd4f..ec05cd2 100644
--- a/src/lib/dlt_user.c
+++ b/src/lib/dlt_user.c
@@ -4242,13 +4242,8 @@ DltReturnValue dlt_user_log_check_user_message(void)
nfd[0].events = POLLIN;
nfd[0].fd = fd;
-#if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
- if (fd != DLT_FD_INIT) {
- ret = poll(nfd, 1, -1);
-#else /* DLT_LIB_USE_FIFO_IPC */
- if (fd != DLT_FD_INIT && dlt_user.dlt_log_handle > 0) {
- ret = poll(nfd, 1, DLT_USER_RECEIVE_NDELAY);
-#endif
+ if (fd >= 0) {
+ ret = poll(nfd, 1, DLT_USER_RECEIVE_MDELAY);
if (ret) {
if (nfd[0].revents & (POLLHUP | POLLNVAL | POLLERR)) {
dlt_user.dlt_log_handle = DLT_FD_INIT;
diff --git a/src/lib/dlt_user_cfg.h b/src/lib/dlt_user_cfg.h
index 8951b75..e8997f0 100644
--- a/src/lib/dlt_user_cfg.h
+++ b/src/lib/dlt_user_cfg.h
@@ -126,6 +126,9 @@
/* delay for housekeeper thread (nsec) while receiving messages*/
#define DLT_USER_RECEIVE_NDELAY (500 * 1000 * 1000)
+/* timeout for poll operations in milliseconds*/
+#define DLT_USER_RECEIVE_MDELAY (500)
+
/* Name of environment variable for local print mode */
#define DLT_USER_ENV_LOCAL_PRINT_MODE "DLT_LOCAL_PRINT_MODE"