[icinga-checkins] icinga.org: icinga2/master: Use application start-up time for the IDO session token

git at icinga.org git at icinga.org
Fri Jul 29 08:40:25 CEST 2016


Module: icinga2
Branch: master
Commit: 0d02b01c027d6618451c1ec2cb9bd6aede4da752
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=0d02b01c027d6618451c1ec2cb9bd6aede4da752

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Fri Jul 29 08:40:10 2016 +0200

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 170288c..e9f5ca0 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 ca05a47..8423719 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<DbObject::Ptr, DbReference> m_ObjectIDs;
diff --git a/lib/db_ido_mysql/idomysqlconnection.cpp b/lib/db_ido_mysql/idomysqlconnection.cpp
index 9e0ac7a..5efda95 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<int>(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<long>(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<long>(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 ee7cb9e..816c34e 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 7b8117d..b3f2e75 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<int>(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<long>(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<long>(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 0be3a8e..06858e3 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;
 



More information about the icinga-checkins mailing list