mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 15:12:51 +08:00
Fixing leaking sockets
This commit is contained in:
parent
93ec092eaf
commit
1d2efa0d25
@ -55,7 +55,8 @@ public class CallbackServer implements Runnable {
|
|||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static final String LOG_TAG = "CallbackServer";
|
private static final String LOG_TAG = "CallbackServer";
|
||||||
|
|
||||||
|
private ServerSocket waitSocket;
|
||||||
/**
|
/**
|
||||||
* The list of JavaScript statements to be sent to JavaScript.
|
* The list of JavaScript statements to be sent to JavaScript.
|
||||||
*/
|
*/
|
||||||
@ -200,7 +201,7 @@ public class CallbackServer implements Runnable {
|
|||||||
try {
|
try {
|
||||||
this.active = true;
|
this.active = true;
|
||||||
String request;
|
String request;
|
||||||
ServerSocket waitSocket = new ServerSocket(0);
|
waitSocket = new ServerSocket(0);
|
||||||
this.port = waitSocket.getLocalPort();
|
this.port = waitSocket.getLocalPort();
|
||||||
//Log.d(LOG_TAG, "CallbackServer -- using port " +this.port);
|
//Log.d(LOG_TAG, "CallbackServer -- using port " +this.port);
|
||||||
this.token = java.util.UUID.randomUUID().toString();
|
this.token = java.util.UUID.randomUUID().toString();
|
||||||
@ -288,7 +289,9 @@ public class CallbackServer implements Runnable {
|
|||||||
//Log.d(LOG_TAG, "CallbackServer.stopServer()");
|
//Log.d(LOG_TAG, "CallbackServer.stopServer()");
|
||||||
if (this.active) {
|
if (this.active) {
|
||||||
this.active = false;
|
this.active = false;
|
||||||
|
|
||||||
|
try { waitSocket.close(); } catch (IOException ignore) {}
|
||||||
|
|
||||||
// Break out of server wait
|
// Break out of server wait
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
this.notify();
|
this.notify();
|
||||||
|
Loading…
Reference in New Issue
Block a user