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.cc23
1 files changed, 8 insertions, 15 deletions
diff --git a/server/src/server.cc b/server/src/server.cc
index f2be8a4..9c653f8 100644
--- a/server/src/server.cc
+++ b/server/src/server.cc
@@ -46,7 +46,6 @@
#include "queryhandlerpracro.h"
#include "queryhandlerpentominos.h"
-#include "queryparser.h"
#include "luaquerymapper.h"
#include "database.h"
#include "widgetgenerator.h"
@@ -116,7 +115,6 @@ static std::string handleCommits(Transaction *transaction, Database &db,
static std::string handleRequest(Transaction *transaction,
- TCPSocket &pentominos_socket,
Database &db,
JournalWriter &journalwriter,
MacroList &macrolist,
@@ -124,6 +122,9 @@ static std::string handleRequest(Transaction *transaction,
{
std::string answer;
+ // Reuse connection throughout entire template.
+ QueryHandlerPentominos qh(transaction->cpr);
+
Requests::iterator i = transaction->requests.begin();
while(i != transaction->requests.end()) {
Request &request = *i;
@@ -186,7 +187,7 @@ static std::string handleRequest(Transaction *transaction,
LUAQueryMapper lqm;
- ////////////////////////
+ ////////////////////////
std::vector< Query >::iterator qi = m->queries.begin();
while(qi != m->queries.end()) {
@@ -195,14 +196,12 @@ static std::string handleRequest(Transaction *transaction,
if(service == "pentominos") {
// Send the queries to Pentominos (if any)
- QueryHandlerPentominos qh(pentominos_socket, transaction->cpr);
-
QueryResult queryresult = qh.exec(*qi);
lqm.addQueryResult(queryresult);
}
if(service == "pracro") {
- // Send the queries to Pentominos (if any)
+ // Send the queries to Pracro (if any)
QueryHandlerPracro qh(db, transaction->cpr);
QueryResult queryresult = qh.exec(*qi);
@@ -261,7 +260,6 @@ static std::string handleRequest(Transaction *transaction,
}
static std::string handleTransaction(Transaction *transaction,
- TCPSocket &pentominos_socket,
Database &db,
JournalWriter &journalwriter,
MacroList &macrolist,
@@ -279,7 +277,7 @@ static std::string handleTransaction(Transaction *transaction,
}
try {
- answer += handleRequest(transaction, pentominos_socket, db, journalwriter,
+ answer += handleRequest(transaction, db, journalwriter,
macrolist, templatelist);
} catch( std::exception &e ) {
PRACRO_ERR(server, "Request error: %s\n", e.what());
@@ -296,11 +294,6 @@ static std::string handleTransaction(Transaction *transaction,
static void handleConnection(TCPSocket *socket)
{
- TCPSocket pentominos_socket;
-#ifndef WITHOUT_PENTOMINOS
- pentominos_socket.connect(Conf::pentominos_addr, Conf::pentominos_port);
-#endif/*WITHOUT_PENTOMINOS*/
-
Database db(Conf::database_backend, Conf::database_addr, "", Conf::database_user, Conf::database_passwd, "");
JournalWriter journalwriter(Conf::journal_commit_addr.c_str(), Conf::journal_commit_port);
@@ -333,8 +326,8 @@ 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, journalwriter, macrolist, templatelist));
+ socket->write(handleTransaction(transaction, db, journalwriter,
+ macrolist, templatelist));
size = size - parser->usedBytes();
if(size) {
strcpy(buf, buf + parser->usedBytes());