From f49d29d2a4b9b7e5dd544915f9236ae08e0c1ddd Mon Sep 17 00:00:00 2001 From: deva Date: Wed, 30 Jul 2008 13:05:44 +0000 Subject: Fixed structural problem in server that prevented the potential request for a nonexisting macro (resulting in a course-only answer). --- server/src/server.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'server/src') diff --git a/server/src/server.cc b/server/src/server.cc index 65fd782..27a6b9d 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -78,7 +78,7 @@ static void connection(TCPSocket &socket) // // Handle commits // - if(transaction.commits.size() > 0) { + { Commits::iterator i = transaction.commits.begin(); while(i != transaction.commits.end()) { Commit &commit = *i; @@ -90,15 +90,15 @@ static void connection(TCPSocket &socket) db.commit(transaction.user, transaction.cpr, *macro, commit.fields); std::string resume = resume_parser(macro->attributes["resume"].c_str(), commit); - + journal_commit(transaction.cpr.c_str(), transaction.user.c_str(), Conf::journal_commit_addr.c_str(), Conf::journal_commit_port, resume.c_str(), resume.length()); - + i++; } } - + // // Handle requests // @@ -108,12 +108,9 @@ static void connection(TCPSocket &socket) std::string answer; - MacroParser mp(request.macro); - mp.parse(); - Macro *m = mp.getMacro(); - - printf("Handling request - macro: %s, course: %s\n", request.macro.c_str(), request.course.c_str()); - + printf("Handling request - macro: %s, course: %s\n", + request.macro.c_str(), request.course.c_str()); + // Read and parse the template file. TemplateParser tp(request.course); tp.parse(); @@ -170,6 +167,10 @@ static void connection(TCPSocket &socket) if(macro.attributes["name"] == request.macro) { + MacroParser mp(request.macro); + mp.parse(); + Macro *m = mp.getMacro(); + // Handle lua programs if(m->scripts.size()) { answer += " \n"; -- cgit v1.2.3