Skip to content

Commit

Permalink
When the uTP socket stalls, mark failed packets for resend
Browse files Browse the repository at this point in the history
  • Loading branch information
thrnz authored and arvidn committed Sep 25, 2022
1 parent 17e3fc3 commit 4269b7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* uTP performance, fix packet loss when sending is stalled
* fix trackers being stuck after session pause/resume
* fix bug in hash_picker with empty files
* uTP performance, prevent premature timeouts/resends
Expand Down
8 changes: 8 additions & 0 deletions src/utp_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,8 @@ void utp_socket_impl::send_syn()

if (!m_stalled)
++p->num_transmissions;
else
p->need_resend = true;

TORRENT_ASSERT(!m_outbuf.at(m_seq_nr));
TORRENT_ASSERT(h->seq_nr == m_seq_nr);
Expand Down Expand Up @@ -1711,6 +1713,10 @@ bool utp_socket_impl::send_pkt(int const flags)
TORRENT_ASSERT(p->mtu_probe == (m_seq_nr == m_mtu_seq)
|| m_seq_nr == 0);

// If we're stalled we'll need to resend
if (m_stalled)
p->need_resend = true;

// If this packet is undersized then note the sequenece number so we
// never have more than one undersized packet in flight at once
if (int(p->size) < std::min(int(p->allocated), effective_mtu))
Expand Down Expand Up @@ -1878,6 +1884,8 @@ bool utp_socket_impl::resend_packet(packet* p, bool fast_resend)

if (!m_stalled)
++p->num_transmissions;
else
p->need_resend = true;

return !m_stalled;
}
Expand Down

0 comments on commit 4269b7b

Please sign in to comment.