Skip to content
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

Resend uTP ACKs that fail to send due to stalling #7113

Merged
merged 1 commit into from
Sep 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions src/utp_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,10 @@ void utp_socket_impl::writable()
m_stalled = false;
if (should_delete()) return;

while(send_pkt());
// if the socket stalled while sending an ack then there will be a
// pending deferred ack. make sure it gets sent out
if (!m_deferred_ack || send_pkt(pkt_ack))
while(send_pkt());
Comment on lines +965 to +968
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this: If there's no outstanding unsent ack then go straight to the send_pkt() loop like normal, otherwise use the pkt_ack flag for the first call, then proceed into the loop if needed. It's much simpler, and I think will achieve the same thing.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that sounds good


maybe_trigger_send_callback();
}
Expand Down Expand Up @@ -1686,17 +1689,19 @@ bool utp_socket_impl::send_pkt(int const flags)
, static_cast<void*>(this), packet_timeout());
#endif
}
// Any queued up deferred ack is now redundant
if (m_deferred_ack)
{
#if TORRENT_UTP_LOG
UTP_LOGV("%8p: Cancelling redundant deferred ack\n"
, static_cast<void*>(this));
#endif
m_deferred_ack = false;
}
}

// Any queued up deferred ack is now redundant
if (m_deferred_ack)
{
#if TORRENT_UTP_LOG
UTP_LOGV("%8p: Cancelling redundant deferred ack\n"
, static_cast<void*>(this));
#endif
m_deferred_ack = false;
}
// If this is an ack then defer it to when the socket becomes writable again
else if (p->size == p->header_size && (flags & pkt_ack))
defer_ack();

// if we have payload, we need to save the packet until it's acked
// and progress m_seq_nr
Expand Down