Skip to content

Commit b8656b5

Browse files
committed
net: Send resend requests to server on deadlock.
The server already triggers resend requests if it detects a potential deadlock has occurred, but the same scenario can occur if one of the clients loses enough game data packets from the server. So detect this on the client side too and trigger artificial resend requests. Big thanks go to MadDog and Mortrixs for providing network logs of the deadlock occurring which allowed me to figure out the cause.
1 parent 945355d commit b8656b5

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/net_client.c

+15-2
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,10 @@ static void NET_CL_CheckResends(void)
611611
int i;
612612
int resend_start, resend_end;
613613
unsigned int nowtime;
614+
boolean maybe_deadlocked;
614615

615616
nowtime = I_GetTimeMS();
617+
maybe_deadlocked = nowtime - gamedata_recv_time > 1000;
616618

617619
resend_start = -1;
618620
resend_end = -1;
@@ -631,15 +633,26 @@ static void NET_CL_CheckResends(void)
631633
&& recvobj->resend_time != 0
632634
&& nowtime > recvobj->resend_time + 300;
633635

636+
// if no game data has been received in a long time, we may be in
637+
// a deadlock scenario where tics from the server have been lost, so
638+
// we've stopped generating any more, so the server isn't sending us
639+
// any, so we don't get any to trigger a resend request. So force the
640+
// first few tics in the receive window to be requested.
641+
if (i == 0 && !recvobj->active && recvobj->resend_time == 0
642+
&& maybe_deadlocked)
643+
{
644+
need_resend = true;
645+
}
646+
634647
if (need_resend)
635648
{
636649
// Start a new run of resend tics?
637-
650+
638651
if (resend_start < 0)
639652
{
640653
resend_start = i;
641654
}
642-
655+
643656
resend_end = i;
644657
}
645658
else if (resend_start >= 0)

0 commit comments

Comments
 (0)