4
0
mirror of https://github.com/apache/cordova-android.git synced 2025-04-23 09:30:14 +08:00

Fix a deadlock in CallbackServer.java.

-Manifested when running mobile spec. Was caused by CallbackServer
obtaining lock  then , while other thread obtained  then .
This commit is contained in:
Andrew Grieve 2012-09-18 13:51:31 -04:00
parent 302d51cdfd
commit 0baf104a75

@ -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 <<<");