summaryrefslogtreecommitdiff
path: root/src/lib/dlt_user.c
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* unix socket: IPC code isolationChristoph Lipka2019-05-061-14/+9
| | | | | Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com> Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
* ipc: close socket if connect failedChristoph Lipka2019-04-241-0/+2
| | | | Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
* Size of Resend buffer less than or equal to DLT_USER_BUF_MAX_SIZE res… (#116)kundatipradeep2019-04-151-1/+4
| | | | | | | * Size of Resend buffer less than or equal to DLT_USER_BUF_MAX_SIZE results in Memory corruption. As older version of DLT DLT_USER_RESENDBUF_MAX_SIZE is [DLT_USER_BUF_MAX_SIZE + 100] which contains space for extra headers, where as in DLT 2.18 the resend buffer is bound to DLT_USER_BUF_MAX_SIZE which results in memory corruption in dlt_buffer_read_block when the size of the data is more than DLT_USER_BUF_MAX_SIZE. Reason for not using "DLT_USER_RESENDBUF_MAX_SIZE" during dynamic memory allocation of resend buffer is as user has got the feasibility to alter the DLT_USER_BUF_MAX_SIZE using the environmental variables the resend buffer in any scenario to be greater then dlt_user.log_buf_len to accommodate the extra headers.
* Fixed memory leak when receiving network traces of 0xFFFF lengthjiripopek2019-04-111-2/+4
| | | | | | | | 0xFFFF was used as a magic number in the length field of a network message in order to trigger a resend. DLT library will now use the nw_trace_type field and a custom type to do this, thus assuring no external client of the library can reach this value(DLT_NW_TRACE_RESEND).
* lib: Add mq_close/mq_unlink conditionsSaya Sugiura2019-03-271-5/+12
| | | | | | | | | | Even if network trace is not used in the application, the library will call mq_close() and mq_unlink() to segmented queue handles and queue names, which triggers unnecessary close(). It is now modified to call mq_close() and mq_unlink() only when network trace is initialized. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* libdlt: Do not allow DLT usage in forked child (#95)Simon Herkenhoff2019-02-041-36/+58
| | | | | | | | | | | | | DLT shall not be used in a forked child until a variant of exec() is called, because DLT is using non async-signal-safe functions. The forking process can continue to use libdlt's logging facilities, but any attempt to use libdlt from the forked child will be denied. The fork-handler test is updated to reflect this by trying to log from the forked child which will fail. The fork then calls exec and runs another application that can continue to use DLT. Signed-off-by: Simon Herkenhoff <sherkenhoff@jp.adit-jv.com>
* Code beautification using uncrustifyChristoph Lipka2018-12-211-1734/+1358
| | | | Signed-off-by: Christoph Lipka <clipka@de.adit-jv.com>
* Cleanup of unit test fixesManikandan C2018-12-211-18/+10
| | | | Signed-off-by: Manikandan C <mchockalingam@de.adit-jv.com>
* libdlt: Add error handlingSaya Sugiura2018-12-211-70/+126
| | | | | | | Error handling was added in case it failed to send to daemon. Signed-off-by: S. Hameed <shameed@jp.adit-jv.com> Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* UnitTest: UpdatesManikandanC2018-12-211-34/+42
| | | | | | | | | | | | 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>
* lib: socket: Flush all data before closing socketSaya Sugiura2018-12-211-1/+35
| | | | | | | | | | | | | | Sometimes socket will be closed even not all of the data is flushed to daemon. So before closing, following will be handled: 1. Use shutdown() to shut down further transmissions 2. Subsequent read() to resend_buffer Also socket fd is reset in child fork handler since the socket itself will not be duplicated in the child process. Solves JIRA: SWGIII-28702 Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* Removed log level change callback notification while context register done ↵Ravi Sankar P2018-12-211-2/+2
| | | | | | with ll_ts API Signed-off-by: Ravi Sankar P <ponnurangamravi.sankar@in.bosch.com>
* Logging: avoided missing of log level change callback Added new context ↵Manikandan C2018-12-211-146/+205
| | | | | | registration Macro and API which has option to register log level change callback along with it. This will avoid missing of initial log level change callback when daemon sends the log level change control msg during context registration Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com>
* Injection: New callback with private data Added new injection callback with ↵ManikandanC2018-12-211-18/+66
| | | | | | private data as argument Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com>
* Dynamic allocation of msg bufferManikandanC2018-12-101-170/+284
| | | | | | | | | | | | | It is possible to change the default buffer size for log message creation via environment variable: export DLT_LOG_MSG_BUF_LEN=<value> Instead of using a static buffer with size of 1390 bytes, the buffer is allocated dynamically with the specified value.The max size is restricted to approx 65k. Signed-off-by: Christoph Lipka <clipka@de.adit-jv.com> Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com>
* Use poll in the dlt-daemon for POSIX complianceManikandanC2018-11-301-8/+38
| | | | | | | | | | | The poll system call is now used in the daemon to enable DLT use in POSIX compliant systems. Also added introduced new unregister_app macro to avoid missing of logs in startup buffer. Signed-off-by: Frederic Berat <fberat@de.adit-jv.com> Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com> Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com> Signed-off-by: S. Hameed <shameed@jp.adit-jv.com>
* Update dlt_user.c (#66)kundatipradeep2018-08-241-0/+13
| | | | In dlt_user_log_send_log and dlt_forward_msg API's when writing the data to DLT PIPE is not successful in scenario which returns "DLT_RETURN_PIPE_ERROR"(Non availability of dlt pipe post termination of DLT DAEMON) it ideally starts stores the data in internal buffer, and close the dlt user handle, which is quiet appropriate. The scenario were dlt application fails in writing data to dlt pipe returns DLT_RETURN_PIPE_ERROR and case were application buffer is full, the return value DLT_RETURN_PIPE_ERROR is over written to "DLT_RETURN_BUFFER_FULL" were dlt user handle will not be reset to -1, it till holds the former data which causes undefined behavior of dlt application(One behavior would be which calls dlt_user_queue_resend and internally allocates memory for segmented data and tries to free it at dlt_user_trace_network_segmented_thread which is not intended behavior, instead return silently when FIFO is not available)
* libdlt: Avoid busy loop in error case of mq_receive() (#59)Yusuke Sato2018-05-291-1/+13
| | | | | | | To avoid busy loop due to error of mq_receive() which is called in sub thread, 100ms sleep is added for the error case. Error log message for mq_receive() is also corrected to have errno. Signed-off-by: Yusuke Sato <yusuke-sato@apn.alpine.co.jp>
* IPC: Unix socket added (#43)ManikandanChockalingam2018-05-181-113/+208
| | | | | | | | | * IPC: Unix socket added The user can select either FIFO or UNIX socket as IPC between user library and daemon through CMakelist option. Socket path configurable for both FIFO and Unix Socket now configurable in CMake Signed-off-by: Christoph Lipka <clipka@de.adit-jv.com> Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com>
* minor compiler warning gcc 7.x (#30)Phong Tran2018-03-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix -Wpointer-compare of compare with null char Signed-off-by: Phong Tran <tranmanphong@gmail.com> * dlt_common: fix -Wformat-truncation of snprintf Avoid snprintf output truncation by handling return value Signed-off-by: Phong Tran <tranmanphong@gmail.com> * dlt_offline_trace: Fix Wformat-truncation of snprintf Compile with Gcc 7.x has the warning of snprintf buffer length size. Check return value of snprintf() for avoiding the warning. Signed-off-by: Phong Tran <tranmanphong@gmail.com> * dlt_common_test: Fix memleak t_dlt_message_read some resources were not free after using. Detected by running valgrind --leak-check=full ./gtest_dlt_common Signed-off-by: Phong Tran <tranmanphong@gmail.com>
* Fix for initialization of buffer settings in DLT user library. (#25)baduras2017-09-131-2/+2
|
* CMake Option: Trigger segmentation fault in case of FATAL logChristoph Lipka2017-02-021-0/+14
| | | | | | | | When the user library receives a log with log level DLT_LOG_FATAL it triggers a segmentation fault to provide information to the developer via tools like coredump. Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
* Environment variables for library ringbufferChristoph Lipka2016-10-241-1/+51
| | | | | | | | | | | | This patch adds environment variables to configure user library ringbuffer and step size. The following variables can be set: DLT_USER_BUFFER_MIN - for minimal size DLT_USER_BUFFER_MAX - for maximal size DLT_USER_BUFFER_STEP - for step size Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
* DLT_PTR macro: Improve implementation and function API addedChristoph Lipka2016-10-241-0/+32
| | | | | | | | The original implementation result in a compile error when DLT_PTR is used with other macros like DLT_STRING. This patch overcomes that problem. Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
* Fix: Memory for context description is not freedYusuke Sato2016-09-231-0/+18
| | | | | | | | Currently, allocated memory for context description is not freed in dlt_free(). free() for each member variables of dlt_user.dlt_ll_ts[i] is added in the for block in dlt_free(). Signed-off-by: Yusuke Sato <yusuke-sato@apn.alpine.co.jp> Change-Id: I52a81cf2918cb0014fdcfc666cb8bb93ca7cb525
* Fix: Handle of /tmp/dlt never reset if dlt-daemon is killed during output ↵Yusuke Sato2016-09-231-1/+1
| | | | | | | | | | user buffer Handle of /tmp/dlt cannot be reset if dlt-daemon is killed during output user buffer because dlt_user_log_resend_buffer() never returns DLT_RETURN_PIPE_ERROR. Return value of dlt_user_log_resend_buffer() is modified to pass return value of dlt_user_log_out3() without change. Signed-off-by: Yusuke Sato <yusuke-sato@apn.alpine.co.jp> Change-Id: I506103ebebcdb3c145d1f0719a3c8caffc8d89c1
* Fix: Segfault in checking buffer usageYusuke Sato2016-09-231-0/+3
| | | | | | | | Segfault is caused by dlt_user_check_buffer() if this function is called during increasing the user buffer. To avoid this issue, semaphore has to be added. Signed-off-by: Yusuke Sato <yusuke-sato@apn.alpine.co.jp> Change-Id: Ie56f2fb73aeacb835180468e57c9338d2ffdb072
* Add dlt_user_is_logLevel_enabled APIChristoph Lipka2016-09-231-1/+1
| | | | | | | | | | This function allows an application developer to check if the DLT LogLevel is enabled before starting any log string creation. It can be used in application specific logging wrapper functions. Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com> Change-Id: I4c269b12bfdeae29a4e795385cdbc54a579ba621
* Fixed D-Bus tracing not working anymoreAlexander Wenzel2016-05-131-1/+1
| | | | | | | Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> Topic: GENDLT-425 Change-Id: I4ec56d714804d9ee4fa904b71c58dafd00990b4f
* Fixed not working default log level.Alexander Wenzel2016-05-031-8/+12
| | | | | | Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> Change-Id: Id01c9a11e4b5ccf4166f10c5e45363f3a7c00535
* Fixed not returning the correct number of lost messages at exit.Alexander Wenzel2016-05-031-1/+5
| | | | | | Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> Change-Id: I211222d04350820098bf56dfc5b7aee50e2529f0
* DLT_RETURN_USER_BUFFER_FULL is returned when user buffer fullLutz Helwing2016-04-221-113/+59
| | | | | | | | | A new return value DLT_RETURN_USER_BUFFER_FULL is introduced which is returned by all dlt_user_log_write_* and dlt_log_* functions when the data to be added to the user buffer exceeds its size (datasize > DLT_USER_BUF_MAX_SIZE) Signed-off-by: Lutz Helwing <lutz_helwing@mentor.com>
* Revert truncation of string or raw blockLutz Helwing2016-04-221-26/+16
| | | | | | | | | | | | | | | Commit d319ebf4d2d449d70befae0eebbdd82c19c5315f introduced new handling of the situation when writing data to the user buffer would exceed its size. This was achieved by truncating the data to fit. This solution had a problem: It could lead to a buffer overflow when the updated arg_size gets negative (actually undefined value because it is unsigned). As a quick fix the behaviour is reverted to the state before the aforementioned commit. Signed-off-by: Lutz Helwing <lutz_helwing@mentor.com>