diff --git a/src/core/util/Database.cc b/src/core/util/Database.cc index b723be0c..dc0b8073 100644 --- a/src/core/util/Database.cc +++ b/src/core/util/Database.cc @@ -8,7 +8,15 @@ static fail::Logger LOG("Database", true); using namespace fail; +#ifndef __puma +boost::mutex Database::m_global_lock; +#endif + Database::Database(const std::string &username, const std::string &host, const std::string &database) { +#ifndef __puma + boost::lock_guard guard(m_global_lock); +#endif + handle = mysql_init(0); last_result = 0; mysql_options(handle, MYSQL_READ_DEFAULT_FILE, "~/.my.cnf"); @@ -26,6 +34,9 @@ Database::~Database() // flush cached INSERTs if available insert_multiple(); +#ifndef __puma + boost::lock_guard guard(m_global_lock); +#endif mysql_close(handle); } diff --git a/src/core/util/Database.hpp b/src/core/util/Database.hpp index ff234f7f..66c0710b 100644 --- a/src/core/util/Database.hpp +++ b/src/core/util/Database.hpp @@ -23,6 +23,7 @@ namespace fail { MYSQL_RES *last_result; // !< Used for mysql_result_free #ifndef __puma boost::mutex m_handle_lock; + static boost::mutex m_global_lock; #endif std::string m_insertquery; std::vector m_insertquery_values;