Skip to content

Display and control your Android device

Shutdown connection before joining threads

Romain Vimontff579990c21d
diff --git a/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java b/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java
index c3408fff..8bc743f8 100644
--- a/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java
+++ b/server/src/main/java/com/genymobile/scrcpy/DesktopConnection.java
@@ -132,20 +132,29 @@ public final class DesktopConnection implements Closeable {
return controlSocket;
}
- public void close() throws IOException {
+ public void shutdown() throws IOException {
if (videoSocket != null) {
videoSocket.shutdownInput();
videoSocket.shutdownOutput();
- videoSocket.close();
}
if (audioSocket != null) {
audioSocket.shutdownInput();
audioSocket.shutdownOutput();
- audioSocket.close();
}
if (controlSocket != null) {
controlSocket.shutdownInput();
controlSocket.shutdownOutput();
+ }
+ }
+
+ public void close() throws IOException {
+ if (videoSocket != null) {
+ videoSocket.close();
+ }
+ if (audioSocket != null) {
+ audioSocket.close();
+ }
+ if (controlSocket != null) {
controlSocket.close();
}
}
diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.java
index 0126f396..a1c6090b 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Server.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Server.java
@@ -163,6 +163,8 @@ public final class Server {
asyncProcessor.stop();
}
+ connection.shutdown();
+
try {
initThread.join();
for (AsyncProcessor asyncProcessor : asyncProcessors) {