diff options
-rw-r--r-- | project2/cgi/cgiAppEngine.cpp | 3 | ||||
-rw-r--r-- | project2/common/sessionContainer.cpp | 2 | ||||
-rw-r--r-- | project2/common/sessionContainer.h | 4 | ||||
-rw-r--r-- | project2/xml/sessionXml.cpp | 11 | ||||
-rw-r--r-- | project2/xml/sessionXml.h | 2 |
5 files changed, 9 insertions, 13 deletions
diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp index 877f9a6..1c52135 100644 --- a/project2/cgi/cgiAppEngine.cpp +++ b/project2/cgi/cgiAppEngine.cpp @@ -32,8 +32,7 @@ CgiApplicationEngine::CgiApplicationEngine(const CgiEnvironment * e, std::ostrea sessionsContainer(LoaderBase::getLoader<SessionContainerLoader, NotSupported>(e->sessionModule)->open()), IO(io) { - UUID sessID = getSessionID(e->getCookieList()); - cursession = sessionsContainer->GetSession(sessID); + cursession = sessionsContainer->GetSession(getSessionID(e->getCookieList())); currentStage = NextStage(new InitialStage(e)); } diff --git a/project2/common/sessionContainer.cpp b/project2/common/sessionContainer.cpp index 87c5729..1acd6d0 100644 --- a/project2/common/sessionContainer.cpp +++ b/project2/common/sessionContainer.cpp @@ -11,7 +11,7 @@ SessionContainer::~SessionContainer() } SessionPtr -SessionContainer::GetSession(UUID & id) const +SessionContainer::GetSession(const UUID & id) const { SessionPtr s = getSession(id); s->ExpiryTime(time(NULL) + Environment::getCurrent()->sessionTimeOut); diff --git a/project2/common/sessionContainer.h b/project2/common/sessionContainer.h index 9f1851a..ffbc5ed 100644 --- a/project2/common/sessionContainer.h +++ b/project2/common/sessionContainer.h @@ -10,11 +10,11 @@ class SessionContainer : public IntrusivePtrBase { SessionContainer(); virtual ~SessionContainer() = 0; - SessionPtr GetSession(UUID & sid) const; + SessionPtr GetSession(const UUID & sid) const; virtual void SaveSession(SessionPtr sess) const = 0; protected: - virtual SessionPtr getSession(UUID & sid) const = 0; + virtual SessionPtr getSession(const UUID & sid) const = 0; }; typedef boost::intrusive_ptr<SessionContainer> SessionContainerPtr; diff --git a/project2/xml/sessionXml.cpp b/project2/xml/sessionXml.cpp index b363f65..fc77de2 100644 --- a/project2/xml/sessionXml.cpp +++ b/project2/xml/sessionXml.cpp @@ -13,7 +13,7 @@ /// Session implementation that stores its contents in an XML file on the local filesystem class SessionXml : public Session { public: - SessionXml(UUID & sid); + SessionXml(const UUID & sid); SessionXml(const xmlpp::Element *); virtual ~SessionXml(); @@ -99,7 +99,7 @@ SessionContainerXml::SaveSession(SessionPtr currentSession) const } SessionPtr -SessionContainerXml::getSession(UUID & sid) const +SessionContainerXml::getSession(const UUID & sid) const { try { xmlpp::DomParser sessions(xmlFile); @@ -110,16 +110,13 @@ SessionContainerXml::getSession(UUID & sid) const if (sess.size() == 1) { return new SessionXml(dynamic_cast<const xmlpp::Element *>(sess[0])); } - else { - return new SessionXml(sid); - } } catch (...) { - return new SessionXml(sid); } + return new SessionXml(UUID::generate_random()); } -SessionXml::SessionXml(UUID & sid) : +SessionXml::SessionXml(const UUID & sid) : Session(sid) { } diff --git a/project2/xml/sessionXml.h b/project2/xml/sessionXml.h index 96cd1d2..8ba6ae2 100644 --- a/project2/xml/sessionXml.h +++ b/project2/xml/sessionXml.h @@ -12,7 +12,7 @@ class SessionContainerXml : public SessionContainer { void SaveSession(SessionPtr) const; protected: - SessionPtr getSession(UUID & sid) const; + SessionPtr getSession(const UUID & sid) const; private: // Configurables |