From 49fb23e82473d3e650ff4d3c2bf9e365455ef74c Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 7 Oct 2011 14:02:06 +0200 Subject: Dump sessions in session xml files before discard, when session_discard_path is in the config file. --- server/src/configuration.cc | 1 + server/src/configuration.h | 1 + server/src/configurationparser.cc | 6 ++++++ server/src/session.cc | 7 +++++++ 4 files changed, 15 insertions(+) (limited to 'server') diff --git a/server/src/configuration.cc b/server/src/configuration.cc index b222639..65eeae6 100644 --- a/server/src/configuration.cc +++ b/server/src/configuration.cc @@ -61,3 +61,4 @@ int Conf::connection_limit = 42; int Conf::connection_timeout = 0; std::string Conf::session_path = "/tmp"; +std::string Conf::session_discard_path = ""; diff --git a/server/src/configuration.h b/server/src/configuration.h index b6adadc..bf05572 100644 --- a/server/src/configuration.h +++ b/server/src/configuration.h @@ -69,6 +69,7 @@ namespace Conf { extern int connection_timeout; extern std::string session_path; + extern std::string session_discard_path; }; #endif/*__ARTEFACT_CONFIGURATION_H__*/ diff --git a/server/src/configurationparser.cc b/server/src/configurationparser.cc index 0796cb9..ca78c84 100644 --- a/server/src/configurationparser.cc +++ b/server/src/configurationparser.cc @@ -195,6 +195,12 @@ void ConfigurationParser::reload() Conf::session_path = s; } catch( ... ) { } + + try { + std::string s = lookup("session_discard_path"); + Conf::session_discard_path = s; + } catch( ... ) { + } } #ifdef TEST_CONFIGURATIONPARSER diff --git a/server/src/session.cc b/server/src/session.cc index e236416..8071d45 100644 --- a/server/src/session.cc +++ b/server/src/session.cc @@ -152,10 +152,17 @@ void Session::discard() { DEBUG(session, "[%p] discard(sessionid: '%s')\n", this, sessionid.c_str()); + // Store session file in discarded folder before deleting. + if(isreadonly == false && Conf::session_discard_path != "") { + SessionSerialiser ser(env, Conf::session_discard_path); + ser.save(this); + } + if(_journal) { delete _journal; _journal = NULL; } + if(isreadonly == false) { AutoBorrower borrower(env->dbpool); Database *db = borrower.get(); -- cgit v1.2.3