From 4fe69b0927f4c5d0cb3b3ae4fa64500db22b13d0 Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Tue, 6 Dec 2016 16:42:41 +0900 Subject: unix socket: IPC code isolation Signed-off-by: Christoph Lipka Signed-off-by: Vo Trung Chi --- src/daemon/dlt-daemon.c | 3 +-- src/daemon/dlt_daemon_connection.c | 2 ++ src/lib/dlt_user.c | 23 +++++++++-------------- 3 files changed, 12 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index 79b4058..a8404fd 100644 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -2763,8 +2763,7 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon, int verbose) { char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' }; - int j, sent, third_value; - ssize_t ret; + int sent; uint8_t *rcv_buffer = NULL; int size; uint32_t len = sizeof(DltUserHeader); diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c index 669a7b1..2fe17c1 100644 --- a/src/daemon/dlt_daemon_connection.c +++ b/src/daemon/dlt_daemon_connection.c @@ -232,8 +232,10 @@ DLT_STATIC DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local } break; +#ifdef DLT_USE_UNIX_SOCKET_IPC case DLT_CONNECTION_APP_CONNECT: /* FALL THROUGH */ +#endif case DLT_CONNECTION_ONE_S_TIMER: /* FALL THROUGH */ case DLT_CONNECTION_SIXTY_S_TIMER: diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index b074172..1c1bbd8 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -331,17 +331,11 @@ static DltReturnValue dlt_initialize_fifo_connection(void) dlt_user.dlt_log_handle = open(dlt_daemon_fifo, O_WRONLY | O_NONBLOCK | O_CLOEXEC); if (dlt_user.dlt_log_handle == -1) { - - if (dlt_user.connection_state != DLT_USER_RETRY_CONNECT) { - /* This is a normal usecase. It is OK that the daemon (and thus the FIFO /tmp/dlt) - * starts later and some DLT users have already been started before. - * Thus it is OK if the FIFO can't be opened. */ - dlt_vnlog(LOG_INFO, DLT_USER_BUFFER_LENGTH, "FIFO %s cannot be opened. Retrying later...\n", - dlt_daemon_fifo); - dlt_user.connection_state = DLT_USER_RETRY_CONNECT; - } - - /*return DLT_RETURN_OK; */ + /* This is a normal usecase. It is OK that the daemon (and thus the FIFO /tmp/dlt) + * starts later and some DLT users have already been started before. + * Thus it is OK if the FIFO can't be opened. */ + dlt_vnlog(LOG_INFO, DLT_USER_BUFFER_LENGTH, "FIFO %s cannot be opened. Retrying later...\n", + dlt_daemon_fifo); } return DLT_RETURN_OK; @@ -381,8 +375,9 @@ DltReturnValue dlt_init(void) dlt_log(LOG_WARNING, str); /*return 0; */ } +#endif -#elif defined DLT_USE_UNIX_SOCKET_IPC +#ifdef DLT_USE_UNIX_SOCKET_IPC if (dlt_initialize_socket_connection() != DLT_RETURN_OK) /* We could connect to the pipe, but not to the socket, which is normally */ @@ -395,8 +390,6 @@ DltReturnValue dlt_init(void) if (dlt_initialize_fifo_connection() != DLT_RETURN_OK) return DLT_RETURN_ERROR; - dlt_user.connection_state = DLT_USER_CONNECTED; - if (dlt_receiver_init(&(dlt_user.receiver), dlt_user.dlt_user_handle, DLT_USER_RCVBUF_MAX_SIZE) == DLT_RETURN_ERROR) { dlt_user_initialised = false; @@ -3793,7 +3786,9 @@ DltReturnValue dlt_user_log_send_log(DltContextData *log, int mtype) /* handle not open or pipe error */ close(dlt_user.dlt_log_handle); dlt_user.dlt_log_handle = -1; +#ifdef DLT_USE_UNIX_SOCKET_IPC dlt_user.connection_state = DLT_USER_RETRY_CONNECT; +#endif #ifdef DLT_SHM_ENABLE /* free shared memory */ -- cgit v1.2.1