mirror of
https://github.com/transmission/transmission
synced 2024-12-22 07:42:37 +00:00
fix: keep peer io alive inside utp callback (#6507)
This commit is contained in:
parent
468de87076
commit
a1160f1556
1 changed files with 5 additions and 0 deletions
|
@ -725,6 +725,11 @@ void tr_peerIo::utp_init([[maybe_unused]] struct_utp_context* ctx)
|
||||||
{
|
{
|
||||||
if (auto* const io = static_cast<tr_peerIo*>(utp_get_userdata(args->socket)); io != nullptr)
|
if (auto* const io = static_cast<tr_peerIo*>(utp_get_userdata(args->socket)); io != nullptr)
|
||||||
{
|
{
|
||||||
|
// The peer io object can destruct inside can_read_wrapper(), so keep
|
||||||
|
// it alive for the duration of this code block. This can happen when
|
||||||
|
// a BT handshake did not complete successfully for example.
|
||||||
|
auto const keep_alive = io->shared_from_this();
|
||||||
|
|
||||||
io->inbuf_.add(args->buf, args->len);
|
io->inbuf_.add(args->buf, args->len);
|
||||||
io->set_enabled(TR_DOWN, true);
|
io->set_enabled(TR_DOWN, true);
|
||||||
io->can_read_wrapper();
|
io->can_read_wrapper();
|
||||||
|
|
Loading…
Reference in a new issue