From 5475db8bde06d1c45498293f383665f26de7ca1e Mon Sep 17 00:00:00 2001 From: Alexander Wenzel Date: Fri, 6 Dec 2013 09:04:21 +0100 Subject: Fix deadlock in dlt_user_log_reattach_to_daemon(void). Signed-off-by: Alexander Wenzel --- src/lib/dlt_user.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index 40e7cf9..e62131e 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -3819,16 +3819,24 @@ void dlt_user_log_reattach_to_daemon(void) handle.log_level_pos = num; log_new.context_description = dlt_user.dlt_ll_ts[num].context_description; + // Release the mutex for sending context registration: + // function dlt_user_log_send_register_context() can take the mutex to write to the DLT buffer. => dead lock + DLT_SEM_FREE(); + log_new.log_level = DLT_USER_LOG_LEVEL_NOT_SET; log_new.trace_status = DLT_USER_TRACE_STATUS_NOT_SET; if (dlt_user_log_send_register_context(&log_new)==-1) { - DLT_SEM_FREE(); return; } reregistered=1; + + // Lock again the mutex + // it is necessary in the for(;;) test, in order to have coherent dlt_user data all over the critical section. + DLT_SEM_LOCK(); + } } -- cgit v1.2.1