From bf02f064b7f83f39d1ed92b321204c455f11d0fb Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 3 Dec 2009 06:58:44 +0000 Subject: Some fixes on the session system. --- server/src/server.cc | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'server/src') diff --git a/server/src/server.cc b/server/src/server.cc index b9b3743..0b2f6d6 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -79,6 +79,9 @@ static std::string error_box(std::string message) std::string errorbox = "\n" "\n" +#if 0 + " " + message + "\n" +#else " \n" +#endif "\n"; return errorbox; } @@ -175,7 +179,7 @@ static std::string handleRequest(Transaction *transaction, macro.attributes["name"], time(NULL)-Conf::db_max_ttl); - answer += " mutex.lock(); + sid_ok = conn->sessions.find(sessionid) != conn->sessions.end(); + conn->mutex.unlock(); + } + PRACRO_DEBUG(httpd, "SessionID: %llu\n", sessionid); const char *session_commit = MHD_lookup_connection_value(con, MHD_HEADER_KIND, "SessionCommit"); if(session_commit) { - printf("COMMIT: sessionid %llu\n", sessionid); + PRACRO_DEBUG(httpd, "COMMIT: sessionid %llu\n", sessionid); commitsession = true; } - std::string reply = handleConnection(data, *data_size, conn, sessionid, commitsession); + std::string reply; + if(sid_ok) { + reply = handleConnection(data, *data_size, conn, sessionid, commitsession); + } else { + PRACRO_ERR(httpd, "No such sessionid %llu\n", sessionid); + reply = error_box("No such session ID!"); + } struct MHD_Response *rsp; rsp = MHD_create_response_from_data(reply.length(), (char*)reply.c_str(), MHD_NO, MHD_YES); -- cgit v1.2.3