summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/admin_connection.cc14
-rw-r--r--server/src/session.cc20
-rw-r--r--server/src/session.h12
3 files changed, 32 insertions, 14 deletions
diff --git a/server/src/admin_connection.cc b/server/src/admin_connection.cc
index f761023..1522627 100644
--- a/server/src/admin_connection.cc
+++ b/server/src/admin_connection.cc
@@ -59,17 +59,11 @@ static std::string admin_listactivesessions(Environment &env)
{
std::string str;
- std::vector<std::string> act = env.sessions.activeSessions();
- std::vector<std::string>::iterator i = act.begin();
+ std::vector<Sessions::SessionInfo> act = env.sessions.activeSessions();
+ std::vector<Sessions::SessionInfo>::iterator i = act.begin();
while(i != act.end()) {
- // NOTE: Returned session is returned in locked state!
- Session *s = NULL;
- SessionAutounlock l(&s);
- s = env.sessions.lockedSession(*i);
- if(s) {
- str += "Session " + *i + ": "+s->templ+" on "+s->patientid+" "+
- std::string(s->idle()?"[idle]":"[active]")+"\n";
- }
+ str += "Session " + i->id + ": "+i->templ+" on "+i->patientid+" "+
+ std::string(i->idle?"[idle]":"[active]")+"\n";
i++;
}
diff --git a/server/src/session.cc b/server/src/session.cc
index 6bb4440..57499f9 100644
--- a/server/src/session.cc
+++ b/server/src/session.cc
@@ -346,15 +346,29 @@ void Sessions::store()
*/
}
-std::vector<std::string> Sessions::activeSessions()
+std::vector<Sessions::SessionInfo> Sessions::activeSessions()
{
MutexAutolock lock(mutex);
- std::vector<std::string> act;
+ std::vector<SessionInfo> act;
std::map<std::string, Session*>::iterator i = sessions.begin();
while(i != sessions.end()) {
- act.push_back(i->first);
+ Session *s = i->second;
+ SessionInfo si;
+ si.id = i->first;
+ si.templ = "LOCKED"
+
+ if(s->trylock()) {
+ // si.user = "simpson";
+ // si.course = s->course;
+ si.patientid = s->patientid;
+ si.templ = s->templ;
+ si.idle = s->idle();
+ // si.ondisc = false;
+ s->unlock();
+ }
+ act.push_back(si);
i++;
}
diff --git a/server/src/session.h b/server/src/session.h
index 9ad84b5..1cb3041 100644
--- a/server/src/session.h
+++ b/server/src/session.h
@@ -132,7 +132,17 @@ public:
//
// Admin methods
//
- std::vector<std::string> activeSessions();
+ class SessionInfo {
+ public:
+ std::string id;
+ std::string patientid;
+ std::string user;
+ std::string course;
+ std::string templ;
+ bool idle;
+ bool ondisc;
+ };
+ std::vector<SessionInfo> activeSessions();
private:
std::map<std::string, Session *> sessions;