Shutdown connection before joining threads

Interrupting async processors may require to shutdown the connection to
wake up blocking calls.

Therefore, shutdown the connection first, then join the threads, then
close the connection.

Refs commit 9c08eb79cb
This commit is contained in:
Romain Vimont 2023-11-01 14:52:38 +01:00
parent 55a15ad75d
commit b10bb9f8bf
2 changed files with 14 additions and 3 deletions

View File

@ -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();
}
}

View File

@ -163,6 +163,8 @@ public final class Server {
asyncProcessor.stop();
}
connection.shutdown();
try {
initThread.join();
for (AsyncProcessor asyncProcessor : asyncProcessors) {