summaryrefslogtreecommitdiff
path: root/src/lib/dlt_user.c
Commit message (Collapse)AuthorAgeFilesLines
* Add verbose mode attribute handling (#292)Martin Willers2021-03-161-502/+357
| | | | | | dlt_user_log_write_*_attr() enables to writing these types, but also support adding "attributes" for them, i.e. a "name" and a "unit". Signed-off-by: Martin Willers <M.Willers@gmx.net>
* other: fix remaining conversion warningsDinh Cong Toan2021-01-061-12/+12
| | | | | | | | | | | - Converting datatype to the correct one. - As macro do not perform type-checking before, so these functions used it with different datatype could create a lot of conversion warnings. For this reason, these warnings could be consider as normal information and will not be fixed. Signed-off-by: Dinh Cong Toan <toan.dinhcong@vn.bosch.com>
* library: fix conversion warningsDinh Cong Toan(RBVH/ECM12)2021-01-061-57/+59
| | | | | | | | | | | | - Change the data type of variable 'size' in DltContextData struct (dlt_user.h.in). Variable 'size' was used repeated with function 'sizeof()' many time, so change type to 'size_t' can avoid a lot of warnings. - Adding temporary variable to calculate the datasize header (define in dlt_common.h) in 'dlt_common.c' file. Signed-off-by: Dinh Cong Toan(RBVH/ECM12) <Toan.DinhCong@vn.bosch.com>
* gateway: fix compile warningsDinh Cong Toan(RBVH/ECM12)2021-01-061-6/+6
| | | | | | | | | - Correct the data type of 'headersize' and 'datasize' variables in header 'dlt_common.h', then config those functions using this library. - Explicit the data type. Signed-off-by: Dinh Cong Toan(RBVH/ECM12) <Toan.DinhCong@vn.bosch.com>
* libdlt: Use SIGUSR1 for thread on AndroidBui Nguyen Quoc Thanh2021-01-061-2/+33
| | | | | | | Since bionic does not support pthread_cancel(), try to terminate housekeeper thread via SIGUSR1. Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* libdlt: Use poll to avoid CPU high loadBui Nguyen Quoc Thanh2021-01-061-29/+49
| | | | | | | | | | | | | Use timeout of polling as time for retry. In case of timeout or failure of polling, continue to close the socket. It could take some times to get the socket is shutdown So it means there could be some data available to read. Try to consume the data and poll the socket again. If read fails, time to close the socket then. Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* libdlt: Flush all data in atexit_handlerSaya Sugiura2021-01-061-13/+43
| | | | | | | | | | | | | | | | | Current implementation had two issues: - Remaining data in startup_buffer wasn't able to be sent to daemon even dlt_user.timeout_at_exit_handler was set to more than 0 - Socket could be closed before all the data was sent to daemon To solve this: - dlt_unregister_app_flush_buffered_logs() won't clean appIDs if any data is remaining in startup_buffer. atexit_handler will be in charge of cleaning them - Socket won't be closed if data wasn't sent due to errno EAGAIN or EWOULDBLOCK. It retries until execution count reaches to maximum DLT_USER_MAX_RETRY_COUNT (1000 as default) Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* libdlt: disable injection msg via env varBui Nguyen Quoc Thanh2021-01-061-3/+10
| | | | | | | | | | | | | | In order to disable injection message at dlt user, set DLT_DISABLE_INJECTION_MSG_AT_USER to any value. When injection message is disabled, libdlt won't poll any data from receiver. It means libdlt will ignore all data/messages from dlt-daemon. By default, variable is unset so that dlt users are able to handle data/messages from dlt-daemon. Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* dlt_user: fix invalid poll timeoutAlexander Mohr2021-01-061-7/+2
| | | | | | | | | | | | | | The poll timeout was only set for fifo. TCP connections require this timeout as well. dlt_user_log_check_user_message also validated the file descriptor to be greater 0. Because 0 is a valid file descriptor this check has been changed to greater or equal 0. poll receives a timeout in milliseconds. The given paramter was in nanoseconds. An additional define takes adds the delay in miliseconds. Signed-off-by: Alexander Mohr <alexander.m.mohr@daimler.com>
* Add support for logging with VSOCK (#255)Martin Ejdestig2020-12-141-37/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For more information about VSOCK, see "man vsock" ( https://man7.org/linux/man-pages/man7/vsock.7.html ). Makes it possible for processes in a virtual machine to log directly in DLT running on host without setting up a network connection between guest and host. It is also probably more efficient. Have not done any performance measurements (not main reason for patch), but no forwarding is required as when running DLT in a multi-node setup. When building dlt-daemon for host, WITH_DLT_DAEMON_VSOCK_IPC should be enabled for daemon to listen on incoming VSOCK requests. Local communication method between applications and daemon is still determined with DLT_IPC. When building for guest, WITH_DLT_LIB_VSOCK_IPC should be enabled and DLT_IPC will be ignored, which will make libdlt open a VSOCK socket to the deamon for logging messages. VSOCK can be tested without a virtual machine. Since VMADDR_CID_HOST is used by libdlt when connecting, see vsock man page, clients can be run on host to test VSOCK communication. Some modifications has been done to be able to handle logging through FIFO pipe and socket in the same build of dlt-daemon: - dlt_receiver_init/free_unix_socket() is renamed to dlt_receiver_init/free_global_buffer() and used for FIFO as well. Also fixes memory leak since dlt_receiver_free_unix_socket() was used regardless of whether DLT_USE_UNIX_SOCKET was defined or not. - Pass type to dlt_receiver_init() instead of dlt_receiver_receive(). And remove preprocessor conditionals for handling DLT_CONNECTION_APP_MSG in dlt_daemon_process_user_messages(). Also fixes wrong enum type being passed to dlt_receiver_receive() in dlt_client.c (DltClient::mode was used as a DltReceiverType enum but it is a DltClientMode enum). - Add a flag to DltDaemonApplication to indicate whether file descriptor is "owned" by the DltDaemonApplication or not. When dlt_daemon_application_add() is called due to message received on a socket, fd is passed as an argument (app does not own fd). For FIFO, a per application FIFO is opened (app owns the fd). Also fixes so that user handle is reset for both application and all its contexts when resetting any. Prevents fd from being used by accident after it has been closed. dlt_mkdir_recursive() is moved to src/daemon since it is only used in the daemon. Minimizes use of DLT_USE_UNIX_SOCKET_IPC. Other bugfixes: - Call DLT_SEM_FREE() if setting socket to O_NONBLOCK fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). - Close socket if dlt_receiver_init() fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). Signed-off-by: Martin Ejdestig <martin.ejdestig@volvocars.com>
* dlt_user.c: fix the lack of DLT_NETWORK_TRACE_ENABLE definitionKHANH LUONG HONG DUY2020-08-031-0/+2
| | | | Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* network trace: Fix macro usageKHANH LUONG HONG DUY2020-07-061-1/+1
| | | | Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* libdlt: Relocate dltFifoBaseDir settingLUONG HONG DUY KHANH(RBVH/ENG42)2020-07-061-3/+0
| | | | | | | Relocate the setting of dltFifoBaseDir variable from dlt_init() to dlt_check_envvar() Signed-off-by: LUONG HONG DUY KHANH(RBVH/ENG42) <KHANH.LUONGHONGDUY@vn.bosch.com>
* network trace: Add mqueue verificationSaya Sugiura2020-07-061-18/+29
| | | | | | | | | | There is some OS (e.g. Android) which doesn't support message queue. Since network trace uses it as IPC, we need to disable it if following calls are not available: mq_open, mq_close, mq_unlink, mq_send, mq_receive Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* relocation dlt_check_envvar() and update dlt_init() functionsLUONG HONG DUY KHANH(RBVH/ENG42)2020-07-061-6/+6
| | | | Signed-off-by: LUONG HONG DUY KHANH(RBVH/ENG42) <KHANH.LUONGHONGDUY@vn.bosch.com>
* fix some gcc9 compiler warningsFelix Herrmann2020-07-061-31/+30
| | | | | | | | | Many stringop-truncation and stringop-overflow warnings are still there (so many). https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/ Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* Android: Enable Android buildFelix Herrmann2020-07-061-5/+31
| | | | | Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* correct errno usage in dlt_stop_threadsVo Trung Chi2020-07-061-11/+6
| | | | | | | | | | | Most pthreads functions return 0 on success, and an error number on failure. Note that the pthreads functions do not set errno. Refer to man page of pthreads for detail. So we have to use the return value as the error number instead of errno variable. Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
* FIX: prevent usage of uninitialized message queue handleRudolf Svanda2020-05-181-1/+3
| | | | | | | | | Problem occurs always if application exits and dlt_user.dlt_segmented_queue_read_handle is not initialized. Warning "NWTSegmented: Error while reading queue" is printed on terminal on embedded devices. Signed-off-by: Rudolf Svanda <rudolf.svanda@globallogic.com>
* Minor optimizationMartin Willers2020-05-181-1/+1
| | | | | | | There is no need to have both an array and a pointer to it; just use the array directly. Signed-off-by: Martin Willers <M.Willers@gmx.net>
* Add functions for writing strings with known sizesMartin Willers2020-05-181-0/+16
| | | | Signed-off-by: Martin Willers <M.Willers@gmx.net>
* Add helper function for writing strings with known sizesMartin Willers2020-05-181-3/+17
| | | | | | | | | | | This use case is common in C++ code nowadays, due to the usage of e.g. std::string_view, which does not provide a function for retrieving a null-terminated C-string, but which provides quick access to the string length via std::string_view::size(). Such use cases can now avoid an entirely unnecessary strlen() call. Signed-off-by: Martin Willers <M.Willers@gmx.net>
* sys/poll.h: deprecate old sys/poll.h include header, now glibc/musl wants ↵Gianfranco Costamagna2020-01-271-1/+1
| | | | | | | | | poll.h being included directly. This fixes a build failure on musl systems with strict c hardening flags Signed-off-by: Gianfranco Costamagna <costamagnagianfranco@yahoo.it> Signed-off-by: Gianfranco Costamagna <locutusofborg@debian.org>
* dlt_user: init DltContextData before usePhong Tran2019-12-111-5/+4
| | | | | | | | for fixing the coverity warnings type Uninitialized scalar variable (UNINIT). Using uninitialized value log.use_timestamp when calling dlt_user_log_send_log. Signed-off-by: Phong Tran <tranmanphong@gmail.com>
* Provide DLT_GET_APPID macro (#187) (#188)Vo Trung Chi2019-11-141-0/+11
| | | Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
* libdlt: reattachment and improvement in dlt thread (#171)Vo Trung Chi2019-10-011-108/+59
| | | | | | | | | | | | | | | | | Improvement: housekeeper thread with poll - Change name receiver thread to housekeeper thread - Use poll() in housekeeper thread to get new received message from DLT Daemon. - Remove resend buffer inside of dlt_user_log_reattach_to_daemon() - Only try to resend buffer if fd is valid. This commit removes the event driven dlt_user_log_reattach_to_daemon() that is called e.g. by DLT_LOG. Now, only the DLT housekeeper thread handles the retrial to attach to daemon. Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com> Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com> Signed-off-by: Simon Herkenhoff <sherkenhoff@jp.adit-jv.com> Signed-off-by: Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com>
* libdlt: calculate resend buffer memoryBui Nguyen Quoc Thanh2019-09-131-19/+29
| | | | | | | | | | | | | | The fix from commit 376bf6c is considered as a workaround. From now, the resend buffer size is calculated based on (dlt_user.log_buf_len + header_size) - Remove the macro DLT_USER_EXTRA_BUFF_SIZE - Use env_disable_extended_header_for_nonverbose instead of env_nonverbose_extended_header Related commit: 376bf6c Size of Resend buffer less than or equal to DLT_USER_BUF_MAX_SIZE res… (#116) Signed-off-by: Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com>
* lib: Disable extended header in non verbose mode by env varOnkar Palkar2019-09-131-0/+11
| | | | | | | dlt-test-non-verbose test application is also added. Signed-off-by: Onkar Palkar <onkar.palkar@wipro.com> Signed-off-by: S. Hameed <shameed@jp.adit-jv.com>
* shm: Resend dlt msg when client connectVo Trung Chi2019-09-131-7/+0
| | | | | | | | After dlt-client connects to dlt-daemon successfully, all the stored dlt messages in daemon was not flushed to dlt client when using shared memory as IPC. It is harmonized with dlt_daemon_process_user_message_log(). Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
* lib: Remove else nothingSaya Sugiura2019-09-131-2/+0
| | | | | | Remove "else nothing" to correct code behavior. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* network trace: Do not allow DLT usage in forked childVo Trung Chi2019-09-131-0/+4
| | | | | | | dlt_user_trace_network_segmented() shall not be used in forked child process. Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
* lib: Assign fd after it's closedSaya Sugiura2019-09-131-0/+1
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* Add user custom timestamp interfaceSebastian Unger2019-09-131-1/+8
| | | | | | | | | | | | | Two new macros are introduced so that users can use their customized timestamps for DLT messages: - DLT_LOG_TS(CONTEXT, LOGLEVEL, TS, ARGS ...) - DLT_LOG_ID_TS(CONTEXT, LOGLEVEL, MSGID, TS, ARGS ...) Detailed explanations can be found in dlt_for_developers.md. Also a new option is added to dlt-system to use events' timestamps from journald adapter. Signed-off-by: Sebastian Unger <sunger@de.adit-jv.com>
* libdlt: truncate the log message if it is too long (#156) (#157)Vo Trung Chi2019-09-021-90/+147
| | | | | | | | | | | | Change the behavior of dlt_user_log_write_string, dlt_user_log_write_constant_string and dlt_user_log_write_utf8_string so that they truncate the incoming message if it is too big and add "Message truncated, too long" at the end of it. These function should anyway still return an DLT_RETURN_USER_BUFFER_FULL error in this case. Signed-off-by: Nguyen Dinh Thi (RBVH/ENG2) <Thi.NguyenDinh@vn.bosch.com> Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
* using POSIX shared memory APIs (#90) (#151)Vo Trung Chi2019-08-011-16/+6
| | | | | Replace all Linux specific shared memory APIs with POSIX alternatives. Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
* Correct sa findingsSaya Sugiura2019-07-241-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dlt_offline_logstorage.c - Parameter to isdigit is not correct - Handle the size of memset() and strncpy() properly dlt-test-stress-user.c - Parameter d is duplicated dlt_env_ll.c - Parameter env is used before NULL check - Remove redundant line dlt-control-common.c dlt_daemon_event_handler.c - Do not use NULL variable to print log dlt_config_file_parser.c - Remove unnecessary loop dlt_daemon_client.c - Return error in NULL check dlt_user.c - Free allocated memory in error case Related commit: 5c8f88d logstorage: fix compile error Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* doxygen: Align variable for apid and ctidSaya Sugiura2019-07-191-20/+20
| | | | | | | The variables used for application id and context id are aligned with "apid" and "ctid". Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* doxygen: Remove licenceSaya Sugiura2019-07-191-2/+0
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* define DLT_PATH_MAX for max path buffer lengthRadoslaw Kaczorowski2019-07-031-10/+12
| | | | | | | | DLT limits the path length and does not do anything else to determine the actual value, because the least that is supported on any system that DLT runs on is 1024 bytes. Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
* libdlt: Use posix nanosleep (#144)Phong Tran2019-06-271-2/+9
| | | | | Change to use nanosleep instead of usleep. Signed-off-by: Phong Tran <tranmanphong@gmail.com>
* cleanup: Use dlt_vlog()Saya Sugiura2019-06-191-20/+10
| | | | | | | There were a couple of places which used snprintf-dlt_log. It is now replaced with dlt_vlog(). Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* Fix alerts from lgtmSaya Sugiura2019-06-191-2/+2
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* libdlt: Remove commented out codeSaya Sugiura2019-06-181-33/+0
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* Remove dlt_forward_msgSaya Sugiura2019-06-181-106/+0
| | | | | | Since dlt_forward_msg() is not used anywhere, we will remove it. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* libdlt: compare dlt_ll_ts to NULLSaya Sugiura2019-06-181-4/+4
| | | | | | This commit fixes dlt_user.dlt_ll_ts to compare to NULL instead of 0. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* network trace: Define package ID macroSaya Sugiura2019-06-181-4/+4
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* libdlt: Fix compiler warningsSaya Sugiura2019-06-111-0/+2
| | | | | | Fix the warning from -Wmaybe-uninitialized. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* lib: unlock buffer on terminationS. Hameed2019-05-241-24/+27
| | | | | | | | | | | | | | | | | | | | | | | | | Sometimes it happens that internal threads present in DLT library are cancelled with one of the task still holding the mutex, then the main task gets locked forever. The following changes have been made: - Cleanup on thread cancellation with pthread_cleanup_push() is introduced - Locking on the message queue lock and subsequent signaling in dlt_stop_threads is only done if the segmented thread was created. - It is unnecessary to have a robust mutex for the message queue. Replace it with a normal mutex and remove EOWNERDEAD logic. Add a pthread_cancel handler to the segmented thread that might hold the message queue mutex. - Message queue mutex is statically initialized Signed-off-by: S. Hameed <shameed@jp.adit-jv.com> Signed-off-by: Jeevan Ramakant Nagvekar <jeevan.nagvekar1@wipro.com> Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* Logging: Error message modificationManikandanC2019-05-061-8/+16
| | | | | | | Error message is printed only in error case and not in case of expected failure. Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com>
* POSIX: Replace usleep with nanosleepSaya Sugiura2019-05-061-3/+14
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>