Try to fix issues with clients locking up due to never receiving acks back in case of dropped packets #151

Merged
alufolie91 merged 4 commits from fixdupeacks into Saturn-Next 2025-01-30 10:26:34 +01:00
+16 -7
View File
@@ -325,10 +325,10 @@ static void RemoveAck(INT32 i)
}
// We have got a packet, proceed the ack request and ack return
static boolean Processackpak(void)
static int Processackpak(void)
{
INT32 i;
boolean goodpacket = true;
int goodpacket = 0;
node_t *node = &nodes[doomcom->remotenode];
// Received an ack return, so remove the ack in the list
@@ -353,7 +353,7 @@ static boolean Processackpak(void)
{
DEBFILE(va("Discard(1) ack %d (duplicated)\n", ack));
duppacket++;
goodpacket = false; // Discard packet (duplicate)
goodpacket = 1; // Discard packet (duplicate)
}
else
{
@@ -363,10 +363,10 @@ static boolean Processackpak(void)
{
DEBFILE(va("Discard(2) ack %d (duplicated)\n", ack));
duppacket++;
goodpacket = false; // Discard packet (duplicate)
goodpacket = 1; // Discard packet (duplicate)
break;
}
if (goodpacket)
if (goodpacket == 0)
{
// Is a good packet so increment the acknowledge number,
// Then search for a "hole" in the queue
@@ -427,12 +427,13 @@ static boolean Processackpak(void)
else // Buffer full discard packet, sender will resend it
{ // We can admit the packet but we will not detect the duplication after :(
DEBFILE("no more freeackret\n");
goodpacket = false;
goodpacket = 2;
}
}
}
}
}
// return values: 0 = ok, 1 = duplicate, 2 = out of order
return goodpacket;
}
#endif
@@ -1158,6 +1159,7 @@ boolean HGetPacket(void)
while(true)
{
//nodejustjoined = I_NetGet();
int goodpacket;
I_NetGet();
if (doomcom->remotenode == -1) // No packet received
@@ -1202,8 +1204,15 @@ boolean HGetPacket(void)
}*/
// Proceed the ack and ackreturn field
if (!Processackpak())
goodpacket = Processackpak();
if (goodpacket != 0)
{
// resend the ACK in case the previous ACK didn't reach the client.
// prevents the client's netbuffer from locking up.
if (goodpacket == 1)
Net_SendAcks(doomcom->remotenode);
continue; // discarded (duplicated)
}
// A packet with just ackreturn
if (netbuffer->packettype == PT_NOTHING)