Skip to content

Commit b9c8a5f

Browse files
fix: issues
1 parent 4b204a8 commit b9c8a5f

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/plugins/terminal/src/android/Executor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
268268

269269
int port;
270270
try (ServerSocket socket = new ServerSocket(0)) {
271-
socket.setReuseAddress(true);
272271
port = socket.getLocalPort();
273272
}
274273

src/plugins/terminal/src/android/ProcessServer.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,18 @@ public void onMessage(WebSocket conn, String message) {
101101

102102
@Override
103103
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
104-
// Single point of cleanup for every connection lifecycle ending —
105-
// whether closed cleanly, after an error, or by the process exiting.
106104
try {
107105
ConnState state = conn.getAttachment();
108106
if (state != null) state.process.destroy();
109-
stop();
110107
} catch (Exception ignored) {}
108+
109+
// stop() calls w.join() on every worker thread. If called directly from
110+
// onClose (which runs on a WebSocketWorker thread), it deadlocks waiting
111+
// for itself to finish. A separate thread sidesteps that entirely.
112+
new Thread(() -> {
113+
try {
114+
stop();
115+
} catch (Exception ignored) {}
116+
}).start();
111117
}
112118
}

0 commit comments

Comments
 (0)