X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=server%2Fcontrol.c;h=f81ea00b9c79cc171896e58caa6aa996527e724c;hb=0654fb285c91da103314610cd4f27295e3da38f3;hp=59f9b73180c84b03e9164ef9f3bf2875dd3cb44c;hpb=5b98dd1c37a6151e734e8fa3a7054248ae3455c6;p=matches%2FMCTX3420.git diff --git a/server/control.c b/server/control.c index 59f9b73..f81ea00 100644 --- a/server/control.c +++ b/server/control.c @@ -14,7 +14,7 @@ typedef struct ControlData { ControlModes current_mode; pthread_mutex_t mutex; - struct timeval start_time; + struct timespec start_time; char user_name[31]; // The user who owns the currently running experiment char experiment_dir[BUFSIZ]; //Directory for experiment char experiment_name[BUFSIZ]; @@ -134,7 +134,7 @@ void Control_Handler(FCGIContext *context, char *params) { return; } - if (strcmp(g_controls.user_name, context->user_name) != 0) + if ((*g_controls.user_name) != '\0' && strcmp(g_controls.user_name, context->user_name) != 0) { if (context->user_type != USER_ADMIN) { FCGI_RejectJSON(context, "Another user has an experiment in progress."); @@ -197,7 +197,7 @@ void Control_Handler(FCGIContext *context, char *params) { "%s", name); } - FCGI_AcceptJSON(context, "Ok", NULL); + FCGI_AcceptJSON(context, "Ok"); } } @@ -225,7 +225,7 @@ const char* Control_SetMode(ControlModes desired_mode, void * arg) path, strerror(errno)); ret = "Couldn't create experiment directory."; } else { - gettimeofday(&(g_controls.start_time), NULL); + clock_gettime(CLOCK_MONOTONIC, &(g_controls.start_time)); } } else ret = "Cannot start when not in a stopped state."; @@ -280,6 +280,6 @@ const char * Control_GetModeName() { * Gets the start time for the current experiment * @return the start time */ -const struct timeval* Control_GetStartTime() { +const struct timespec * Control_GetStartTime() { return &g_controls.start_time; }