summaryrefslogtreecommitdiff
path: root/server/src/server.cc
diff options
context:
space:
mode:
authordeva <deva>2008-09-23 08:10:37 +0000
committerdeva <deva>2008-09-23 08:10:37 +0000
commitefb0b27f5bc659a49e330fb7970a9b1b6ae0f398 (patch)
tree4872d87d301ea5d31c7b2e7f0435ec9318222086 /server/src/server.cc
parent587f685b6f7cbc63a8ee8dc8b3d5c590144db045 (diff)
Made fix for the 'multiple xml buffers in single network buffer' problem.
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);
}