Revision: 40810
http://brlcad.svn.sourceforge.net/brlcad/?rev=40810&view=rev
Author: davidloman
Date: 2010-09-29 13:32:56 +0000 (Wed, 29 Sep 2010)
Log Message:
-----------
Put in Session creation/caching logic
Modified Paths:
--------------
rt^3/trunk/src/GS/SessionManager.cxx
rt^3/trunk/src/GS/SessionManager.h
Modified: rt^3/trunk/src/GS/SessionManager.cxx
===================================================================
--- rt^3/trunk/src/GS/SessionManager.cxx 2010-09-29 13:30:18 UTC (rev
40809)
+++ rt^3/trunk/src/GS/SessionManager.cxx 2010-09-29 13:32:56 UTC (rev
40810)
@@ -35,7 +35,8 @@
SessionManager::SessionManager()
{
- this->sessionIdMap = new QMap<quint32, Session*> ();
+ this->sessionIdMap = new QMap<QUuid, Session*> ();
+ this->accountIdMap = new QMap<quint32, Session*> ();
this->log = Logger::getInstance();
}
@@ -55,10 +56,26 @@
Session*
SessionManager::newSession(Account* a)
{
- Session* s = new Session(a);
+ Session* s = NULL;
+ //check to see if its already cached.
+ this->mapsLock.lock();
+ s = this->accountIdMap->value(a->getID());
+ this->mapsLock.unlock();
+ if (s != 0) {
+ s->stampLastAccess();
+ } else {
+ //New
+ s = new Session(a);
+ //cache
+ this->mapsLock.lock();
+ this->sessionIdMap->insert(s->getSessionID(),s);
+ this->accountIdMap->insert(s->getAccount()->getID(),s);
+ this->mapsLock.unlock();
+
+ }
return s;
}
@@ -68,6 +85,7 @@
quint16 type = msg->getMsgType();
switch(type) {
case NEWSESSIONREQ:
+ this->handleNewSessionReqMsg((NewSessionReqMsg*)msg);
break;
case SESSIONINFO:
//Dunno why someone would be sending the GS this message!
@@ -87,26 +105,36 @@
QString uname = msg->getUName();
QString passwd = msg->getPasswd();
+ //validate incoming data
if (origin == 0) {
- //How to handle??
+ //TODO Figure out how to how to handle NULL Portal
+ log->logERROR("SessionManager", "NULL Portal!");
+ return;
+ }
+ if (uname.length() <=0 || passwd.length() <= 0) {
+ log->logINFO("SessionManager", "Auth FAILED. Zero len uname or
passwd.");
+ GenericOneByteMsg* fail = new GenericOneByteMsg(FAILURE,
ACCOUNT_VALIDATION_FAIL);
+ origin->send(fail);
return;
}
-
+ //try to validate creds
Account* a = AccountManager::getInstance()->login(msg->getUName(),
msg->getPasswd(), msg->getOrigin());
if (a == 0) {
//Account validation failed
GenericOneByteMsg* fail = new GenericOneByteMsg(FAILURE,
ACCOUNT_VALIDATION_FAIL);
-
-
+ origin->send(fail);
+ return;
}
Session* s = this->newSession(a);
+ //Cache
+
}
Modified: rt^3/trunk/src/GS/SessionManager.h
===================================================================
--- rt^3/trunk/src/GS/SessionManager.h 2010-09-29 13:30:18 UTC (rev 40809)
+++ rt^3/trunk/src/GS/SessionManager.h 2010-09-29 13:32:56 UTC (rev 40810)
@@ -48,10 +48,8 @@
Logger* log;
- QMutex sesIDMapLock;
+ QMutex mapsLock;
QMap<QUuid, Session*>* sessionIdMap;
-
- QMutex accountIDMapLock;
QMap<quint32, Session*>* accountIdMap;
void handleNewSessionReqMsg(NewSessionReqMsg* msg);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits