From 1ff328a3e6cce14797f597d7ae8cbf6ff108111e Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 21 Aug 2021 21:44:14 +0200 Subject: [PATCH] Removed the mutex from User. I'm going to change how users work. --- modules/users/db_based_user.cpp | 8 -------- modules/users/user.cpp | 14 -------------- modules/users/user.h | 2 -- 3 files changed, 24 deletions(-) diff --git a/modules/users/db_based_user.cpp b/modules/users/db_based_user.cpp index fb307e1..69694c7 100644 --- a/modules/users/db_based_user.cpp +++ b/modules/users/db_based_user.cpp @@ -8,8 +8,6 @@ #include void DBBasedUser::save() { - _mutex.lock(); - QueryBuilder *b = DatabaseManager::get_singleton()->ddb->get_query_builder(); if (get_id() == 0) { @@ -79,15 +77,11 @@ void DBBasedUser::save() { b->run_query(); delete b; - - _mutex.unlock(); } void DBBasedUser::load() { unregister_sessions(); - _mutex.lock(); - if (get_id() == 0) { return; } @@ -134,8 +128,6 @@ void DBBasedUser::load() { delete b; - _mutex.unlock(); - register_sessions(); } diff --git a/modules/users/user.cpp b/modules/users/user.cpp index 5df6c21..c117098 100644 --- a/modules/users/user.cpp +++ b/modules/users/user.cpp @@ -149,8 +149,6 @@ void User::register_sessions() { return; } - _mutex.lock(); - for (int i = 0; i < _sessions.size(); ++i) { HTTPSession *session = new HTTPSession(); session->session_id = _sessions[i]; @@ -158,8 +156,6 @@ void User::register_sessions() { sm->add_session(session); } - - _mutex.unlock(); } void User::unregister_sessions() { @@ -174,13 +170,9 @@ void User::unregister_sessions() { return; } - _mutex.lock(); - for (int i = 0; i < _sessions.size(); ++i) { sm->delete_session(_sessions[i]); } - - _mutex.unlock(); } void User::handle_request_default(Request *request) { @@ -243,9 +235,7 @@ void User::handle_login_request_default(Request *request) { session->add_object("user", user); - user->_mutex.lock(); user->_sessions.push_back(session->session_id); - user->_mutex.unlock(); user->save(); @@ -630,8 +620,6 @@ void User::handle_password_reset_request(Request *request) { void User::handle_logout_request(Request *request) { request->remove_cookie("session_id"); - _mutex.lock(); - for (int i = 0; i < _sessions.size(); ++i) { if (_sessions[i] == request->session->session_id) { _sessions[i] = _sessions[_sessions.size() - 1]; @@ -639,8 +627,6 @@ void User::handle_logout_request(Request *request) { } } - _mutex.unlock(); - save(); SessionManager::get_singleton()->delete_session(request->session->session_id); diff --git a/modules/users/user.h b/modules/users/user.h index 2dd9779..72c2ba1 100644 --- a/modules/users/user.h +++ b/modules/users/user.h @@ -93,8 +93,6 @@ protected: static FormValidator *_login_validator; static FormValidator *_registration_validator; static FormValidator *_profile_validator; - - std::mutex _mutex; }; #endif \ No newline at end of file