summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2009-12-03 06:58:44 +0000
committerdeva <deva>2009-12-03 06:58:44 +0000
commitbf02f064b7f83f39d1ed92b321204c455f11d0fb (patch)
tree81a86d516743e92e3f8422180089103d7c5a7b26
parent1f174930832202c09f7233a0bc8315f2546d8e20 (diff)
Some fixes on the session system.
-rw-r--r--server/src/server.cc31
1 files changed, 24 insertions, 7 deletions
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 =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<pracro version=\"1.0\">\n"
+#if 0
+ " <error>" + message + "</error>\n"
+#else
" <template name=\"error\">\n"
" <macro name=\"error\" static=\"true\">\n"
" <widgets caption=\"ERROR!\" layout=\"vbox\" name=\"error\">\n"
@@ -86,6 +89,7 @@ static std::string error_box(std::string message)
" </widgets>\n"
" </macro>\n"
" </template>\n"
+#endif
"</pracro>\n";
return errorbox;
}
@@ -175,7 +179,7 @@ static std::string handleRequest(Transaction *transaction,
macro.attributes["name"],
time(NULL)-Conf::db_max_ttl);
- answer += " <macro completed=";
+ answer += " <macro uid=\"42\" completed=";
if(completed) answer += "\"true\"";
else answer += "\"false\"";
@@ -390,19 +394,32 @@ static int handle_request(void *cls,
url, method, version, *data_size);
sessionid_t sessionid;
bool commitsession = false;
-
+ bool sid_ok = true;
+
const char *sessionids = MHD_lookup_connection_value(con, MHD_HEADER_KIND, "SessionID");
- if(sessionids == NULL) sessionid = newSessionID(conn);
- else sessionid = atoll(sessionids);
- printf("SessionID: %llu\n", sessionid);
+ if(sessionids == NULL) {
+ sessionid = newSessionID(conn);
+ } else {
+ sessionid = atoll(sessionids);
+ conn->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);