From 08e2a09ca51afc87c40f4fac0c92b8a94e353b53 Mon Sep 17 00:00:00 2001 From: deva Date: Wed, 29 Jul 2009 15:00:46 +0000 Subject: Fixed potetially bad error in the server. It would break the stream if introduced to multiple xml-documents after one another. --- server/src/server.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/server/src/server.cc b/server/src/server.cc index af46119..8e5e938 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -294,7 +294,6 @@ static void handleConnection(TCPSocket *socket) JournalWriter journalwriter(Conf::journal_commit_addr.c_str(), Conf::journal_commit_port); MacroList macrolist(Conf::xml_basedir + "/macros"); - MacroList::iterator i = macrolist.begin(); while(i != macrolist.end()) { MacroListItem::iterator j = i->second.begin(); @@ -335,16 +334,16 @@ static void handleConnection(TCPSocket *socket) socket->write(handleTransaction(transaction, pentominos_socket, db, journalwriter, macrolist)); size = size - parser->usedBytes(); + if(size) { + strcpy(buf, buf + parser->usedBytes()); + PRACRO_DEBUG(server, "Replaying %d bytes.\n", size); + } delete transaction; transaction = NULL; delete parser; parser = NULL; } else { - size = size - parser->usedBytes(); - } - - if(size > 0) { - strcpy(buf, buf + size); - PRACRO_DEBUG(server, "Replaying %d bytes.\n", size); + size = 0; + memset(buf, 0, sizeof(buf)); } } } -- cgit v1.2.3