From: Gonzalo A. <ga...@us...> - 2006-09-12 20:01:55
|
Update of /cvsroot/mod-c/ehtml/samples In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv6605/samples Modified Files: 02session.cpp Log Message: * Session automatic restore/save/release is shifted from 02session.cpp to EHTMLApplication. Index: 02session.cpp =================================================================== RCS file: /cvsroot/mod-c/ehtml/samples/02session.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** 02session.cpp 12 Sep 2006 15:28:15 -0000 1.3 --- 02session.cpp 12 Sep 2006 20:01:49 -0000 1.4 *************** *** 17,22 **** class SessionEHTMLApp: public EHTMLApplication { - SessionDriver* driver; - Session* session; size_t cnt; --- 17,20 ---- *************** *** 30,34 **** SessionEHTMLApp(request_context* req): EHTMLApplication(req), ! session(NULL), cnt(0), lblSessionDriver("No session driver. Use EHTMLSessionType."), lblCount("count = no session"){ ; } --- 28,32 ---- SessionEHTMLApp(request_context* req): EHTMLApplication(req), ! cnt(0), lblSessionDriver("No session driver. Use EHTMLSessionType."), lblCount("count = no session"){ ; } *************** *** 45,75 **** } ! driver = SessionDriver::Selected(); if (driver == NULL) return 0; - if (!driver->Connect()) { - ap_log_error(APLOG_MARK, LOG_ERR, 0, - Request->GetRequestContext()->r->server, - "Error connecting to session server: %s", - strerror(errno)); - lblSessionDriver.SetText("Error connecting to session store."); - lblCount.SetText(strerror(errno)); - return 0; - } - lblSessionDriver.SetText("Session driver = " + driver->name()); ! session = driver->Get(); ! ! if (session == NULL) { ! SessionIDDriver* iddriver = SessionIDDriver::Selected(); ! if (iddriver != NULL) { ! SessionID id = iddriver->GenerateID(); ! session = new Session(id); ! } else { ! lblCount.SetText("no session ID driver. Use EHTMLSessionIDType."); ! } ! } if (session != NULL) { --- 43,53 ---- } ! SessionDriver* driver = SessionDriver::Selected(); if (driver == NULL) return 0; lblSessionDriver.SetText("Session driver = " + driver->name()); ! Session* session = GetSession(); if (session != NULL) { *************** *** 86,93 **** } lblCount.SetText("count = " + (*session)[COUNT]); - Debug("Got session id=%s\n", session->ID().hex().c_str()); - GetResponse()->SetCookie(Session::SessionIDName(), - session->ID().hex()); } --- 64,69 ---- } lblCount.SetText("count = " + (*session)[COUNT]); + Debug("Got session id=%s\n", session->ID().hex().c_str()); } *************** *** 95,120 **** } - virtual int DoFinishStage() { - 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)); - } - } - return EHTMLApplication::DoFinishStage(); - } }; --- 71,74 ---- |