summaryrefslogtreecommitdiff
path: root/server/src/server.cc
diff options
context:
space:
mode:
authordeva <deva>2008-09-30 12:49:34 +0000
committerdeva <deva>2008-09-30 12:49:34 +0000
commite2120257dda4d91b48bb031a96edda810ce30dfb (patch)
treef83eadbbb6d84fd0d6fb7d7a4d3e342535854795 /server/src/server.cc
parenta01f655935558e0f71253907fd8e4c57b0d2f64c (diff)
Changed SAXParser parse method to take a buffer and a size instead of a c++ string. Made the queryhandler use a read loop, parsing on-the-fly to determine when the entire document has been read.
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);
}