Skip to content

Commit e038cf7

Browse files
committed
Mitigate the missed-request/retransmit feedback loop.
1 parent 0f2f821 commit e038cf7

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

ClientSource/Connection/PABotBase.cpp

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,37 @@ void PABotBase::retransmit_thread(){
563563

564564
// Retransmit
565565
// Iterate through all pending requests and retransmit them in
566-
// chronological order. Skip the ones that are new.
566+
// chronological order. ~~Skip the ones that are new.~~
567+
// (Don't skip the new ones since it will lead to gaps.)
568+
569+
// Gather together all requests/commands. Sort them by seqnum and
570+
// resend everything.
571+
572+
WallClock oldest = last_sent;
573+
574+
std::map<uint64_t, const BotBaseMessage*> messages;
575+
for (auto& item : m_pending_requests){
576+
item.second.sanitizer.check_usage();
577+
if (item.second.state == AckState::NOT_ACKED){
578+
oldest = std::max(oldest, item.second.first_sent);
579+
messages[item.first] = &item.second.request;
580+
}
581+
}
582+
for (auto& item : m_pending_commands){
583+
item.second.sanitizer.check_usage();
584+
if (item.second.state == AckState::NOT_ACKED){
585+
oldest = std::max(oldest, item.second.first_sent);
586+
messages[item.first] = &item.second.request;
587+
}
588+
}
589+
590+
if (!messages.empty() && now - oldest >= m_retransmit_delay){
591+
for (const auto& item : messages){
592+
send_message(*item.second, true);
593+
}
594+
}
595+
596+
#if 0
567597
for (auto& item : m_pending_requests){
568598
item.second.sanitizer.check_usage();
569599
if (item.second.state == AckState::NOT_ACKED &&
@@ -580,6 +610,8 @@ void PABotBase::retransmit_thread(){
580610
send_message(item.second.request, true);
581611
}
582612
}
613+
#endif
614+
583615
last_sent = current_time();
584616
}
585617
// cout << "retransmit_thread() - exit" << endl;

0 commit comments

Comments
 (0)