summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lipka <clipka@jp.adit-jv.com>2016-12-06 16:42:41 +0900
committerSaya Sugiura <ssugiura@jp.adit-jv.com>2019-05-06 15:44:49 +0900
commit4fe69b0927f4c5d0cb3b3ae4fa64500db22b13d0 (patch)
tree74ae0df4109c6f0980e45a3d0b2a29c4dfdc10f2
parent1348d1c07dbda69c32317738b8e9c69734f181c3 (diff)
downloadDLT-daemon-4fe69b0927f4c5d0cb3b3ae4fa64500db22b13d0.tar.gz
unix socket: IPC code isolation
Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com> Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
-rw-r--r--include/dlt/dlt_types.h2
-rw-r--r--include/dlt/dlt_user.h2
-rw-r--r--src/daemon/dlt-daemon.c3
-rw-r--r--src/daemon/dlt_daemon_connection.c2
-rw-r--r--src/lib/dlt_user.c23
5 files changed, 16 insertions, 16 deletions
diff --git a/include/dlt/dlt_types.h b/include/dlt/dlt_types.h
index c47ba50..cddc349 100644
--- a/include/dlt/dlt_types.h
+++ b/include/dlt/dlt_types.h
@@ -178,6 +178,7 @@ typedef enum
typedef float float32_t;
typedef double float64_t;
+#ifdef DLT_USE_UNIX_SOCKET_IPC
/**
* Definition Library connection state
*/
@@ -187,5 +188,6 @@ typedef enum
DLT_USER_CONNECTED,
DLT_USER_RETRY_CONNECT
} DltUserConnectionState;
+#endif
#endif /* DLT_TYPES_H */
diff --git a/include/dlt/dlt_user.h b/include/dlt/dlt_user.h
index b885eaf..a5199b4 100644
--- a/include/dlt/dlt_user.h
+++ b/include/dlt/dlt_user.h
@@ -240,7 +240,9 @@ typedef struct
int corrupt_message_size;
int16_t corrupt_message_size_size;
# endif
+# ifdef DLT_USE_UNIX_SOCKET_IPC
DltUserConnectionState connection_state;
+# endif
uint16_t log_buf_len; /**< length of message buffer, by default: DLT_USER_BUF_MAX_SIZE */
} DltUser;
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 */