Fix a potential race condition

This commit is contained in:
Henrik Rydgård
2026-03-09 00:51:39 +01:00
parent cf9ee07b8e
commit 71d884379d
2 changed files with 6 additions and 1 deletions
+4
View File
@@ -46,6 +46,7 @@ public:
if (callback_) {
callback_(*this);
}
hasRunCallback_ = true;
}
virtual void Start() = 0;
@@ -54,6 +55,8 @@ public:
virtual bool Done() = 0;
virtual bool Failed() const = 0;
virtual bool HasRunCallback() { return Done() && hasRunCallback_; }
// Returns 1.0 when done. That one value can be compared exactly - or just use Done().
float Progress() const { return progress_.progress; }
float SpeedKBps() const { return progress_.kBps; }
@@ -87,6 +90,7 @@ protected:
Buffer buffer_;
bool cancelled_ = false;
int resultCode_ = 0;
bool hasRunCallback_ = false;
std::vector<std::string> responseHeaders_;
net::RequestProgress progress_;
+2 -1
View File
@@ -213,7 +213,8 @@ void AdhocLoadServerList(bool sync) {
do {
sleep_ms(10, "waiting-for-adhoc-server-list");
g_DownloadManager.Update();
} while (!dl->Done());
} while (!dl->HasRunCallback());
dl.reset();
}
g_serverListLoaded = true;
} else if (!g_Config.sAdhocServerListUrl.empty()) {