diff options
Diffstat (limited to 'server/src/connection.cc')
-rw-r--r-- | server/src/connection.cc | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/server/src/connection.cc b/server/src/connection.cc index 849a90c..dd76f97 100644 --- a/server/src/connection.cc +++ b/server/src/connection.cc @@ -44,7 +44,7 @@ static std::string error_box(std::string message) static bool did_commit = false; #endif -Connection::Connection(Environment &e, std::string sid, bool c, bool d) +Connection::Connection(Environment &e, std::string sid, bool c, bool d, bool nc) : env(e), parser(&transaction) { DEBUG(connection, "[%p] CREATE\n", this); @@ -52,6 +52,7 @@ Connection::Connection(Environment &e, std::string sid, bool c, bool d) sessionid = sid; docommit = c; dodiscard = d; + donocommit = nc; #ifdef TEST_CONNECTION did_commit = false; @@ -65,11 +66,20 @@ Connection::~Connection() DEBUG(connection, "[%p] DESTROY\n", this); } +void Connection::nocommit(Session *session) +{ + if(donocommit) { + donocommit = false; + session->nocommit(); + } +} + void Connection::commit(Session *session) { if(docommit) { + std::string sid = session->id(); session->commit(); - env.sessions.deleteSession(session->id()); + env.sessions.deleteSession(sid); sessionid = ""; docommit = false; #ifdef TEST_CONNECTION @@ -81,8 +91,9 @@ void Connection::commit(Session *session) void Connection::discard(Session *session) { if(dodiscard) { + std::string sid = session->id(); session->discard(); - env.sessions.deleteSession(session->id()); + env.sessions.deleteSession(sid); sessionid = ""; dodiscard = false; } @@ -116,6 +127,7 @@ bool Connection::handle(const char *data, size_t size) parser_complete = true; commit(session); discard(session); + nocommit(session); return true; } @@ -129,6 +141,7 @@ bool Connection::handle(const char *data, size_t size) commit(session); discard(session); + nocommit(session); return true; } |