-
-
Save ghazel/0a3b9bdc9f3a81dda96f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: utp/utp.cpp | |
=================================================================== | |
--- utp/utp.cpp (revision 22356) | |
+++ utp/utp.cpp (working copy) | |
@@ -1521,6 +1521,8 @@ | |
return acked_bytes; | |
} | |
+enum { MAX_EACK = 128; } | |
+ | |
void UTPSocket::selective_ack(uint base, const byte *mask, byte len) | |
{ | |
if (cur_window_packets == 0) return; | |
@@ -1533,7 +1535,7 @@ | |
// resends is a stack of sequence numbers we need to resend. Since we | |
// iterate in reverse over the acked packets, at the end, the top packets | |
// are the ones we want to resend | |
- int resends[32]; | |
+ int resends[MAX_EACK]; | |
int nr = 0; | |
LOG_UTPV("0x%08x: Got EACK [%032b] base:%u", this, *(uint32*)mask, base); | |
@@ -1606,6 +1608,12 @@ | |
if (((v - fast_resend_seq_nr) & ACK_NR_MASK) <= OUTGOING_BUFFER_MAX_SIZE && | |
count >= DUPLICATE_ACKS_BEFORE_RESEND && | |
duplicate_ack < DUPLICATE_ACKS_BEFORE_RESEND) { | |
+ // resends is a stack, and we're mostly interested in the top of it | |
+ // if we're full, just throw away the lower half | |
+ if (nr >= MAX_EACK) { | |
+ memmov(resends, resends + MAX_EACK/2 * sizeof(resends[0]), MAX_EACK/2 * sizeof(resends[0])); | |
+ nr -= MAX_EACK / 2; | |
+ } | |
resends[nr++] = v; | |
LOG_UTPV("0x%08x: no ack for %u", this, v); | |
} else { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment