Reoo88 commited on
Commit
d948a08
ยท
verified ยท
1 Parent(s): d632964

stall watchdog: no fake last-byte on reattach; cap swapping at stall timeout (measured 40-57s freeze @vimtoo.2)

Browse files
Files changed (1) hide show
  1. relay.py +7 -2
relay.py CHANGED
@@ -576,6 +576,7 @@ class Sender:
576
  return None
577
  sess['swapping'] = True
578
  sess['swap_source'] = True
 
579
  try:
580
  if response:
581
  try:
@@ -606,7 +607,8 @@ class Sender:
606
  sess['stall_reason'] = ''
607
  sess['force_stop'] = False
608
  sess['timeouts'] = 0
609
- sess['last'] = time.monotonic()
 
610
  sess['reattaches'] = int(sess.get('reattaches') or 0) + 1
611
  self.current_candidate = cand
612
  self.set(source=cand.get('label') or cand.get('brief') or '', stalled=False)
@@ -809,7 +811,10 @@ class Sender:
809
  # ุญูŠู‹ุง ูˆูŠูˆุชูŠูˆุจ ูŠุจู‚ู‰ ุนู„ู‰ ุขุฎุฑ ุซุงู†ูŠุฉ โ€” ูˆู‡ุฐุง ู‡ูˆ ุงู„ุชุนู„ูŠู‚ ุงู„ุฐูŠ ุดูƒุง ู…ู†ู‡ ุงู„ู…ุณุชุฎุฏู….
810
  # ููŠ HLS ูŠุณุชุญูŠู„ ุงู„ู‚ูŠุงุณ ุฅู„ุง ุนู„ู‰ FFmpeg (ู‡ูˆ ู…ู† ูŠูุชุญ ุงู„ู‚ุงุฆู…ุฉ)ุŒ ูู†ู‚ุจู„ ุชู‚ุฏู‘ู…ู‡.
811
  _fresh = (sess['ff_last'] if response is None else sess['last'])
812
- if stall_limit and not sess.get('swapping') and now - _fresh > stall_limit:
 
 
 
813
  attached = self._try_reattach(user, p, bridge, sess, stop, refresh,
814
  read_timeout, retries, response, pump)
815
  if attached:
 
576
  return None
577
  sess['swapping'] = True
578
  sess['swap_source'] = True
579
+ sess['swap_started'] = time.monotonic()
580
  try:
581
  if response:
582
  try:
 
607
  sess['stall_reason'] = ''
608
  sess['force_stop'] = False
609
  sess['timeouts'] = 0
610
+ # Do not bump sess['last'] here: that hid 40โ€“57s of silence from the
611
+ # 12s stall watchdog (measured @vimtoo.2: out frozen, age 42โ€“57, yh still good).
612
  sess['reattaches'] = int(sess.get('reattaches') or 0) + 1
613
  self.current_candidate = cand
614
  self.set(source=cand.get('label') or cand.get('brief') or '', stalled=False)
 
811
  # ุญูŠู‹ุง ูˆูŠูˆุชูŠูˆุจ ูŠุจู‚ู‰ ุนู„ู‰ ุขุฎุฑ ุซุงู†ูŠุฉ โ€” ูˆู‡ุฐุง ู‡ูˆ ุงู„ุชุนู„ูŠู‚ ุงู„ุฐูŠ ุดูƒุง ู…ู†ู‡ ุงู„ู…ุณุชุฎุฏู….
812
  # ููŠ HLS ูŠุณุชุญูŠู„ ุงู„ู‚ูŠุงุณ ุฅู„ุง ุนู„ู‰ FFmpeg (ู‡ูˆ ู…ู† ูŠูุชุญ ุงู„ู‚ุงุฆู…ุฉ)ุŒ ูู†ู‚ุจู„ ุชู‚ุฏู‘ู…ู‡.
813
  _fresh = (sess['ff_last'] if response is None else sess['last'])
814
+ swap_for = (now - float(sess.get('swap_started') or 0)) if sess.get('swapping') else 0.0
815
+ # swapping must not disable the stall watchdog for longer than the stall
816
+ # limit: refresh()+HTTP open was measured at 40โ€“57s of frozen viewers.
817
+ if stall_limit and now - _fresh > stall_limit and (not sess.get('swapping') or swap_for > stall_limit):
818
  attached = self._try_reattach(user, p, bridge, sess, stop, refresh,
819
  read_timeout, retries, response, pump)
820
  if attached: