mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-28 03:49:18 +01:00
Went back from using an RWLock to a Mutex in WebServerSimple.
This commit is contained in:
parent
9106b5685e
commit
a1a94ab94e
@ -146,12 +146,12 @@ void WebServerSimple::_start() {
|
|||||||
Error err;
|
Error err;
|
||||||
|
|
||||||
// Restart server.
|
// Restart server.
|
||||||
server_lock.write_lock();
|
server_lock.lock();
|
||||||
|
|
||||||
server->stop();
|
server->stop();
|
||||||
err = server->listen(bind_port, bind_ip, use_ssl, ssl_key, ssl_cert);
|
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));
|
ERR_FAIL_COND_MSG(err != OK, "Error starting HTTP server:\n" + itos(err));
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ void WebServerSimple::_stop() {
|
|||||||
|
|
||||||
WebServer::_stop();
|
WebServer::_stop();
|
||||||
|
|
||||||
server_lock.write_lock();
|
server_lock.lock();
|
||||||
|
|
||||||
server->stop();
|
server->stop();
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ void WebServerSimple::_stop() {
|
|||||||
set_process_internal(false);
|
set_process_internal(false);
|
||||||
|
|
||||||
_running = false;
|
_running = false;
|
||||||
server_lock.write_unlock();
|
server_lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
WebServerSimple::WebServerSimple() {
|
WebServerSimple::WebServerSimple() {
|
||||||
@ -222,9 +222,9 @@ WebServerSimple::~WebServerSimple() {
|
|||||||
void WebServerSimple::_notification(int p_what) {
|
void WebServerSimple::_notification(int p_what) {
|
||||||
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
|
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
|
||||||
if (_single_threaded_poll) {
|
if (_single_threaded_poll) {
|
||||||
server_lock.read_lock();
|
server_lock.lock();
|
||||||
server->poll();
|
server->poll();
|
||||||
server_lock.read_unlock();
|
server_lock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,8 +270,8 @@ void WebServerSimple::_server_thread_poll(void *data) {
|
|||||||
while (!ej->server_quit) {
|
while (!ej->server_quit) {
|
||||||
OS::get_singleton()->delay_usec(1000);
|
OS::get_singleton()->delay_usec(1000);
|
||||||
|
|
||||||
ej->server_lock.read_lock();
|
ej->server_lock.lock();
|
||||||
ej->server->poll();
|
ej->server->poll();
|
||||||
ej->server_lock.read_unlock();
|
ej->server_lock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include "core/io/stream_peer_ssl.h"
|
#include "core/io/stream_peer_ssl.h"
|
||||||
#include "core/io/tcp_server.h"
|
#include "core/io/tcp_server.h"
|
||||||
#include "core/io/zip_io.h"
|
#include "core/io/zip_io.h"
|
||||||
#include "core/os/rw_lock.h"
|
#include "core/os/mutex.h"
|
||||||
|
|
||||||
#include "../http/web_server.h"
|
#include "../http/web_server.h"
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ protected:
|
|||||||
|
|
||||||
Ref<HTTPServerSimple> server;
|
Ref<HTTPServerSimple> server;
|
||||||
bool server_quit;
|
bool server_quit;
|
||||||
RWLock server_lock;
|
Mutex server_lock;
|
||||||
Thread *_poll_thread;
|
Thread *_poll_thread;
|
||||||
bool _running;
|
bool _running;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user