Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 62E47D371 for ; Tue, 18 Sep 2012 17:52:51 +0000 (UTC) Received: (qmail 5754 invoked by uid 500); 18 Sep 2012 17:52:51 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 5632 invoked by uid 500); 18 Sep 2012 17:52:51 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 5607 invoked by uid 99); 18 Sep 2012 17:52:51 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Sep 2012 17:52:51 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id E03EB38CDA; Tue, 18 Sep 2012 17:52:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agrieve@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [1/14] android commit: Fix a deadlock in CallbackServer.java. Message-Id: <20120918175250.E03EB38CDA@tyr.zones.apache.org> Date: Tue, 18 Sep 2012 17:52:50 +0000 (UTC) Updated Branches: refs/heads/master 451688a12 -> 0baf104a7 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. Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/0baf104a Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/0baf104a Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/0baf104a Branch: refs/heads/master Commit: 0baf104a751240ac085c6e2a6eb46a1355256fea Parents: 302d51c Author: Andrew Grieve Authored: Tue Sep 18 13:51:31 2012 -0400 Committer: Andrew Grieve Committed: Tue Sep 18 13:51:31 2012 -0400 ---------------------------------------------------------------------- .../src/org/apache/cordova/CallbackServer.java | 16 +++++++------- 1 files changed, 8 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/0baf104a/framework/src/org/apache/cordova/CallbackServer.java ---------------------------------------------------------------------- diff --git a/framework/src/org/apache/cordova/CallbackServer.java b/framework/src/org/apache/cordova/CallbackServer.java index 0b8383c..dcf3b6e 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 <<<");