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.cc36
1 files changed, 24 insertions, 12 deletions
diff --git a/server/src/server.cc b/server/src/server.cc
index ad7065e..688a310 100644
--- a/server/src/server.cc
+++ b/server/src/server.cc
@@ -262,21 +262,33 @@ static void handleConnection(TCPSocket *socket)
while((size = socket->read(buf, bufsize)) > 0) {
- if(transaction == NULL) {
- transaction = new Transaction();
- parser = new TransactionParser(transaction);
- }
+ while(size) {
+
+ if(transaction == NULL) {
+ transaction = new Transaction();
+ parser = new TransactionParser(transaction);
+ }
- printf("Got %d bytes in read loop\n", size);
- if(parser->parse(buf)) {
- printf("Got complete XML document\n");
- socket->write(handleTransaction(*transaction));
+ printf("Got %d bytes in read loop\n", size);
+ size = 0;
+ if(parser->parse(buf)) {
+ printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
+ "!! Got complete XML document %d bytes used, %d bytes in current buffer.\n"
+ "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", parser->usedBytes(), strlen(buf));
- delete transaction;
- transaction = NULL;
+ if(parser->usedBytes() < strlen(buf)) {
+ size = strlen(buf) - parser->usedBytes();
+ strcpy(buf, buf + parser->usedBytes());
+ }
- delete parser;
- parser = NULL;
+ socket->write(handleTransaction(*transaction));
+
+ delete transaction;
+ transaction = NULL;
+
+ delete parser;
+ parser = NULL;
+ }
}
memset(buf, 0, bufsize);
}