Update of /cvsroot/mod-c/ehtml/src
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv6605/src
Modified Files:
EHTMLApplication.cpp
Log Message:
* Session automatic restore/save/release is shifted from 02session.cpp to EHTMLApplication.
Index: EHTMLApplication.cpp
===================================================================
RCS file: /cvsroot/mod-c/ehtml/src/EHTMLApplication.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** EHTMLApplication.cpp 12 Sep 2006 15:23:33 -0000 1.10
--- EHTMLApplication.cpp 12 Sep 2006 20:01:49 -0000 1.11
***************
*** 31,34 ****
--- 31,39 ----
#include <http_log.h>
+ #include "Profiling.h"
+ #include "ehtml.h"
+
+ ProfileFunction* ProfileFunction::_head = NULL;
+
using namespace std;
***************
*** 45,48 ****
--- 50,54 ----
/* MainRequestContext = ReqContext;
MainAllocPool = ReqContext->r->pool;*/
+ driver = NULL;
}
***************
*** 92,98 ****
int EHTMLApplication::DoInitStage()
{
! SessionDriver* driver = SessionDriver::Selected();
! if (driver != NULL)
driver->Application(this);
OnInit.Trigger();
// @TODO: Restore the session...
--- 98,125 ----
int EHTMLApplication::DoInitStage()
{
! driver = SessionDriver::Selected();
! if (driver != NULL) {
driver->Application(this);
+ if (!driver->Connect())
+ Error("connecting to session server: %s", strerror(errno));
+
+ session = driver->Get();
+
+ if (session == NULL) {
+ SessionIDDriver* iddriver = SessionIDDriver::Selected();
+ if (iddriver != NULL) {
+ SessionID id = iddriver->GenerateID();
+ session = new Session(id);
+ } else {
+ Error("no session ID driver. Use EHTMLSessionIDType.");
+ }
+ }
+
+ if (session != NULL) {
+ if (!RequestContext->dir_config->cookieless)
+ GetResponse()->SetCookie(Session::SessionIDName(),
+ session->ID().hex());
+ }
+ }
OnInit.Trigger();
// @TODO: Restore the session...
***************
*** 133,136 ****
--- 160,183 ----
OnFinish.Trigger();
+ if (session && driver) {
+ Debug("Finish: session id=%s\n", session->ID().hex().c_str());
+ if (!driver->Save(session)) {
+ Error("Error saving session (hex=%s): %s",
+ session->ID().hex().c_str(), strerror(errno));
+ }
+
+ if (!driver->Release(session)) {
+ Error("Error releasing session (hex=%s): %s",
+ session->ID().hex().c_str(), strerror(errno));
+ }
+
+ //@todo TODO: MUST USE CONFIGURATION DIRECTIVE TO SEE WHICH ENCODING
+ //IS TO BE USED.
+ if (!driver->Disconnect()) {
+ Error("Error disconnecting to session server: %s",
+ strerror(errno));
+ }
+ }
+
// Shut down all open sessions
ShutSessionsDown();
|