You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2012/07/21 01:03:02 UTC

android commit: Fixing leaking sockets

Updated Branches:
  refs/heads/master 93ec092ea -> 1d2efa0d2


Fixing leaking sockets


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/1d2efa0d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/1d2efa0d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/1d2efa0d

Branch: refs/heads/master
Commit: 1d2efa0d25e99d525103239490cbca8a06ad10ef
Parents: 93ec092
Author: Joe Bowser <bo...@apache.org>
Authored: Fri Jul 20 16:02:43 2012 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Fri Jul 20 16:02:43 2012 -0700

----------------------------------------------------------------------
 .../src/org/apache/cordova/CallbackServer.java     |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/1d2efa0d/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 2eb292f..b8075b5 100755
--- a/framework/src/org/apache/cordova/CallbackServer.java
+++ b/framework/src/org/apache/cordova/CallbackServer.java
@@ -55,7 +55,8 @@ public class CallbackServer implements Runnable {
 
     @SuppressWarnings("unused")
     private static final String LOG_TAG = "CallbackServer";
-
+    
+    private ServerSocket waitSocket;
     /**
      * The list of JavaScript statements to be sent to JavaScript.
      */
@@ -200,7 +201,7 @@ public class CallbackServer implements Runnable {
         try {
             this.active = true;
             String request;
-            ServerSocket waitSocket = new ServerSocket(0);
+            waitSocket = new ServerSocket(0);
             this.port = waitSocket.getLocalPort();
             //Log.d(LOG_TAG, "CallbackServer -- using port " +this.port);
             this.token = java.util.UUID.randomUUID().toString();
@@ -288,7 +289,9 @@ public class CallbackServer implements Runnable {
         //Log.d(LOG_TAG, "CallbackServer.stopServer()");
         if (this.active) {
             this.active = false;
-
+            
+            try { waitSocket.close(); } catch (IOException ignore) {}
+            
             // Break out of server wait
             synchronized (this) {
                 this.notify();