Skip to content

Commit fe5cb2c

Browse files
committed
Remove broken timeout behaviour
Code that relies on `resend_count` was added in 7ea4a03 and 247a1eb, but never worked. This was fixed in #11607 which caused the problem to surface. Hence undo the first commit entirely and change the logic of the second.
1 parent 6ea558f commit fe5cb2c

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

src/network/connectionthreads.cpp

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ std::mutex log_conthread_mutex;
4848
#undef DEBUG_CONNECTION_KBPS
4949
#endif
5050

51-
/* maximum number of retries for reliable packets */
52-
#define MAX_RELIABLE_RETRY 5
53-
5451
#define WINDOW_SIZE 5
5552

5653
static session_t readPeerId(u8 *packetdata)
@@ -212,7 +209,6 @@ void ConnectionSendThread::runTimeouts(float dtime)
212209
}
213210

214211
float resend_timeout = udpPeer->getResendTimeout();
215-
bool retry_count_exceeded = false;
216212
for (Channel &channel : udpPeer->channels) {
217213

218214
// Remove timed out incomplete unreliable split packets
@@ -231,24 +227,16 @@ void ConnectionSendThread::runTimeouts(float dtime)
231227
m_iteration_packets_avaialble -= timed_outs.size();
232228

233229
for (const auto &k : timed_outs) {
234-
session_t peer_id = readPeerId(*k.data);
235230
u8 channelnum = readChannel(*k.data);
236231
u16 seqnum = readU16(&(k.data[BASE_HEADER_SIZE + 1]));
237232

238233
channel.UpdateBytesLost(k.data.getSize());
239234

240-
if (k.resend_count > MAX_RELIABLE_RETRY) {
241-
retry_count_exceeded = true;
242-
timeouted_peers.push_back(peer->id);
243-
/* no need to check additional packets if a single one did timeout*/
244-
break;
245-
}
246-
247235
LOG(derr_con << m_connection->getDesc()
248236
<< "RE-SENDING timed-out RELIABLE to "
249237
<< k.address.serializeString()
250238
<< "(t/o=" << resend_timeout << "): "
251-
<< "from_peer_id=" << peer_id
239+
<< "count=" << k.resend_count
252240
<< ", channel=" << ((int) channelnum & 0xff)
253241
<< ", seqnum=" << seqnum
254242
<< std::endl);
@@ -259,17 +247,9 @@ void ConnectionSendThread::runTimeouts(float dtime)
259247
// lost or really takes more time to transmit
260248
}
261249

262-
if (retry_count_exceeded) {
263-
break; /* no need to check other channels if we already did timeout */
264-
}
265-
266250
channel.UpdateTimers(dtime);
267251
}
268252

269-
/* skip to next peer if we did timeout */
270-
if (retry_count_exceeded)
271-
continue;
272-
273253
/* send ping if necessary */
274254
if (udpPeer->Ping(dtime, data)) {
275255
LOG(dout_con << m_connection->getDesc()
@@ -1153,8 +1133,8 @@ SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Control(Channel *chan
11531133
try {
11541134
BufferedPacket p = channel->outgoing_reliables_sent.popSeqnum(seqnum);
11551135

1156-
// only calculate rtt from straight sent packets
1157-
if (p.resend_count == 0) {
1136+
// the rtt calculation will be a bit off for re-sent packets but that's okay
1137+
{
11581138
// Get round trip time
11591139
u64 current_time = porting::getTimeMs();
11601140

@@ -1174,6 +1154,7 @@ SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Control(Channel *chan
11741154
dynamic_cast<UDPPeer *>(peer)->reportRTT(rtt);
11751155
}
11761156
}
1157+
11771158
// put bytes for max bandwidth calculation
11781159
channel->UpdateBytesSent(p.data.getSize(), 1);
11791160
if (channel->outgoing_reliables_sent.size() == 0)

0 commit comments

Comments
 (0)