mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-06 02:01:58 +02:00
Fix race conditions from Play Store (#1696)
This commit is contained in:
@@ -397,7 +397,9 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
Util.close(socket)
|
||||
if (::socket.isInitialized) {
|
||||
Util.close(socket)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package dev.slimevr.websocketapi;
|
||||
import dev.slimevr.protocol.ConnectionContext;
|
||||
import dev.slimevr.protocol.GenericConnection;
|
||||
import org.java_websocket.WebSocket;
|
||||
import org.java_websocket.exceptions.WebsocketNotConnectedException;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.UUID;
|
||||
@@ -27,8 +28,13 @@ public class WebsocketConnection implements GenericConnection {
|
||||
|
||||
@Override
|
||||
public void send(ByteBuffer bytes) {
|
||||
if (this.conn.isOpen())
|
||||
this.conn.send(bytes.slice());
|
||||
if (this.conn.isOpen()) {
|
||||
try {
|
||||
this.conn.send(bytes.slice());
|
||||
} catch (WebsocketNotConnectedException ignored) {
|
||||
// Race condition if it closes between our check and sending
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user