diff options
author | Brad Fitzpatrick <bradfitz@android.com> | 2011-01-14 12:48:08 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-01-14 12:48:08 -0800 |
commit | 1e8d23f6b03aeed45cdcf5c03121741ee9684396 (patch) | |
tree | a390cc6a33d84c0ef53f0b38893416c3db5646b4 /services/java/com | |
parent | 312206b98749bbe395416634e6e82bd242b1d5f2 (diff) | |
parent | 9765c72eeaba9ed0f704dd992e7a954f38f20abd (diff) | |
download | frameworks_base-1e8d23f6b03aeed45cdcf5c03121741ee9684396.zip frameworks_base-1e8d23f6b03aeed45cdcf5c03121741ee9684396.tar.gz frameworks_base-1e8d23f6b03aeed45cdcf5c03121741ee9684396.tar.bz2 |
Merge "Watchdog can get deadlocked on activity manager" into honeycomb
Diffstat (limited to 'services/java/com')
-rw-r--r-- | services/java/com/android/server/Watchdog.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/services/java/com/android/server/Watchdog.java b/services/java/com/android/server/Watchdog.java index 1b885f5..2a25c2a 100644 --- a/services/java/com/android/server/Watchdog.java +++ b/services/java/com/android/server/Watchdog.java @@ -425,7 +425,7 @@ public class Watchdog extends Thread { // First collect stack traces from all threads of the system process. // Then kill this process so that the system will restart. - String name = (mCurrentMonitor != null) ? + final String name = (mCurrentMonitor != null) ? mCurrentMonitor.getClass().getName() : "null"; EventLog.writeEvent(EventLogTags.WATCHDOG, name); @@ -434,7 +434,8 @@ public class Watchdog extends Thread { if (mPhonePid > 0) pids.add(mPhonePid); // Pass !waitedHalf so that just in case we somehow wind up here without having // dumped the halfway stacks, we properly re-initialize the trace file. - File stack = ActivityManagerService.dumpStackTraces(!waitedHalf, pids, null, null); + final File stack = ActivityManagerService.dumpStackTraces( + !waitedHalf, pids, null, null); // Give some extra time to make sure the stack traces get written. // The system's been hanging for a minute, another second or two won't hurt much. @@ -445,7 +446,19 @@ public class Watchdog extends Thread { dumpKernelStackTraces(); } - mActivity.addErrorToDropBox("watchdog", null, null, null, name, null, stack, null); + // Try to add the error to the dropbox, but assuming that the ActivityManager + // itself may be deadlocked. (which has happened, causing this statement to + // deadlock and the watchdog as a whole to be ineffective) + Thread dropboxThread = new Thread("watchdogWriteToDropbox") { + public void run() { + mActivity.addErrorToDropBox( + "watchdog", null, null, null, name, null, stack, null); + } + }; + dropboxThread.start(); + try { + dropboxThread.join(2000); // wait up to 2 seconds for it to return. + } catch (InterruptedException ignored) {} // Only kill the process if the debugger is not attached. if (!Debug.isDebuggerConnected()) { |