summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2016-01-07 09:31:33 -0800
committer Mathieu Chartier <mathieuc@google.com> 2016-01-08 16:28:46 -0800
commitba098bafdc4bd6dc6fc85f2996fa9f2d9be051bf (patch)
treebed1fcab1495ffb11383178bcf3b90a48b30bfd0
parent66521058c80ee4058995d28f512dd6d173610e3a (diff)
Revert "Revert "Reduce sleep duration in SuspendAllDaemonThreads""
Fixed the error where I reduced the time until the warning by 10x. Bug: 26351700 This reverts commit bc34a7ed232cb3d384c250578e2b4ede45f2b167. Change-Id: I6b30a0711fe077421665b78c39ded88899407700
-rw-r--r--runtime/thread_list.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index 43ee84839b..ae18819e90 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -1161,8 +1161,9 @@ void ThreadList::SuspendAllDaemonThreadsForShutdown() {
}
// Give the threads a chance to suspend, complaining if they're slow.
bool have_complained = false;
- for (int i = 0; i < 10; ++i) {
- usleep(200 * 1000);
+ static constexpr size_t kTimeoutMicroseconds = 2000 * 1000;
+ static constexpr size_t kSleepMicroseconds = 1000;
+ for (size_t i = 0; i < kTimeoutMicroseconds / kSleepMicroseconds; ++i) {
bool all_suspended = true;
for (const auto& thread : list_) {
if (thread != self && thread->GetState() == kRunnable) {
@@ -1176,8 +1177,9 @@ void ThreadList::SuspendAllDaemonThreadsForShutdown() {
if (all_suspended) {
return;
}
+ usleep(kSleepMicroseconds);
}
- LOG(ERROR) << "suspend all daemons failed";
+ LOG(WARNING) << "timed out suspending all daemon threads";
}
void ThreadList::Register(Thread* self) {
DCHECK_EQ(self, Thread::Current());