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.cc27
1 files changed, 6 insertions, 21 deletions
diff --git a/server/src/server.cc b/server/src/server.cc
index e4a470e..64ee709 100644
--- a/server/src/server.cc
+++ b/server/src/server.cc
@@ -173,21 +173,9 @@ static std::string handleTransaction(Transaction &transaction)
s.connect(Conf::pentominos_addr, Conf::pentominos_port);
#endif/*WITHOUT_PENTOMINOS*/
QueryHandler qh(&s, transaction.cpr);
- ///////////////////////////////
-
- qh.addQuery(*qi);
-
- std::string result = qh.exec();
- printf("Got result: [%s]\n", result.c_str());
- /////////////////////////
- /////////////////////////
- // Parse the result from the queries to pentominos
- QueryParser qp(result);
- qp.parse();
- // Map the results
- lqm.addQueryResult(qp.result);
- ////////////////////////
+ QueryResult queryresult = qh.exec(*qi);
+ lqm.addQueryResult(queryresult);
qi++;
}
@@ -269,17 +257,11 @@ static void handleConnection(TCPSocket *socket)
}
printf("Got %d bytes in read loop\n", size);
- size = 0;
- if(parser->parse(buf)) {
+ if(parser->parse(buf, size)) {
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
"!! Got complete XML document %d bytes used, %d bytes in current buffer.\n"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", parser->usedBytes(), strlen(buf));
- if(parser->usedBytes() < strlen(buf)) {
- size = strlen(buf) - parser->usedBytes();
- strcpy(buf, buf + parser->usedBytes());
- }
-
socket->write(handleTransaction(*transaction));
delete transaction;
@@ -288,6 +270,9 @@ static void handleConnection(TCPSocket *socket)
delete parser;
parser = NULL;
}
+
+ size = size - parser->usedBytes();
+ if(size) memcpy(buf, buf + parser->usedBytes(), size);
}
memset(buf, 0, bufsize);
}