From 0d02b01c027d6618451c1ec2cb9bd6aede4da752 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 29 Jul 2016 08:40:10 +0200 Subject: [PATCH] Use application start-up time for the IDO session token fixes #12250 --- lib/db_ido/dbconnection.cpp | 5 +++++ lib/db_ido/dbconnection.hpp | 2 ++ lib/db_ido_mysql/idomysqlconnection.cpp | 5 ++--- lib/db_ido_mysql/idomysqlconnection.hpp | 1 - lib/db_ido_pgsql/idopgsqlconnection.cpp | 5 ++--- lib/db_ido_pgsql/idopgsqlconnection.hpp | 1 - 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/db_ido/dbconnection.cpp b/lib/db_ido/dbconnection.cpp index 170288cf8..e9f5ca0fb 100644 --- a/lib/db_ido/dbconnection.cpp +++ b/lib/db_ido/dbconnection.cpp @@ -492,3 +492,8 @@ void DbConnection::SetIDCacheValid(bool valid) { m_IDCacheValid = valid; } + +int DbConnection::GetSessionToken(void) +{ + return Application::GetStartTime(); +} diff --git a/lib/db_ido/dbconnection.hpp b/lib/db_ido/dbconnection.hpp index ca05a4760..842371994 100644 --- a/lib/db_ido/dbconnection.hpp +++ b/lib/db_ido/dbconnection.hpp @@ -100,6 +100,8 @@ protected: static void UpdateProgramStatus(void); + static int GetSessionToken(void); + private: bool m_IDCacheValid; std::map m_ObjectIDs; diff --git a/lib/db_ido_mysql/idomysqlconnection.cpp b/lib/db_ido_mysql/idomysqlconnection.cpp index 9e0ac7a5c..5efda95ab 100644 --- a/lib/db_ido_mysql/idomysqlconnection.cpp +++ b/lib/db_ido_mysql/idomysqlconnection.cpp @@ -175,7 +175,6 @@ void IdoMysqlConnection::Reconnect(void) CONTEXT("Reconnecting to MySQL IDO database '" + GetName() + "'"); double startTime = Utility::GetTime(); - m_SessionToken = static_cast(Utility::GetTime()); SetShouldConnect(true); @@ -449,7 +448,7 @@ void IdoMysqlConnection::ClearTableBySession(const String& table) { Query("DELETE FROM " + GetTablePrefix() + table + " WHERE instance_id = " + Convert::ToString(static_cast(m_InstanceID)) + " AND session_token <> " + - Convert::ToString(m_SessionToken)); + Convert::ToString(GetSessionToken())); } void IdoMysqlConnection::ClearConfigTable(const String& table) @@ -748,7 +747,7 @@ bool IdoMysqlConnection::FieldToEscapedString(const String& key, const Value& va *result = static_cast(m_InstanceID); return true; } else if (key == "session_token") { - *result = m_SessionToken; + *result = GetSessionToken(); return true; } diff --git a/lib/db_ido_mysql/idomysqlconnection.hpp b/lib/db_ido_mysql/idomysqlconnection.hpp index ee7cb9e83..816c34ebb 100644 --- a/lib/db_ido_mysql/idomysqlconnection.hpp +++ b/lib/db_ido_mysql/idomysqlconnection.hpp @@ -71,7 +71,6 @@ protected: private: DbReference m_InstanceID; - int m_SessionToken; WorkQueue m_QueryQueue; diff --git a/lib/db_ido_pgsql/idopgsqlconnection.cpp b/lib/db_ido_pgsql/idopgsqlconnection.cpp index 7b8117d45..b3f2e75d5 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.cpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.cpp @@ -174,7 +174,6 @@ void IdoPgsqlConnection::Reconnect(void) CONTEXT("Reconnecting to PostgreSQL IDO database '" + GetName() + "'"); double startTime = Utility::GetTime(); - m_SessionToken = static_cast(Utility::GetTime()); SetShouldConnect(true); @@ -420,7 +419,7 @@ void IdoPgsqlConnection::ClearTableBySession(const String& table) { Query("DELETE FROM " + GetTablePrefix() + table + " WHERE instance_id = " + Convert::ToString(static_cast(m_InstanceID)) + " AND session_token <> " + - Convert::ToString(m_SessionToken)); + Convert::ToString(GetSessionToken())); } void IdoPgsqlConnection::ClearConfigTable(const String& table) @@ -605,7 +604,7 @@ bool IdoPgsqlConnection::FieldToEscapedString(const String& key, const Value& va *result = static_cast(m_InstanceID); return true; } else if (key == "session_token") { - *result = m_SessionToken; + *result = GetSessionToken(); return true; } diff --git a/lib/db_ido_pgsql/idopgsqlconnection.hpp b/lib/db_ido_pgsql/idopgsqlconnection.hpp index 0be3a8eaf..06858e336 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.hpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.hpp @@ -63,7 +63,6 @@ protected: private: DbReference m_InstanceID; - int m_SessionToken; WorkQueue m_QueryQueue;