Went back from using an RWLock to a Mutex in WebServerSimple.

This commit is contained in:
Relintai 2022-07-24 15:15:08 +02:00
parent 9106b5685e
commit a1a94ab94e
2 changed files with 10 additions and 10 deletions

View File

@ -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();
}
}

View File

@ -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<HTTPServerSimple> server;
bool server_quit;
RWLock server_lock;
Mutex server_lock;
Thread *_poll_thread;
bool _running;