diff options
author | ManikandanC <Manikandan.Chockalingam@in.bosch.com> | 2016-10-18 15:43:44 +0530 |
---|---|---|
committer | Christoph Lipka <clipka@users.noreply.github.com> | 2018-12-21 10:16:46 +0100 |
commit | e3c2501313d98ff9f4519116e6d2f36314e0240e (patch) | |
tree | d1472ee7047b598b4b25bb7c06748eaa6f9f61cf /src/daemon | |
parent | 2262f8b3406ac903a37f96a63c6250de215d1866 (diff) | |
download | DLT-daemon-e3c2501313d98ff9f4519116e6d2f36314e0240e.tar.gz |
UnitTest: Updates
Gateway
Logstorage
Event Handler
Signed-off-by: Christoph Lipka <clipka@de.adit-jv.com>
Signed-off-by: S. Hameed <shameed@jp.adit-jv.com>
Signed-off-by: Aditya Paluri <venkataaditya.paluri@in.bosch.com>
Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com>
Diffstat (limited to 'src/daemon')
-rw-r--r-- | src/daemon/CMakeLists.txt | 10 | ||||
-rw-r--r-- | src/daemon/dlt-daemon.c | 6 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_client.c | 22 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_common.h | 1 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_connection.c | 3 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_connection_types.h | 3 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_event_handler.c | 6 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_offline_logstorage.c | 1 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_offline_logstorage_internal.h | 77 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_socket.c | 4 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_socket.h | 2 |
11 files changed, 114 insertions, 21 deletions
diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index e9fb2ba..a2f6e38 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -45,6 +45,15 @@ install(TARGETS dlt-daemon COMPONENT base) if (WITH_DLT_UNIT_TESTS) + if (WITH_DLT_FILTER_BACKEND_PROP) + add_library(dlt_daemon ${dlt_daemon_SRCS} ${dlt_prop_backend_SRCS} ${systemd_SRCS}) + target_link_libraries(dlt_daemon ald_plugin rt ${CMAKE_THREAD_LIBS_INIT}) + install(TARGETS dlt_daemon + RUNTIME DESTINATION bin + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static + COMPONENT base) + else() add_library(dlt_daemon ${dlt_daemon_SRCS}) target_link_libraries(dlt_daemon ${RT_LIBRARY} ${SOCKET_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) install(TARGETS dlt_daemon @@ -52,6 +61,7 @@ if (WITH_DLT_UNIT_TESTS) LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static COMPONENT base) + endif(WITH_DLT_FILTER_BACKEND_PROP) endif(WITH_DLT_UNIT_TESTS) INSTALL(FILES dlt.conf diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index 774573e..9e99c74 100644 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -810,6 +810,8 @@ int main(int argc, char* argv[]) dlt_daemon_local_cleanup(&daemon, &daemon_local, daemon_local.flags.vflag); + dlt_gateway_deinit(&daemon_local.pGateway, daemon_local.flags.vflag); + dlt_daemon_free(&daemon, daemon_local.flags.vflag); dlt_log(LOG_NOTICE, "Leaving DLT daemon\n"); @@ -1488,9 +1490,9 @@ void dlt_daemon_daemonize(int verbose) This is a dlt-daemon only function. The libdlt has no equivalent function available. */ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, char *str, int verbose) { - DltMessage msg; + DltMessage msg = {0}; static uint8_t uiMsgCount = 0; - DltStandardHeaderExtra *pStandardExtra; + DltStandardHeaderExtra *pStandardExtra = NULL; uint32_t uiType; uint16_t uiSize; uint32_t uiExtraSize; diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c index 120d2af..55b775b 100644 --- a/src/daemon/dlt_daemon_client.c +++ b/src/daemon/dlt_daemon_client.c @@ -110,10 +110,9 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon, int verbose) { int j, sent = 0; - DltConnection* temp = NULL; + DltConnection *temp = NULL; int type_mask = (DLT_CON_MASK_CLIENT_MSG_TCP | DLT_CON_MASK_CLIENT_MSG_SERIAL); - char local_str[DLT_DAEMON_TEXTBUFSIZE]; uint8_t *tmp_buffer = NULL; if ((daemon == NULL) || (daemon_local == NULL)) @@ -144,13 +143,19 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon, DLT_DAEMON_SEM_FREE(); if ((ret != DLT_DAEMON_ERROR_OK) && - DLT_CONNECTION_CLIENT_MSG_TCP == temp->type) + (DLT_CONNECTION_CLIENT_MSG_TCP == temp->type)) { if (daemon->state != DLT_DAEMON_STATE_BUFFER_FULL) { if (temp->receiver->bytes_sent < (size1 + size2)) { tmp_buffer = (uint8_t*)calloc(size1 + size2, sizeof(uint8_t)); + + if (tmp_buffer == NULL) + { + dlt_vlog(LOG_ERR, "%s: Memory allocation failed.\n", __func__); + return 0; + } memcpy(tmp_buffer, data1, size1); memcpy(tmp_buffer + size1, data2, size2); DLT_DAEMON_SEM_LOCK(); @@ -158,10 +163,7 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon, if (dlt_buffer_push3(&(daemon->client_ringbuffer), tmp_buffer + temp->receiver->bytes_sent, (size1 + size2 - temp->receiver->bytes_sent), - 0, - 0, - 0, - 0) < DLT_RETURN_OK) + 0, 0, 0, 0) < DLT_RETURN_OK) { dlt_vlog(LOG_DEBUG, "%s: Buffer is full! Message discarded.\n", __func__); dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER_FULL); @@ -178,11 +180,7 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon, if (ret != DLT_DAEMON_ERROR_OK) { - snprintf(local_str, - DLT_DAEMON_TEXTBUFSIZE, - "%s: send dlt message failed\n", - __func__); - dlt_log(LOG_WARNING, local_str); + dlt_vlog(LOG_WARNING, "%s: send dlt message failed\n", __func__); } else { diff --git a/src/daemon/dlt_daemon_common.h b/src/daemon/dlt_daemon_common.h index bd81e0d..4110a72 100644 --- a/src/daemon/dlt_daemon_common.h +++ b/src/daemon/dlt_daemon_common.h @@ -233,6 +233,7 @@ DltDaemonRegisteredUsers *dlt_daemon_find_users_list(DltDaemon *daemon, int dlt_daemon_load_runtime_configuration(DltDaemon *daemon, const char *runtime_directory, int verbose); + /** * Add (new) application to internal application management * @param daemon pointer to dlt daemon structure diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c index e0cb003..c9e7be7 100644 --- a/src/daemon/dlt_daemon_connection.c +++ b/src/daemon/dlt_daemon_connection.c @@ -62,7 +62,8 @@ extern char *app_recv_buffer; * @param msg The message buffer to be sent * @param msg_size The length of the message to be sent * - * @return The amount of bytes send on success, -1 otherwise. + * @return DLT_DAEMON_ERROR_OK on success, DLT_DAEMON_ERROR_SEND_FAILED + * on send failure, DLT_DAEMON_ERROR_UNKNOWN otherwise. * errno is appropriately set. */ DLT_STATIC int dlt_connection_send(DltConnection *conn, diff --git a/src/daemon/dlt_daemon_connection_types.h b/src/daemon/dlt_daemon_connection_types.h index 68a0400..560f7f9 100644 --- a/src/daemon/dlt_daemon_connection_types.h +++ b/src/daemon/dlt_daemon_connection_types.h @@ -40,7 +40,8 @@ typedef enum { } DltConnectionStatus; typedef enum { - DLT_CONNECTION_CLIENT_CONNECT = 0, + DLT_CONNECTION_NONE = 0, + DLT_CONNECTION_CLIENT_CONNECT, DLT_CONNECTION_CLIENT_MSG_TCP, DLT_CONNECTION_CLIENT_MSG_SERIAL, DLT_CONNECTION_APP_CONNECT, diff --git a/src/daemon/dlt_daemon_event_handler.c b/src/daemon/dlt_daemon_event_handler.c index 35b85c0..029e938 100644 --- a/src/daemon/dlt_daemon_event_handler.c +++ b/src/daemon/dlt_daemon_event_handler.c @@ -473,7 +473,11 @@ int dlt_connection_check_activate(DltEventHandler *evhdl, dlt_log(LOG_INFO, local_str); dlt_event_handler_disable_fd(evhdl, con->receiver->fd); - + + if (con->type == DLT_CONNECTION_CLIENT_CONNECT) + { + con->receiver->fd = -1; + } con->status = INACTIVE; } break; diff --git a/src/daemon/dlt_daemon_offline_logstorage.c b/src/daemon/dlt_daemon_offline_logstorage.c index b99944d..86d4b5e 100644 --- a/src/daemon/dlt_daemon_offline_logstorage.c +++ b/src/daemon/dlt_daemon_offline_logstorage.c @@ -26,6 +26,7 @@ #include <syslog.h> #include "dlt_daemon_offline_logstorage.h" +#include "dlt_daemon_offline_logstorage_internal.h" #include "dlt_gateway_types.h" #include "dlt_gateway.h" diff --git a/src/daemon/dlt_daemon_offline_logstorage_internal.h b/src/daemon/dlt_daemon_offline_logstorage_internal.h new file mode 100644 index 0000000..4c1f828 --- /dev/null +++ b/src/daemon/dlt_daemon_offline_logstorage_internal.h @@ -0,0 +1,77 @@ +/** + * @licence app begin@ + * Copyright (C) 2017 Advanced Driver Information Technology. + * This code is developed by Advanced Driver Information Technology. + * Copyright of Advanced Driver Information Technology, Bosch and DENSO. + * + * DLT offline log storage functionality internal header file. + * + * \copyright + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * + * \author Aditya Paluri <venkataaditya.paluri@in.bosch.com> ADIT 2017 + * + * \file: dlt_daemon_offline_logstorage_internal.h + * For further information see http://www.genivi.org/. + * @licence end@ + */ + +/******************************************************************************* + * ** + * SRC-MODULE: dlt_daemon_offline_logstorage_internal.h ** + * ** + * TARGET : linux ** + * ** + * PROJECT : DLT ** + * ** + * AUTHOR : Aditya Paluri venkataaditya.paluri@in.bosch.com ** + * PURPOSE : ** + * ** + * REMARKS : ** + * ** + * PLATFORM DEPENDANT [yes/no]: yes ** + * ** + * TO BE CHANGED BY USER [yes/no]: no ** + * ** + ******************************************************************************/ + +/******************************************************************************* +* Author Identity ** +******************************************************************************* +* ** +* Initials Name Company ** +* -------- ------------------------- ---------------------------------- ** +* ap Aditya Paluri ADIT ** +*******************************************************************************/ + +#ifndef DLT_DAEMON_OFFLINE_LOGSTORAGE_INTERNAL_H +#define DLT_DAEMON_OFFLINE_LOGSTORAGE_INTERNAL_H + +DLT_STATIC DltReturnValue dlt_logstorage_split_key(char *key, char *appid, char *ctxid, char *ecuid); + +DltReturnValue dlt_logstorage_update_all_contexts(DltDaemon *daemon, + DltDaemonLocal *daemon_local, + char *id, + int curr_log_level, + int cmp_flag, + char *ecuid, + int verbose); + +DltReturnValue dlt_logstorage_update_context(DltDaemon *daemon, + DltDaemonLocal *daemon_local, + char *apid, + char *ctxid, + char *ecuid, + int curr_log_level, + int verbose); + +int dlt_logstorage_update_context_loglevel(DltDaemon *daemon, + DltDaemonLocal *daemon_local, + char *key, + int curr_log_level, + int verbose); + +#endif diff --git a/src/daemon/dlt_daemon_socket.c b/src/daemon/dlt_daemon_socket.c index c85798f..f51d803 100644 --- a/src/daemon/dlt_daemon_socket.c +++ b/src/daemon/dlt_daemon_socket.c @@ -161,7 +161,6 @@ int dlt_daemon_socket_send(int sock,void* data1,int size1,void* data2,int size2, } /* Send data */ - if ((data1 != NULL) && (size1 > 0)) { ret = dlt_daemon_socket_sendreliable(sock, data1, size1, &bytes_sent); @@ -183,7 +182,7 @@ int dlt_daemon_socket_get_send_qeue_max_size(int sock) { int n = 0; socklen_t m = sizeof(n); - getsockopt(sock,SOL_SOCKET,SO_SNDBUF,(void *)&n, &m); + getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (void *)&n, &m); return n; } @@ -213,4 +212,3 @@ int dlt_daemon_socket_sendreliable(int sock, void* data_buffer, int message_size return DLT_DAEMON_ERROR_OK; } - diff --git a/src/daemon/dlt_daemon_socket.h b/src/daemon/dlt_daemon_socket.h index a94990f..3765c70 100644 --- a/src/daemon/dlt_daemon_socket.h +++ b/src/daemon/dlt_daemon_socket.h @@ -67,7 +67,7 @@ int dlt_daemon_socket_close(int sock); int dlt_daemon_socket_get_send_qeue_max_size(int sock); -int dlt_daemon_socket_send(int sock,void* data1,int size1,void* data2,int size2,char serialheader); +int dlt_daemon_socket_send(int sock, void* data1, int size1, void* data2, int size2, char serialheader); /** * @brief dlt_daemon_socket_sendreliable - sends data to socket with additional checks and resending functionality - trying to be reliable |