Skip to content

Commit

Permalink
add connect interval control for win10
Browse files Browse the repository at this point in the history
  • Loading branch information
xxnet committed Aug 24, 2015
1 parent a6072d6 commit 0c2caad
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion gae_proxy/local/connect_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ class OSVERSIONINFOEXW(ctypes.Structure):
low_prior_lock = []
high_prior_connecting_num = 0
low_prior_connecting_num = 0
last_connect_time = 0

min_connect_interval = 0.03

def start_connect_register(high_prior=False):
global high_prior_connecting_num, low_prior_connecting_num
global high_prior_connecting_num, low_prior_connecting_num, last_connect_time
if not is_win10:
return

Expand All @@ -72,11 +75,21 @@ def start_connect_register(high_prior=False):

ccc_lock.acquire()

last_connect_interval = time.time() - last_connect_time
if last_connect_interval < 0:
xlog.error("last_connect_interval:%f", last_connect_interval)
return

if last_connect_interval < min_connect_interval:
wait_time = min_connect_interval - last_connect_interval
time.sleep(wait_time)

if high_prior:
high_prior_connecting_num += 1
else:
low_prior_connecting_num += 1
finally:
last_connect_time = time.time()
ccc_lock.release()


Expand Down

0 comments on commit 0c2caad

Please sign in to comment.