1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-03 13:35:36 +00:00

fix: reconstruct utp_core_ when toggling utp (#6075)

This commit is contained in:
Yat Ho 2023-10-05 09:33:18 +08:00 committed by GitHub
parent 3f7340502f
commit c6236c7bee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -677,10 +677,7 @@ void tr_session::setSettings(tr_session_settings&& settings_in, bool force)
setDefaultTrackers(val);
}
if (auto const& val = new_settings.utp_enabled; force || val != old_settings.utp_enabled)
{
tr_sessionSetUTPEnabled(this, val);
}
bool const utp_changed = new_settings.utp_enabled != old_settings.utp_enabled;
useBlocklist(new_settings.blocklist_enabled);
@ -727,9 +724,7 @@ void tr_session::setSettings(tr_session_settings&& settings_in, bool force)
port_forwarding_->local_port_changed();
}
bool const dht_changed = new_settings.dht_enabled != old_settings.dht_enabled;
if (!udp_core_ || force || port_changed || dht_changed)
if (!udp_core_ || force || port_changed || utp_changed)
{
udp_core_ = std::make_unique<tr_session::tr_udp_core>(*this, udpPort());
}
@ -748,11 +743,11 @@ void tr_session::setSettings(tr_session_settings&& settings_in, bool force)
}
}
if (!allowsDHT())
if (!new_settings.dht_enabled)
{
dht_.reset();
}
else if (force || !dht_ || port_changed || addr_changed || dht_changed)
else if (force || !dht_ || port_changed || addr_changed || new_settings.dht_enabled != old_settings.dht_enabled)
{
dht_ = tr_dht::create(dht_mediator_, localPeerPort(), udp_core_->socket4(), udp_core_->socket6());
}
@ -1450,7 +1445,13 @@ void tr_sessionSetUTPEnabled(tr_session* session, bool enabled)
return;
}
session->settings_.utp_enabled = enabled;
session->runInSessionThread(
[session, enabled]()
{
auto settings = session->settings_;
settings.utp_enabled = enabled;
session->setSettings(std::move(settings), false);
});
}
void tr_sessionSetLPDEnabled(tr_session* session, bool enabled)