1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 16:52:39 +00:00

Protect against broken implementations of monotonic time.

Fixes #4090.
This commit is contained in:
Juliusz Chroboczek 2011-03-09 15:31:54 +00:00
parent 2d1cff1a24
commit 97229c1813

View file

@ -1893,10 +1893,19 @@ size_t UTP_ProcessIncoming(UTPSocket *conn, const byte *packet, size_t len, bool
for (int i = 0; i < acks; ++i) {
int seq = conn->seq_nr - conn->cur_window_packets + i;
OutgoingPacket *pkt = (OutgoingPacket*)conn->outbuf.get(seq);
int64 rtt;
if (pkt == 0 || pkt->transmissions == 0) continue;
assert((int)(pkt->payload) >= 0);
acked_bytes += pkt->payload;
min_rtt = min<int64>(min_rtt, UTP_GetMicroseconds() - pkt->time_sent);
rtt = UTP_GetMicroseconds() - pkt->time_sent;
if(rtt < 0) {
LOG_UTP("UTP_GetMicroseconds decreased (%ld > %ld). "
"This should not happen.",
(long)pkt->time_sent,
(long)(pkt->time_sent + rtt));
rtt = 0;
}
min_rtt = min<int64>(min_rtt, rtt);
}
// count bytes acked by EACK