diff options
author | 2022-10-22 04:33:19 +0000 | |
---|---|---|
committer | 2022-10-22 11:53:31 +0000 | |
commit | 0db9605ec8bd3158f4f0107a511dd09a889c9341 (patch) | |
tree | 66db28109b47e8f12eff2d2eccb2483f8b21a07b /runtime/native/java_lang_Thread.cc | |
parent | 453df307ac07bf239f90029abaff20e319b7e470 (diff) |
Revert "Revert^4 "Thread suspension cleanup and deadlock fix""
This reverts commit a23d325152c7cd81ccb426a407f6da280797e61d.
Reason for revert: Triggered failures in org.apache.harmony.jpda.tests.jdwp.Events_CombinedEventsTest#testCombinedEvents_05
Change-Id: I0604a60f73a983c92e29827222bfa6158ee043aa
Diffstat (limited to 'runtime/native/java_lang_Thread.cc')
-rw-r--r-- | runtime/native/java_lang_Thread.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/runtime/native/java_lang_Thread.cc b/runtime/native/java_lang_Thread.cc index fd67a0a7fa..570c554782 100644 --- a/runtime/native/java_lang_Thread.cc +++ b/runtime/native/java_lang_Thread.cc @@ -147,8 +147,11 @@ static void Thread_setNativeName(JNIEnv* env, jobject peer, jstring java_name) { // thread list lock to avoid this, as setting the thread name causes mutator to lock/unlock // in the DDMS send code. ThreadList* thread_list = Runtime::Current()->GetThreadList(); + bool timed_out; // Take suspend thread lock to avoid races with threads trying to suspend this one. - Thread* thread = thread_list->SuspendThreadByPeer(peer, SuspendReason::kInternal); + Thread* thread = thread_list->SuspendThreadByPeer(peer, + SuspendReason::kInternal, + &timed_out); if (thread != nullptr) { { ScopedObjectAccess soa(env); @@ -156,6 +159,9 @@ static void Thread_setNativeName(JNIEnv* env, jobject peer, jstring java_name) { } bool resumed = thread_list->Resume(thread, SuspendReason::kInternal); DCHECK(resumed); + } else if (timed_out) { + LOG(ERROR) << "Trying to set thread name to '" << name.c_str() << "' failed as the thread " + "failed to suspend within a generous timeout."; } } |