Reduce VPN control packet latency
This commit is contained in:
@@ -30,8 +30,8 @@ android {
|
||||
applicationId "su.cin.rapvpn"
|
||||
minSdk 26
|
||||
targetSdk 35
|
||||
versionCode 202
|
||||
versionName "0.2.202"
|
||||
versionCode 203
|
||||
versionName "0.2.203"
|
||||
buildConfigField "String", "DEFAULT_BACKEND_URL", "\"${normalizeGradleString(defaultBackendUrl)}\""
|
||||
buildConfigField "String", "DEFAULT_CLUSTER_ID", "\"${normalizeGradleString(defaultClusterId)}\""
|
||||
buildConfigField "String", "DEFAULT_ORGANIZATION_ID", "\"${normalizeGradleString(defaultOrganizationId)}\""
|
||||
|
||||
@@ -26,6 +26,7 @@ final class VpnPacketWebSocketRelay {
|
||||
private static final int MAX_SINGLE_PACKET_BYTES = 65535;
|
||||
private static final long CONNECTING_STALE_MS = 8000;
|
||||
private static final long OPEN_WAIT_MS = 3500;
|
||||
private static final int PRIORITY_GRACE_MS = 2;
|
||||
|
||||
private final String baseUrl;
|
||||
private final VpnService vpnService;
|
||||
@@ -158,7 +159,11 @@ final class VpnPacketWebSocketRelay {
|
||||
if (packets != null) {
|
||||
return packets;
|
||||
}
|
||||
packets = incoming.poll(Math.min(2, waitMs), TimeUnit.MILLISECONDS);
|
||||
packets = priorityIncoming.poll(Math.min(PRIORITY_GRACE_MS, waitMs), TimeUnit.MILLISECONDS);
|
||||
if (packets != null) {
|
||||
return packets;
|
||||
}
|
||||
packets = incoming.poll();
|
||||
if (packets != null) {
|
||||
return packets;
|
||||
}
|
||||
@@ -166,7 +171,7 @@ final class VpnPacketWebSocketRelay {
|
||||
if (packets != null) {
|
||||
return packets;
|
||||
}
|
||||
packets = incoming.poll(Math.max(1, waitMs - 2), TimeUnit.MILLISECONDS);
|
||||
packets = incoming.poll(Math.max(1, waitMs - PRIORITY_GRACE_MS), TimeUnit.MILLISECONDS);
|
||||
return packets == null ? new ArrayList<>() : packets;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user