mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 22:46:10 +00:00
Fix possible crash in DomainResolver.
App::CallDelayed() could be queued twice for a single key, if before the delayed call we cleared entry in _attempts and created it again.
This commit is contained in:
@@ -453,7 +453,7 @@ void DomainResolver::resolve(const AttemptKey &key) {
|
||||
auto hosts = DnsDomains();
|
||||
std::random_device rd;
|
||||
ranges::shuffle(hosts, std::mt19937(rd()));
|
||||
_attempts.emplace(key, std::move(hosts));
|
||||
_attempts.emplace(key, Attempts{ std::move(hosts) });
|
||||
sendNextRequest(key);
|
||||
}
|
||||
|
||||
@@ -478,12 +478,13 @@ void DomainResolver::sendNextRequest(const AttemptKey &key) {
|
||||
if (i == end(_attempts)) {
|
||||
return;
|
||||
}
|
||||
auto &hosts = i->second;
|
||||
auto &attempts = i->second;
|
||||
auto &hosts = attempts.hosts;
|
||||
const auto host = hosts.back();
|
||||
hosts.pop_back();
|
||||
|
||||
if (!hosts.empty()) {
|
||||
App::CallDelayed(kSendNextTimeout, this, [=] {
|
||||
App::CallDelayed(kSendNextTimeout, &attempts.guard, [=] {
|
||||
sendNextRequest(key);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user