Use application start-up time for the IDO session token

fixes #12250
This commit is contained in:
Gunnar Beutner 2016-07-29 08:40:10 +02:00
parent 92c28548d1
commit 0d02b01c02
6 changed files with 11 additions and 8 deletions

View File

@ -492,3 +492,8 @@ void DbConnection::SetIDCacheValid(bool valid)
{ {
m_IDCacheValid = valid; m_IDCacheValid = valid;
} }
int DbConnection::GetSessionToken(void)
{
return Application::GetStartTime();
}

View File

@ -100,6 +100,8 @@ protected:
static void UpdateProgramStatus(void); static void UpdateProgramStatus(void);
static int GetSessionToken(void);
private: private:
bool m_IDCacheValid; bool m_IDCacheValid;
std::map<DbObject::Ptr, DbReference> m_ObjectIDs; std::map<DbObject::Ptr, DbReference> m_ObjectIDs;

View File

@ -175,7 +175,6 @@ void IdoMysqlConnection::Reconnect(void)
CONTEXT("Reconnecting to MySQL IDO database '" + GetName() + "'"); CONTEXT("Reconnecting to MySQL IDO database '" + GetName() + "'");
double startTime = Utility::GetTime(); double startTime = Utility::GetTime();
m_SessionToken = static_cast<int>(Utility::GetTime());
SetShouldConnect(true); SetShouldConnect(true);
@ -449,7 +448,7 @@ void IdoMysqlConnection::ClearTableBySession(const String& table)
{ {
Query("DELETE FROM " + GetTablePrefix() + table + " WHERE instance_id = " + Query("DELETE FROM " + GetTablePrefix() + table + " WHERE instance_id = " +
Convert::ToString(static_cast<long>(m_InstanceID)) + " AND session_token <> " + Convert::ToString(static_cast<long>(m_InstanceID)) + " AND session_token <> " +
Convert::ToString(m_SessionToken)); Convert::ToString(GetSessionToken()));
} }
void IdoMysqlConnection::ClearConfigTable(const String& table) 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); *result = static_cast<long>(m_InstanceID);
return true; return true;
} else if (key == "session_token") { } else if (key == "session_token") {
*result = m_SessionToken; *result = GetSessionToken();
return true; return true;
} }

View File

@ -71,7 +71,6 @@ protected:
private: private:
DbReference m_InstanceID; DbReference m_InstanceID;
int m_SessionToken;
WorkQueue m_QueryQueue; WorkQueue m_QueryQueue;

View File

@ -174,7 +174,6 @@ void IdoPgsqlConnection::Reconnect(void)
CONTEXT("Reconnecting to PostgreSQL IDO database '" + GetName() + "'"); CONTEXT("Reconnecting to PostgreSQL IDO database '" + GetName() + "'");
double startTime = Utility::GetTime(); double startTime = Utility::GetTime();
m_SessionToken = static_cast<int>(Utility::GetTime());
SetShouldConnect(true); SetShouldConnect(true);
@ -420,7 +419,7 @@ void IdoPgsqlConnection::ClearTableBySession(const String& table)
{ {
Query("DELETE FROM " + GetTablePrefix() + table + " WHERE instance_id = " + Query("DELETE FROM " + GetTablePrefix() + table + " WHERE instance_id = " +
Convert::ToString(static_cast<long>(m_InstanceID)) + " AND session_token <> " + Convert::ToString(static_cast<long>(m_InstanceID)) + " AND session_token <> " +
Convert::ToString(m_SessionToken)); Convert::ToString(GetSessionToken()));
} }
void IdoPgsqlConnection::ClearConfigTable(const String& table) 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); *result = static_cast<long>(m_InstanceID);
return true; return true;
} else if (key == "session_token") { } else if (key == "session_token") {
*result = m_SessionToken; *result = GetSessionToken();
return true; return true;
} }

View File

@ -63,7 +63,6 @@ protected:
private: private:
DbReference m_InstanceID; DbReference m_InstanceID;
int m_SessionToken;
WorkQueue m_QueryQueue; WorkQueue m_QueryQueue;