X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/8569ecdc2c9368dc0fe650b901cce7b37337ffec..2574a28cbf000603bc31f61593dbf061ff56c1d5:/projects/stargazer/plugins/store/postgresql/postgresql_store_corporations.cpp diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store_corporations.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store_corporations.cpp index 1d33d5b0..6c6b9985 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store_corporations.cpp +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store_corporations.cpp @@ -26,19 +26,21 @@ * */ +#include "postgresql_store.h" + +#include "stg/corp_conf.h" +#include "stg/common.h" + #include #include #include #include -#include "postgresql_store.h" -#include "stg/locker.h" - //----------------------------------------------------------------------------- int POSTGRESQL_STORE::GetCorpsList(std::vector * corpsList) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +std::lock_guard lock(m_mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -92,9 +94,9 @@ return 0; } //----------------------------------------------------------------------------- -int POSTGRESQL_STORE::SaveCorp(const CORP_CONF & cc) const +int POSTGRESQL_STORE::SaveCorp(const STG::CorpConf & cc) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +std::lock_guard lock(m_mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -121,9 +123,9 @@ if (EscapeString(ename)) { printfd(__FILE__, "POSTGRESQL_STORE::SaveCorp(): 'Failed to escape name'\n"); if (RollbackTransaction()) - { - printfd(__FILE__, "POSTGRESQL_STORE::SaveCorp(): 'Failed to rollback transaction'\n"); - } + { + printfd(__FILE__, "POSTGRESQL_STORE::SaveCorp(): 'Failed to rollback transaction'\n"); + } return -1; } @@ -158,9 +160,9 @@ return 0; } //----------------------------------------------------------------------------- -int POSTGRESQL_STORE::RestoreCorp(CORP_CONF * cc, const std::string & name) const +int POSTGRESQL_STORE::RestoreCorp(STG::CorpConf * cc, const std::string & name) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +std::lock_guard lock(m_mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -187,9 +189,9 @@ if (EscapeString(ename)) { printfd(__FILE__, "POSTGRESQL_STORE::RestoreCorp(): 'Failed to escape name'\n"); if (RollbackTransaction()) - { - printfd(__FILE__, "POSTGRESQL_STORE::RestoreCorp(): 'Failed to rollback transaction'\n"); - } + { + printfd(__FILE__, "POSTGRESQL_STORE::RestoreCorp(): 'Failed to rollback transaction'\n"); + } return -1; } @@ -218,9 +220,9 @@ if (tuples != 1) printfd(__FILE__, "POSTGRESQL_STORE::RestoreCorp(): 'Invalid number of tuples. Wanted 1, actulally %d'\n", tuples); PQclear(result); if (RollbackTransaction()) - { - printfd(__FILE__, "POSTGRESQL_STORE::RestoreCorp(): 'Failed to rollback transaction'\n"); - } + { + printfd(__FILE__, "POSTGRESQL_STORE::RestoreCorp(): 'Failed to rollback transaction'\n"); + } return -1; } @@ -243,7 +245,7 @@ return 0; //----------------------------------------------------------------------------- int POSTGRESQL_STORE::AddCorp(const std::string & name) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +std::lock_guard lock(m_mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -270,9 +272,9 @@ if (EscapeString(ename)) { printfd(__FILE__, "POSTGRESQL_STORE::AddCorp(): 'Failed to escape name'\n"); if (RollbackTransaction()) - { - printfd(__FILE__, "POSTGRESQL_STORE::AddCorp(): 'Failed to rollback transaction'\n"); - } + { + printfd(__FILE__, "POSTGRESQL_STORE::AddCorp(): 'Failed to rollback transaction'\n"); + } return -1; } @@ -310,7 +312,7 @@ return 0; //----------------------------------------------------------------------------- int POSTGRESQL_STORE::DelCorp(const std::string & name) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +std::lock_guard lock(m_mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -337,9 +339,9 @@ if (EscapeString(ename)) { printfd(__FILE__, "POSTGRESQL_STORE::DelCorp(): 'Failed to escape name'\n"); if (RollbackTransaction()) - { - printfd(__FILE__, "POSTGRESQL_STORE::DelCorp(): 'Failed to rollback transaction'\n"); - } + { + printfd(__FILE__, "POSTGRESQL_STORE::DelCorp(): 'Failed to rollback transaction'\n"); + } return -1; }