Fix deadlock in dlt_user_log_reattach_to_daemon(void).
authorAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Fri, 6 Dec 2013 08:04:21 +0000 (09:04 +0100)
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Fri, 10 Jan 2014 06:15:59 +0000 (07:15 +0100)
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
src/lib/dlt_user.c

index 40e7cf9..e62131e 100644 (file)
@@ -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();
+
                 }
             }