diff options
author | 2023-01-06 01:25:14 +0000 | |
---|---|---|
committer | 2023-01-06 01:25:14 +0000 | |
commit | c85ae17f8267ac528e58892099dcefcc73bb8a26 (patch) | |
tree | 64e70f450f4a54c2a40410fb111ccc292e3089f1 /runtime/native/java_lang_Thread.cc | |
parent | fe9b34f845e8e439b4ae47ae999ef2cfdbd66462 (diff) |
Revert "Revert^6 "Thread suspension cleanup and deadlock fix""
This reverts commit fe9b34f845e8e439b4ae47ae999ef2cfdbd66462.
Reason for revert: Breaks full-eng build
Change-Id: I230b31809e274740b8fae9358c260787462efe4d
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."; } } |