summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/session.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/server/src/session.cc b/server/src/session.cc
index 477fb19..ea4d11c 100644
--- a/server/src/session.cc
+++ b/server/src/session.cc
@@ -55,6 +55,8 @@ Session::Session(Environment *e,
patientid = pid;
templ = t;
+ mutex.name = "session-" + sid;
+
DEBUG(session, "[%p] new Session(sessionid: '%s', patientid: '%s',"
" template: '%s')\n", this, sid.c_str(), pid.c_str(), t.c_str());
@@ -312,6 +314,7 @@ void Sessions::store()
Session *session = NULL;
std::string sessionid;
do {
+ bool waitcont = false;
session = NULL;
{
MutexAutolock lock(mutex);
@@ -319,10 +322,19 @@ void Sessions::store()
if(head != sessions.end()) {
session = head->second;
sessionid = head->first;
- if(session->trylock()) sessions.erase(sessionid);
- else continue;
+ if(session->trylock()) {
+ sessions.erase(sessionid);
+ } else {
+ waitcont = true;
+ }
}
}
+
+ if(waitcont) {
+ usleep(200000); // sleep 200ms
+ continue;
+ }
+
if(session != NULL) {
SessionSerialiser ser(env, Conf::session_path);
ser.save(session);