From 2a89f766b3c4917001de03a06bfbecb1ce25675f Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 28 Nov 2011 15:03:17 +0100 Subject: Use one-thread-per-connection and fix up Session locking. --- server/src/client_connection.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'server/src/client_connection.cc') diff --git a/server/src/client_connection.cc b/server/src/client_connection.cc index fe55efc..075dc46 100644 --- a/server/src/client_connection.cc +++ b/server/src/client_connection.cc @@ -44,7 +44,7 @@ static std::string error_box(std::string message) static bool did_commit = false; #endif -ClientConnection::ClientConnection(Environment &e, headers_t &headers, +ClientConnection::ClientConnection(Environment &e, headers_t headers, headers_t args, std::string uri) : env(e), parser(&transaction) { @@ -154,17 +154,22 @@ bool ClientConnection::handle(const char *data, size_t size) } Session *session = NULL; + SessionAutounlock l(&session); + try { if(sessionid == "") { // Create new session - session = env.sessions.newSession(patientid, templ); + // NOTE: New session is returned in locked state! + session = env.sessions.newLockedSession(patientid, templ); } else { // Attach to old session - session = env.sessions.session(sessionid); + // NOTE: Returned session is returned in locked state! + session = env.sessions.lockedSession(sessionid); // Session didn't exist - create a new one anyway. if(session == NULL) { - session = env.sessions.newSession(patientid, templ); + // NOTE: New session is returned in locked state! + session = env.sessions.newLockedSession(patientid, templ); } } } catch(Sessions::SessionAlreadyActive &e) { @@ -201,7 +206,7 @@ bool ClientConnection::handle(const char *data, size_t size) parser_complete = true; { - SessionAutolock lock(*session); + //SessionAutolock lock(session); response = handleTransaction(request, transaction, env, *session); } -- cgit v1.2.3