X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=server%2Ffastcgi.c;h=d7e057b6f5f19d9a65ded5276225a3543db56fbb;hb=e070906c87ee00c82b5c81c8aa905f3c20002047;hp=fd5839ed632f7139ab7a2b834dcbd6bf51f9e2e2;hpb=5b98dd1c37a6151e734e8fa3a7054248ae3455c6;p=matches%2FMCTX3420.git diff --git a/server/fastcgi.c b/server/fastcgi.c index fd5839e..d7e057b 100644 --- a/server/fastcgi.c +++ b/server/fastcgi.c @@ -50,9 +50,14 @@ static void IdentifyHandler(FCGIContext *context, char *params) { FCGI_BeginJSON(context, STATUS_OK); FCGI_JSONPair("description", "MCTX3420 Server API (2013)"); FCGI_JSONPair("build_date", __DATE__ " " __TIME__); + struct timespec t; + t.tv_sec = 0; t.tv_nsec = 0; + clock_getres(CLOCK_MONOTONIC, &t); + FCGI_JSONDouble("clock_getres", TIMEVAL_TO_DOUBLE(t)); FCGI_JSONLong("api_version", API_VERSION); FCGI_JSONBool("logged_in", has_control); FCGI_JSONPair("user_name", has_control ? context->user_name : ""); + //Sensor and actuator information if (ident_sensors) { @@ -328,8 +333,8 @@ void FCGI_BeginJSON(FCGIContext *context, StatusCodes status_code) printf("\t\"module\" : \"%s\"", context->current_module); FCGI_JSONLong("status", status_code); //Time and running statistics - struct timeval now; - gettimeofday(&now, NULL); + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); FCGI_JSONDouble("start_time", TIMEVAL_TO_DOUBLE(g_options.start_time)); FCGI_JSONDouble("current_time", TIMEVAL_TO_DOUBLE(now)); FCGI_JSONDouble("running_time", TIMEVAL_DIFF(now, g_options.start_time)); @@ -383,7 +388,7 @@ void FCGI_JSONLong(const char *key, long value) */ void FCGI_JSONDouble(const char *key, double value) { - printf(",\r\n\t\"%s\" : %f", key, value); + printf(",\r\n\t\"%s\" : %.9f", key, value); } /** @@ -515,8 +520,23 @@ void * FCGI_RequestLoop (void *data) snprintf(module, BUFSIZ, "%s", getenv("DOCUMENT_URI_LOCAL")); snprintf(params, BUFSIZ, "%s", getenv("QUERY_STRING")); + + //char cookies[BUFSIZ]; + //snprintf(cookies, BUFSIZ, "%s", getenv("COOKIE_STRING")); + //Log(LOGDEBUG, "ALL cookies %s", cookies); //mmmm + //Hack to get the nameless cookie only + // (works as long as browsers send the nameless cookie first...) snprintf(control_key, CONTROL_KEY_BUFSIZ, "%s", getenv("COOKIE_STRING")); + // Ignore any other cookies if the nameless cookie is empty + for (int i = 0; i < CONTROL_KEY_BUFSIZ; ++i) + { + if (control_key[i] == ';') + { + control_key[i] = '\0'; + break; + } + } Log(LOGDEBUG, "Got request #%d - Module %s, params %s", context.response_number, module, params); Log(LOGDEBUG, "Control key: %s", control_key); @@ -554,7 +574,7 @@ void * FCGI_RequestLoop (void *data) if (module_handler) { - if (module_handler != Login_Handler && module_handler != IdentifyHandler && module_handler) + if (g_options.auth_method != AUTH_NONE && module_handler != Login_Handler && module_handler != IdentifyHandler && module_handler) //if (false) // Testing { if (!FCGI_HasControl(&context, control_key))