Publish Zonghengjia Windows 0.4.0 client source
This commit is contained in:
@@ -15,6 +15,12 @@ FRESHNESS = timedelta(minutes=3)
|
||||
RESERVATION_BYTES_PER_SECOND = 128 * 1024
|
||||
|
||||
|
||||
def lock_vpn_ai_runtime():
|
||||
"""Lock the one row shared by dispatch and topology-changing operations."""
|
||||
runtime, _ = VpnAiRuntime.objects.get_or_create(service_name="vpn-ai")
|
||||
return VpnAiRuntime.objects.select_for_update().get(pk=runtime.pk)
|
||||
|
||||
|
||||
def build_dispatch_snapshot(now=None):
|
||||
now = now or timezone.now()
|
||||
reservations = dict(ClientSession.objects.filter(
|
||||
@@ -46,8 +52,7 @@ def build_dispatch_snapshot(now=None):
|
||||
def choose_node(session, excluded=(), new_connection=False):
|
||||
# Lock one small shared row to serialize concurrent reservations. Never
|
||||
# change account/node status on the strength of one client's failure.
|
||||
runtime, _ = VpnAiRuntime.objects.get_or_create(service_name="vpn-ai")
|
||||
VpnAiRuntime.objects.select_for_update().get(pk=runtime.pk)
|
||||
lock_vpn_ai_runtime()
|
||||
session = ClientSession.objects.select_for_update().get(pk=session.pk)
|
||||
now = timezone.now()
|
||||
snapshot = build_dispatch_snapshot(now)
|
||||
|
||||
Reference in New Issue
Block a user