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 b8c5853aa6
commit ff579990c2
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) {