diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index ccebd4f61..ec05cd220 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 8951b7567..e8997f0fa 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" diff --git a/src/shared/dlt_offline_trace.c b/src/shared/dlt_offline_trace.c index 1f6a5d576..2d70a77f1 100644 --- a/src/shared/dlt_offline_trace.c +++ b/src/shared/dlt_offline_trace.c @@ -396,7 +396,7 @@ DltReturnValue dlt_offline_trace_write(DltOfflineTrace *trace, int size3) { - if (trace->ohandle <= 0) + if (trace->ohandle < 0) return DLT_RETURN_ERROR; /* check file size here */ @@ -440,7 +440,7 @@ DltReturnValue dlt_offline_trace_write(DltOfflineTrace *trace, DltReturnValue dlt_offline_trace_free(DltOfflineTrace *trace) { - if (trace->ohandle <= 0) + if (trace->ohandle < 0) return DLT_RETURN_ERROR; /* close last used log file */ diff --git a/src/shared/dlt_user_shared.c b/src/shared/dlt_user_shared.c index 857a6e9ab..732301c6d 100644 --- a/src/shared/dlt_user_shared.c +++ b/src/shared/dlt_user_shared.c @@ -108,7 +108,7 @@ DltReturnValue dlt_user_log_out2(int handle, void *ptr1, size_t len1, void *ptr2 struct iovec iov[2]; uint32_t bytes_written; - if (handle <= 0) + if (handle < 0) /* Invalid handle */ return DLT_RETURN_ERROR; @@ -130,7 +130,7 @@ DltReturnValue dlt_user_log_out3(int handle, void *ptr1, size_t len1, void *ptr2 struct iovec iov[3]; uint32_t bytes_written; - if (handle <= 0) + if (handle < 0) /* Invalid handle */ return DLT_RETURN_ERROR; @@ -145,6 +145,11 @@ DltReturnValue dlt_user_log_out3(int handle, void *ptr1, size_t len1, void *ptr2 if (bytes_written != (len1 + len2 + len3)) { switch (errno) { + case ETIMEDOUT: + { + return DLT_RETURN_PIPE_ERROR; /* ETIMEDOUT - connect timeout */ + break; + } case EBADF: { return DLT_RETURN_PIPE_ERROR; /* EBADF - handle not open */