Merge pull request #88043 from jsjtxietian/web-data-race

Fix data race regarding `server_quit` in `EditorExportPlatformWeb`
This commit is contained in:
Rémi Verschelde 2024-02-07 11:06:23 +01:00
commit e89807514e
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 3 additions and 3 deletions

View file

@ -676,7 +676,7 @@ Ref<Texture2D> EditorExportPlatformWeb::get_run_icon() const {
void EditorExportPlatformWeb::_server_thread_poll(void *data) {
EditorExportPlatformWeb *ej = static_cast<EditorExportPlatformWeb *>(data);
while (!ej->server_quit) {
while (!ej->server_quit.get()) {
OS::get_singleton()->delay_usec(6900);
{
MutexLock lock(ej->server_lock);
@ -714,7 +714,7 @@ EditorExportPlatformWeb::~EditorExportPlatformWeb() {
if (server.is_valid()) {
server->stop();
}
server_quit = true;
server_quit.set(true);
if (server_thread.is_started()) {
server_thread.wait_to_finish();
}

View file

@ -52,7 +52,7 @@ class EditorExportPlatformWeb : public EditorExportPlatform {
int menu_options = 0;
Ref<EditorHTTPServer> server;
bool server_quit = false;
SafeNumeric<bool> server_quit;
Mutex server_lock;
Thread server_thread;