From 0baf104a751240ac085c6e2a6eb46a1355256fea Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Tue, 18 Sep 2012 13:51:31 -0400 Subject: [PATCH] Fix a deadlock in CallbackServer.java. -Manifested when running mobile spec. Was caused by CallbackServer obtaining lock #1 then #2, while other thread obtained #2 then #1. --- .../src/org/apache/cordova/CallbackServer.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/framework/src/org/apache/cordova/CallbackServer.java b/framework/src/org/apache/cordova/CallbackServer.java index 0b8383c2..dcf3b6e4 100755 --- a/framework/src/org/apache/cordova/CallbackServer.java +++ b/framework/src/org/apache/cordova/CallbackServer.java @@ -211,14 +211,14 @@ public class CallbackServer implements Runnable { // Wait until there is some data to send, or send empty data every 10 sec // to prevent XHR timeout on the client - synchronized (this) { - while (this.active) { - if (jsMessageQueue != null) { - payload = jsMessageQueue.popAndEncode(); - if (payload != null) { - break; - } - } + while (this.active) { + if (jsMessageQueue != null) { + payload = jsMessageQueue.popAndEncode(); + if (payload != null) { + break; + } + } + synchronized (this) { try { this.wait(10000); // prevent timeout from happening //Log.d(LOG_TAG, "CallbackServer>>> break <<<");