diff options
author | deva <deva> | 2011-03-28 07:52:12 +0000 |
---|---|---|
committer | deva <deva> | 2011-03-28 07:52:12 +0000 |
commit | ee1acb551b20a62be9bbb4de84d5a9f57f83908a (patch) | |
tree | 9a4a6499df2518c3425da7e3af71c12ec00562b1 /server/src/session.cc | |
parent | 93de7f375842c0afb72db8796c45bfda5f1a6f13 (diff) |
Split up journal commits on multiple users.
Diffstat (limited to 'server/src/session.cc')
-rw-r--r-- | server/src/session.cc | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/server/src/session.cc b/server/src/session.cc index 6850e9b..31c9fe8 100644 --- a/server/src/session.cc +++ b/server/src/session.cc @@ -93,7 +93,6 @@ void Session::commitMacro(Transaction &transaction, Commit &commit, isreadonly = false; } - bool Session::idle() { if(isreadonly) return false; @@ -402,6 +401,39 @@ Session *s7 = env.sessions.newSession(PID, TMPL); TEST_NOTEQUAL(s7, NULL, "We did get one right?"); TEST_EQUAL_STR(s7->id(), id, "Did we get the stored session?"); +// Get an existing session and test locking. +Session *s8 = env.sessions.session(s7->id()); +s7->lock(); +TEST_FALSE(s8->mutex.trylock(), "Session should be locked.") +s7->unlock(); + +{ + Transaction transaction; + transaction.cpr = PID; + transaction.user = "me"; + + Commit commit; + commit.fields["field1"] = "hello"; + commit.fields["field2"] = "world"; + commit.templ = TMPL; + + Macro macro; + macro.attributes["version"] = "1.0"; + macro.attributes["name"] = "somemacro"; + + s7->commitMacro(transaction, commit, macro); +} +TEST_FALSE(s7->idle(), "Session is active."); +TEST_FALSE(s7->isReadonly(), "Not read only session."); +s7->setIdle(true); // Force idle +TEST_TRUE(s7->idle(), "Session is idle."); + +Session *s9 = env.sessions.newSession(PID, TMPL"empty"); +TEST_TRUE(s9->isReadonly(), "Read only session."); +TEST_FALSE(s9->idle(), "Readonly session is not idle."); +s9->setIdle(true); // Force idle (no effect) +TEST_FALSE(s9->idle(), "Readonly session still not idle."); + TEST_END; #endif/*TEST_SESSION*/ |