-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix TCP race condition, remove fixed delay in CC #5167
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,37 +308,37 @@ class ClientContext | |
if (!_pcb) | ||
return true; | ||
|
||
int loop = -1; | ||
int prevsndbuf = -1; | ||
max_wait_ms++; | ||
|
||
// wait for peer's acks to flush lwIP's output buffer | ||
|
||
uint32_t last_sent = millis(); | ||
while (1) { | ||
if (millis() - last_sent > (uint32_t) max_wait_ms) { | ||
#ifdef DEBUGV | ||
// wait until sent: timeout | ||
DEBUGV(":wustmo\n"); | ||
#endif | ||
break; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this |
||
} | ||
|
||
// force lwIP to send what can be sent | ||
tcp_output(_pcb); | ||
|
||
int sndbuf = tcp_sndbuf(_pcb); | ||
if (sndbuf != prevsndbuf) { | ||
// send buffer has changed (or first iteration) | ||
// we received an ack: restart the loop counter | ||
// we received an ack: restart the timeout | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just remove this comment, your new one is better |
||
prevsndbuf = sndbuf; | ||
loop = max_wait_ms; | ||
last_sent = millis(); // We just sent a bit, move timeout forward | ||
} | ||
|
||
if (state() != ESTABLISHED || sndbuf == TCP_SND_BUF || --loop <= 0) | ||
break; | ||
|
||
delay(1); | ||
} | ||
yield(); | ||
|
||
#ifdef DEBUGV | ||
if (loop <= 0) { | ||
// wait until sent: timeout | ||
DEBUGV(":wustmo\n"); | ||
if ((state() != ESTABLISHED) || (sndbuf == TCP_SND_BUF)) { | ||
break; | ||
} | ||
} | ||
#endif | ||
|
||
return max_wait_ms > 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_wait_ms++;
no more necessary