Skip to content

Commit

Permalink
Improve deadlock detector logging.
Browse files Browse the repository at this point in the history
Signed-off-by: Ross Allan <rallanpcl@gmail.com>
  • Loading branch information
LunNova committed Jul 19, 2013
1 parent ecd11dd commit a8802a1
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/common/nallar/tickthreading/minecraft/DeadLockDetector.java
Expand Up @@ -81,10 +81,12 @@ public void run() {
private static void tryFixDeadlocks(String stuckManagerName) {
stuckManagerName += " - ";
Iterable<Thread> threads = Thread.getAllStackTraces().keySet();
boolean killed = false;
int found = 0;
int notRunning = 0;
int killed = 0;
for (Thread thread : threads) {
if (thread.getName().startsWith(stuckManagerName)) {
if (killed) {
if (killed > 0) {
trySleep(5);
}
StackTraceElement[] stackTraceElements = thread.getStackTrace();
Expand All @@ -96,12 +98,18 @@ private static void tryFixDeadlocks(String stuckManagerName) {
}
if (runCount >= 3) {
thread.stop(new ThreadStuckError("Deadlock detected, appears to be caused by " + stuckManagerName));
killed = true;
killed++;
} else {
notRunning++;
}
}
}
if (!killed) {
Log.severe("Failed to kill any threads of manager " + stuckManagerName + ".\n" + CollectionsUtil.join(threads));
String message = "Trying to unstick " + stuckManagerName +
"\nFound " + found + " threads, Killed " + killed + " threads, Already stopped " + notRunning + " threads.";
if (killed == 0) {
Log.severe(message);
} else {
Log.info(message);
}
}

Expand Down

0 comments on commit a8802a1

Please sign in to comment.