summaryrefslogtreecommitdiff
path: root/server/src/transactionhandler.cc
diff options
context:
space:
mode:
authordeva <deva>2010-06-10 07:03:06 +0000
committerdeva <deva>2010-06-10 07:03:06 +0000
commit198b0d886817f2c5bc97cfd11857d4b314dffae3 (patch)
tree4fc2d51de46ab69b9e67149abf0ab6a332032f27 /server/src/transactionhandler.cc
parent730eb796bbce6f124be9194f1565b7dda1daddf1 (diff)
Add transaction support on database pr. pracro session. Makes it possible to discard all edited macros.
Diffstat (limited to 'server/src/transactionhandler.cc')
-rw-r--r--server/src/transactionhandler.cc31
1 files changed, 24 insertions, 7 deletions
diff --git a/server/src/transactionhandler.cc b/server/src/transactionhandler.cc
index c9c58b6..1658713 100644
--- a/server/src/transactionhandler.cc
+++ b/server/src/transactionhandler.cc
@@ -54,8 +54,9 @@ static std::string handleCommits(Transaction &transaction, Environment &env,
std::string answer;
if(transaction.commits.size() > 0) {
- AutoBorrower<Database*> borrower(env.dbpool);
- Database *db = borrower.get();
+ // AutoBorrower<Database*> borrower(env.dbpool);
+ // Database *db = borrower.get();
+ Database *db = session.database();
Commits::iterator i = transaction.commits.begin();
while(i != transaction.commits.end()) {
@@ -93,8 +94,9 @@ static std::string handleRequest(Transaction &transaction, Environment &env,
if(transaction.requests.size() > 0) {
- AutoBorrower<Database*> borrower(env.dbpool);
- Database *db = borrower.get();
+ // AutoBorrower<Database*> borrower(env.dbpool);
+ // Database *db = borrower.get();
+ Database *db = session.database();
Requests::iterator i = transaction.requests.begin();
while(i != transaction.requests.end()) {
@@ -218,10 +220,25 @@ static std::string handleRequest(Transaction &transaction, Environment &env,
}
if(completed) {
- answer += " <resume>";
- answer += xml_encode(db->getResume(transaction.cpr,
+ std::string jresume =
+ session.journal()->getEntry(macro.attributes["name"]);
+
+ std::string state = "old";
+ std::string resume = db->getResume(transaction.cpr,
macro,
- time(NULL) - Conf::db_max_ttl));
+ time(NULL) - Conf::db_max_ttl);
+
+ if(resume == jresume) state = "new";
+
+ if(jresume != "" && resume != jresume) {
+ state = "dirty";
+ session.journal()->removeEntry(macro.attributes["name"]);
+ }
+
+ if(jresume == "" && resume != jresume) state = "old";
+
+ answer += " <resume state=\""+state+"\">";
+ answer += xml_encode(resume);
answer += "</resume>\n";
}