summaryrefslogtreecommitdiff
path: root/server/src/server.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/server.cc')
-rw-r--r--server/src/server.cc20
1 files changed, 14 insertions, 6 deletions
diff --git a/server/src/server.cc b/server/src/server.cc
index 24d1eb1..4a17954 100644
--- a/server/src/server.cc
+++ b/server/src/server.cc
@@ -78,7 +78,8 @@ public:
static std::string handleTransaction(Transaction *transaction,
TCPSocket *pentominos_socket,
- Database *db)
+ Database *db,
+ JournalWriter &journalwriter)
{
std::string answer;
answer += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
@@ -98,7 +99,7 @@ static std::string handleTransaction(Transaction *transaction,
Macro *macro = mp.getMacro();
std::string resume = resume_parser(macro->resume, commit);
- commit.fields["journal.resume"] = resume;
+ commit.fields["journal.resume"] = resume;
db->commitTransaction(transaction->user, transaction->cpr, *macro, commit.fields);
@@ -108,9 +109,12 @@ static std::string handleTransaction(Transaction *transaction,
// macro->resume.attributes["store_in_journal"] == "true";
if(resume != "" && store_in_journal) {
+ journalwriter.addEntry(*transaction, commit, resume);
+ /*
journal_commit(transaction->cpr.c_str(), transaction->user.c_str(),
Conf::journal_commit_addr.c_str(), Conf::journal_commit_port,
resume.c_str(), resume.length());
+ */
}
i++;
@@ -170,7 +174,8 @@ static std::string handleTransaction(Transaction *transaction,
}
if(macro.attributes["name"] == request.macro ||
- (macro.attributes.find("static") != macro.attributes.end() && macro.attributes["static"] == "true")
+ (macro.attributes.find("static") != macro.attributes.end() &&
+ macro.attributes["static"] == "true")
) {
foundmacro = true;
@@ -274,6 +279,8 @@ static void handleConnection(TCPSocket *socket)
Database *db = new Database("pgsql", Conf::database_addr, "", Conf::database_user, Conf::database_passwd, "");
+ JournalWriter journalwriter(Conf::journal_commit_addr.c_str(), Conf::journal_commit_port);
+
ssize_t size;
char buf[4096];
@@ -299,7 +306,7 @@ static void handleConnection(TCPSocket *socket)
if(parser->parse(buf, size)) {
PRACRO_DEBUG(server, "Got complete XML document %d bytes used, %d bytes in current buffer.\n", parser->usedBytes(), size);
- socket->write(handleTransaction(transaction, &pentominos_socket, db));
+ socket->write(handleTransaction(transaction, &pentominos_socket, db, journalwriter));
size = size - parser->usedBytes();
delete transaction; transaction = NULL;
@@ -325,6 +332,8 @@ static void handleConnection(TCPSocket *socket)
parser = NULL;
}
+ journalwriter.commit();
+
PRACRO_DEBUG(server, "Out of read loop!\n");
}
@@ -340,8 +349,7 @@ void server()
socket = new TCPSocket("Listen socket");
socket->listen(port);
} catch (Exception &e) {
- PRACRO_ERR_LOG(server, "Error during parsing:\n%s\n",
- e.what());
+ PRACRO_ERR_LOG(server, "Error in listen:\n%s\n", e.what());
delete socket;
socket = NULL;
return;