From 3f7dc3fd80e7fe548f89b96ab4228135dca688db Mon Sep 17 00:00:00 2001 From: Vo Trung Chi Date: Thu, 1 Aug 2019 07:38:42 +0700 Subject: using POSIX shared memory APIs (#90) (#151) Replace all Linux specific shared memory APIs with POSIX alternatives. Signed-off-by: Vo Trung Chi --- src/lib/dlt_user.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src/lib/dlt_user.c') diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index d040d38..4ae1fde 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -365,16 +365,12 @@ DltReturnValue dlt_init(void) memset(&(dlt_user.dlt_shm), 0, sizeof(DltShm)); /* init shared memory */ - if (dlt_shm_init_client(&(dlt_user.dlt_shm), DLT_SHM_KEY) < 0) { - dlt_vlog(LOG_WARNING, - "Logging disabled, Shared memory %d cannot be created!\n", - DLT_SHM_KEY); - /*return 0; */ - } + if (dlt_shm_init_client(&(dlt_user.dlt_shm), dltShmName) < DLT_RETURN_OK) + dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "Logging disabled," + " Shared memory %s cannot be created!\n", dltShmName); #endif #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 */ /* open before by the DLT daemon => bad failure => return error code */ @@ -382,7 +378,6 @@ DltReturnValue dlt_init(void) return DLT_RETURN_ERROR; #else /* FIFO connection */ - if (dlt_initialize_fifo_connection() != DLT_RETURN_OK) return DLT_RETURN_ERROR; @@ -391,7 +386,6 @@ DltReturnValue dlt_init(void) dlt_user_initialised = false; return DLT_RETURN_ERROR; } - #endif /* These will be lazy initialized only when needed */ @@ -4439,13 +4433,9 @@ void dlt_user_log_reattach_to_daemon(void) #ifdef DLT_SHM_ENABLE /* init shared memory */ - if (dlt_shm_init_client(&dlt_user.dlt_shm, DLT_SHM_KEY) < 0) - dlt_vnlog(LOG_WARNING, - DLT_USER_BUFFER_LENGTH, - "Loging disabled, Shared memory %d cannot be created!\n", - DLT_SHM_KEY); - /*return DLT_RETURN_OK; */ - + if (dlt_shm_init_client(&dlt_user.dlt_shm, dltShmName) < DLT_RETURN_OK) + dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "Logging disabled," + " Shared memory %s cannot be created!\n", dltShmName); #endif dlt_log(LOG_NOTICE, "Logging (re-)enabled!\n"); -- cgit v1.2.1