From a1a94ab94e96dc80ef6ff83abdd2ec825da7b2b7 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 24 Jul 2022 15:15:08 +0200 Subject: [PATCH] Went back from using an RWLock to a Mutex in WebServerSimple. --- .../web/http_server_simple/web_server_simple.cpp | 16 ++++++++-------- .../web/http_server_simple/web_server_simple.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/web/http_server_simple/web_server_simple.cpp b/modules/web/http_server_simple/web_server_simple.cpp index c4b7e88e8..e2a69d701 100644 --- a/modules/web/http_server_simple/web_server_simple.cpp +++ b/modules/web/http_server_simple/web_server_simple.cpp @@ -146,12 +146,12 @@ void WebServerSimple::_start() { Error err; // Restart server. - server_lock.write_lock(); + server_lock.lock(); server->stop(); err = server->listen(bind_port, bind_ip, use_ssl, ssl_key, ssl_cert); - server_lock.write_unlock(); + server_lock.unlock(); ERR_FAIL_COND_MSG(err != OK, "Error starting HTTP server:\n" + itos(err)); @@ -174,7 +174,7 @@ void WebServerSimple::_stop() { WebServer::_stop(); - server_lock.write_lock(); + server_lock.lock(); server->stop(); @@ -187,7 +187,7 @@ void WebServerSimple::_stop() { set_process_internal(false); _running = false; - server_lock.write_unlock(); + server_lock.unlock(); } WebServerSimple::WebServerSimple() { @@ -222,9 +222,9 @@ WebServerSimple::~WebServerSimple() { void WebServerSimple::_notification(int p_what) { if (p_what == NOTIFICATION_INTERNAL_PROCESS) { if (_single_threaded_poll) { - server_lock.read_lock(); + server_lock.lock(); server->poll(); - server_lock.read_unlock(); + server_lock.unlock(); } } } @@ -270,8 +270,8 @@ void WebServerSimple::_server_thread_poll(void *data) { while (!ej->server_quit) { OS::get_singleton()->delay_usec(1000); - ej->server_lock.read_lock(); + ej->server_lock.lock(); ej->server->poll(); - ej->server_lock.read_unlock(); + ej->server_lock.unlock(); } } diff --git a/modules/web/http_server_simple/web_server_simple.h b/modules/web/http_server_simple/web_server_simple.h index 89198d6d7..4233e1ad7 100644 --- a/modules/web/http_server_simple/web_server_simple.h +++ b/modules/web/http_server_simple/web_server_simple.h @@ -35,7 +35,7 @@ #include "core/io/stream_peer_ssl.h" #include "core/io/tcp_server.h" #include "core/io/zip_io.h" -#include "core/os/rw_lock.h" +#include "core/os/mutex.h" #include "../http/web_server.h" @@ -100,7 +100,7 @@ protected: Ref server; bool server_quit; - RWLock server_lock; + Mutex server_lock; Thread *_poll_thread; bool _running;