diff options
author | Hafiz Abid Qadeer <hafiz_abid@mentor.com> | 2015-02-11 16:37:17 +0000 |
---|---|---|
committer | Hafiz Abid Qadeer <hafiz_abid@mentor.com> | 2015-02-11 16:37:17 +0000 |
commit | 5bf72c46b33c0058b4147fd6bbda4b53322f67ca (patch) | |
tree | 82222661aaa9c3297e2cb0e05f032604075bb586 /lldb/source/API/SBProcess.cpp | |
parent | 88d21343df99ef22b7666aa413985508f33a3328 (diff) | |
download | bcm5719-llvm-5bf72c46b33c0058b4147fd6bbda4b53322f67ca.tar.gz bcm5719-llvm-5bf72c46b33c0058b4147fd6bbda4b53322f67ca.zip |
Lock mutex in the same order.
SBProcess uses 2 mutexex; RunLock and APILock. Apart from 2 places, RunLock
is locked before API lock. I have fixed the 2 places where order was different.
I observed a deadlock due to this different order in lldb-mi once. Although
lldb-mi command and event thread dont run at the same time now. So it can not deadlock
there but can still be problem for some other clients.
Pre-approved by Greg in http://lists.cs.uiuc.edu/pipermail/lldb-dev/2015-February/006509.html
llvm-svn: 228844
Diffstat (limited to 'lldb/source/API/SBProcess.cpp')
-rw-r--r-- | lldb/source/API/SBProcess.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 9a0b23bc93d..5de36e302c1 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -918,9 +918,9 @@ SBProcess::GetThreadByID (tid_t tid) ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); Process::StopLocker stop_locker; const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); thread_sp = process_sp->GetThreadList().FindThreadByID (tid, can_update); sb_thread.SetThread (thread_sp); } @@ -942,9 +942,9 @@ SBProcess::GetThreadByIndexID (uint32_t index_id) ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); Process::StopLocker stop_locker; const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); thread_sp = process_sp->GetThreadList().FindThreadByIndexID (index_id, can_update); sb_thread.SetThread (thread_sp); } |