Commit 1e6f257d531798181156a5b874c2fdb5b59f91d9
Exists in
clean_real
:Merge branch 'clean_real' of https://gitlab.irap.omp.eu/CDPP/DDServer into clean_real
Showing
4 changed files
with
89 additions
and
55 deletions
Show diff stats
src/SERVER/DD_Access_sr.c
@@ -39,39 +39,48 @@ int * get_ticket_field_ids(int ncid, int n, char ** fields) { | @@ -39,39 +39,48 @@ int * get_ticket_field_ids(int ncid, int n, char ** fields) { | ||
39 | return a; | 39 | return a; |
40 | } | 40 | } |
41 | int GetTicket(int user_id, char * hostname, int DD_user_id) { | 41 | int GetTicket(int user_id, char * hostname, int DD_user_id) { |
42 | - //printf("GetTicket uid:%i, hostname:%s, ddid:%i\n", user_id, hostname, DD_user_id); | 42 | + printf("GetTicket uid:%i, hostname:%s, ddid:%i\n", user_id, hostname, DD_user_id); |
43 | time_t expiration_time; | 43 | time_t expiration_time; |
44 | time_t clock_value; | 44 | time_t clock_value; |
45 | int permission = NOPERMISSION; | 45 | int permission = NOPERMISSION; |
46 | + printf("NOPERMISSION value : %i\n", permission); | ||
46 | 47 | ||
47 | clock_value = time(NULL); | 48 | clock_value = time(NULL); |
48 | - // expiration_time= clock_value+16200; // 4.5 hours | 49 | + // expiration_time= clock_value+16200; // 4.5 hours |
49 | expiration_time = clock_value+172800; // 48 hours | 50 | expiration_time = clock_value+172800; // 48 hours |
51 | + expiration_time = clock_value + 16200; | ||
52 | + printf("Expiration time : %ld\n", expiration_time); | ||
50 | 53 | ||
51 | // selection query | 54 | // selection query |
52 | char * q = malloc(1024 * sizeof(char)); | 55 | char * q = malloc(1024 * sizeof(char)); |
53 | memset(q, 0, 1024); | 56 | memset(q, 0, 1024); |
54 | - sprintf(q, "SELECT ddid,hostname,time FROM user_ticket WHERE userid='%s' AND hostname='%s';", hostname); | 57 | + sprintf(q, "SELECT ddid,hostname,time FROM user_ticket WHERE userid=%i AND hostname='%s';",user_id, hostname); |
58 | + printf("GetTicket select : -%s-\n", q); | ||
55 | sqlite3 * db; | 59 | sqlite3 * db; |
56 | sqlite3_stmt * res; | 60 | sqlite3_stmt * res; |
57 | sqlite3_open("amda.db", &db); | 61 | sqlite3_open("amda.db", &db); |
58 | int rc; rc = sqlite3_prepare_v2(db, q, -1, &res, 0); | 62 | int rc; rc = sqlite3_prepare_v2(db, q, -1, &res, 0); |
59 | int step; step = sqlite3_step(res); | 63 | int step; step = sqlite3_step(res); |
60 | if(step != SQLITE_ROW) { | 64 | if(step != SQLITE_ROW) { |
65 | + printf("No user ticket row found\n"); | ||
61 | // create a new entry in the database | 66 | // create a new entry in the database |
62 | char * q = malloc(1024 * sizeof(char)); | 67 | char * q = malloc(1024 * sizeof(char)); |
63 | memset(q, 0, 1024); | 68 | memset(q, 0, 1024); |
69 | + printf("\tinsert user_id: %i, host: %s, time: %ld, ddid: %i\n", user_id, hostname, expiration_time, DD_user_id); | ||
64 | sprintf(q, "INSERT INTO user_ticket (userid,hostname,time,ddid) VALUES (%i,'%s',%i,%i);",user_id,hostname,expiration_time,DD_user_id); | 70 | sprintf(q, "INSERT INTO user_ticket (userid,hostname,time,ddid) VALUES (%i,'%s',%i,%i);",user_id,hostname,expiration_time,DD_user_id); |
65 | execute_query(q); | 71 | execute_query(q); |
66 | permission = 0; | 72 | permission = 0; |
67 | free(q); | 73 | free(q); |
68 | } | 74 | } |
69 | else { | 75 | else { |
76 | + printf("Row found\n"); | ||
70 | while(step == SQLITE_ROW) { | 77 | while(step == SQLITE_ROW) { |
71 | int time_tmp; time_tmp = sqlite3_column_int(res, 2); | 78 | int time_tmp; time_tmp = sqlite3_column_int(res, 2); |
72 | int ddid_tmp; ddid_tmp = sqlite3_column_int(res, 0); | 79 | int ddid_tmp; ddid_tmp = sqlite3_column_int(res, 0); |
80 | + printf("\ttime_tmp: %i, ddid_tmp: %i, DD_user_id: %i\n", time_tmp, ddid_tmp, DD_user_id); | ||
73 | if(ddid_tmp==DD_user_id) { | 81 | if(ddid_tmp==DD_user_id) { |
74 | - if(time_tmp<expiration_time) { | 82 | + printf("Expiration time : %ld, t_diff: %ld\n", expiration_time, time_tmp - expiration_time); |
83 | + if(clock_value<time_tmp) { | ||
75 | // update expiration time | 84 | // update expiration time |
76 | char * q = malloc(1024 * sizeof(char)); | 85 | char * q = malloc(1024 * sizeof(char)); |
77 | memset(q,0,1024); | 86 | memset(q,0,1024); |
@@ -79,6 +88,7 @@ int GetTicket(int user_id, char * hostname, int DD_user_id) { | @@ -79,6 +88,7 @@ int GetTicket(int user_id, char * hostname, int DD_user_id) { | ||
79 | execute_query(q); | 88 | execute_query(q); |
80 | free(q); | 89 | free(q); |
81 | } | 90 | } |
91 | + | ||
82 | permission = 0; | 92 | permission = 0; |
83 | break; | 93 | break; |
84 | } | 94 | } |
@@ -88,6 +98,7 @@ int GetTicket(int user_id, char * hostname, int DD_user_id) { | @@ -88,6 +98,7 @@ int GetTicket(int user_id, char * hostname, int DD_user_id) { | ||
88 | 98 | ||
89 | sqlite3_finalize(res); | 99 | sqlite3_finalize(res); |
90 | sqlite3_close(db); | 100 | sqlite3_close(db); |
101 | + printf("Permission val : %i\n", permission); | ||
91 | return permission; | 102 | return permission; |
92 | } | 103 | } |
93 | 104 | ||
@@ -160,7 +171,7 @@ int CheckTicket(char * username, char * ticket) { | @@ -160,7 +171,7 @@ int CheckTicket(char * username, char * ticket) { | ||
160 | * It IS DD_Check ! | 171 | * It IS DD_Check ! |
161 | */ | 172 | */ |
162 | int ShowTicket_old(int user_id, char *hostname, char * ddname) { | 173 | int ShowTicket_old(int user_id, char *hostname, char * ddname) { |
163 | - //printf("ShowTicket : user_id:%i, hostname:'%s', ddname:'%s'\n", user_id, hostname, ddname); | 174 | + printf("ShowTicket : user_id:%i, hostname:'%s', ddname:'%s'\n", user_id, hostname, ddname); |
164 | char * ddbase; | 175 | char * ddbase; |
165 | char refname[PATHLENGTH]; | 176 | char refname[PATHLENGTH]; |
166 | int ticket_id; /* Ticket file ID */ | 177 | int ticket_id; /* Ticket file ID */ |
@@ -241,7 +252,7 @@ int ShowTicket_old(int user_id, char *hostname, char * ddname) { | @@ -241,7 +252,7 @@ int ShowTicket_old(int user_id, char *hostname, char * ddname) { | ||
241 | 252 | ||
242 | 253 | ||
243 | int ShowTicket(int user_id, char *hostname, char * ddname) { | 254 | int ShowTicket(int user_id, char *hostname, char * ddname) { |
244 | - //printf("ShowTicket2 : uid:%i, hostname:%s, ddname:%s\n", user_id, hostname, ddname); | 255 | + printf("ShowTicket2 : uid:%i, hostname:%s, ddname:%s\n", user_id, hostname, ddname); |
245 | time_t expiration_time; | 256 | time_t expiration_time; |
246 | time_t clock_value; | 257 | time_t clock_value; |
247 | int permission = NOPERMISSION; | 258 | int permission = NOPERMISSION; |
@@ -251,35 +262,50 @@ int ShowTicket(int user_id, char *hostname, char * ddname) { | @@ -251,35 +262,50 @@ int ShowTicket(int user_id, char *hostname, char * ddname) { | ||
251 | 262 | ||
252 | clock_value = time(NULL); | 263 | clock_value = time(NULL); |
253 | // expiration_time= clock_value+16200; // 4.5 hours | 264 | // expiration_time= clock_value+16200; // 4.5 hours |
254 | - expiration_time = clock_value+172800; // 48 hours | 265 | + //expiration_time = clock_value+172800; // 48 hours |
266 | + expiration_time = clock_value + 16200; | ||
255 | 267 | ||
256 | // selection query | 268 | // selection query |
257 | char * q = malloc(1024 * sizeof(char)); | 269 | char * q = malloc(1024 * sizeof(char)); |
258 | memset(q, 0, 1024); | 270 | memset(q, 0, 1024); |
259 | sprintf(q, "SELECT ddid,hostname,time FROM user_ticket WHERE userid=%i AND hostname='%s';", user_id,hostname); | 271 | sprintf(q, "SELECT ddid,hostname,time FROM user_ticket WHERE userid=%i AND hostname='%s';", user_id,hostname); |
260 | - //printf("query : %s\n", q); | 272 | + printf("query : -%s-\n", q); |
261 | sqlite3 * db; | 273 | sqlite3 * db; |
262 | sqlite3_stmt * res; | 274 | sqlite3_stmt * res; |
263 | sqlite3_open("amda.db", &db); | 275 | sqlite3_open("amda.db", &db); |
264 | int rc; rc = sqlite3_prepare_v2(db, q, -1, &res, 0); | 276 | int rc; rc = sqlite3_prepare_v2(db, q, -1, &res, 0); |
265 | int step; step = sqlite3_step(res); | 277 | int step; step = sqlite3_step(res); |
266 | if(step != SQLITE_ROW) { | 278 | if(step != SQLITE_ROW) { |
279 | + printf("\tno row found\n"); | ||
267 | // create a new entry in the database | 280 | // create a new entry in the database |
268 | - //printf("STEP FAIL\n"); | ||
269 | permission = NOPERMISSION; | 281 | permission = NOPERMISSION; |
270 | } | 282 | } |
271 | else { | 283 | else { |
284 | + printf("\trow found\n"); | ||
272 | while(step == SQLITE_ROW) { | 285 | while(step == SQLITE_ROW) { |
273 | int time_tmp; time_tmp = sqlite3_column_int(res, 2); | 286 | int time_tmp; time_tmp = sqlite3_column_int(res, 2); |
274 | int ddid_tmp; ddid_tmp = sqlite3_column_int(res, 0); | 287 | int ddid_tmp; ddid_tmp = sqlite3_column_int(res, 0); |
275 | - //printf("\t->row found : ddid %i, time %i, cv: %i\n", ddid_tmp, time_tmp, clock_value); | ||
276 | - //printf("\tdduserid : %i\n", DD_user_id); | 288 | + printf("\t->row found : ddid %i, time %i, cv: %i\n", ddid_tmp, time_tmp, clock_value); |
289 | + printf("\tdduserid : %i\n", DD_user_id); | ||
277 | if(ddid_tmp==DD_user_id) { | 290 | if(ddid_tmp==DD_user_id) { |
278 | if(clock_value < time_tmp) { | 291 | if(clock_value < time_tmp) { |
279 | // update expiration time | 292 | // update expiration time |
293 | + printf("\tclock_value < time_tmp : %ld < %ld\n", clock_value, time_tmp); | ||
294 | + printf("\tdiff : %ld\n", clock_value - time_tmp); | ||
280 | permission = 0; | 295 | permission = 0; |
281 | } | 296 | } |
282 | else { | 297 | else { |
298 | + printf("\tExpired ticket ?? %ld < %ld\n", clock_value, time_tmp); | ||
299 | + printf("\t%ld\n", clock_value - time_tmp); | ||
300 | + // remove ticket entry from table | ||
301 | + char * qq = malloc(1024 * sizeof(char)); | ||
302 | + memset(qq, 0, 1024); | ||
303 | + sprintf(qq, "DELETE FROM user_ticket WHERE userid=%i AND hostname='%s' AND time=%ld;", user_id,hostname,time_tmp); | ||
304 | + printf("DELETE q : -%s-\n", qq); | ||
305 | + sqlite3_exec(db, qq, 0, 0, NULL); | ||
306 | + printf("FREEEEEEEEE\n"); | ||
307 | + free(qq); | ||
308 | + | ||
283 | permission = NOPERMISSION; | 309 | permission = NOPERMISSION; |
284 | } | 310 | } |
285 | break; | 311 | break; |
src/SERVER/DD_GetData.c
@@ -19,6 +19,7 @@ extern LocalOrigSync(DD_Var_t *Local, DD_Var_t *Orig); | @@ -19,6 +19,7 @@ extern LocalOrigSync(DD_Var_t *Local, DD_Var_t *Orig); | ||
19 | * Fill General attributes fron the INFO file | 19 | * Fill General attributes fron the INFO file |
20 | */ | 20 | */ |
21 | int OpenInstr(char *VInstrName) { | 21 | int OpenInstr(char *VInstrName) { |
22 | + //printf("OpenInstr : Vi name : %s\n", VInstrName); | ||
22 | char refname[PATHLENGTH]; /* full name of the reference file */ | 23 | char refname[PATHLENGTH]; /* full name of the reference file */ |
23 | char *ddbase; /* Environment variable DDBASE (path to the DDBASE ROOT)*/ | 24 | char *ddbase; /* Environment variable DDBASE (path to the DDBASE ROOT)*/ |
24 | char RInstrName[MAXSETLENGTH]; /* Requested virtual instrument name */ | 25 | char RInstrName[MAXSETLENGTH]; /* Requested virtual instrument name */ |
@@ -41,6 +42,7 @@ int OpenInstr(char *VInstrName) { | @@ -41,6 +42,7 @@ int OpenInstr(char *VInstrName) { | ||
41 | for(id = 0; id < MaxIDNumber; id++) { | 42 | for(id = 0; id < MaxIDNumber; id++) { |
42 | if(DD_Var[id] != NULL) { | 43 | if(DD_Var[id] != NULL) { |
43 | if(strcmp(RInstrName, DD_Var[id]->InstrName) == 0) { | 44 | if(strcmp(RInstrName, DD_Var[id]->InstrName) == 0) { |
45 | + //printf("VI is open at id : %i\n", id); | ||
44 | return(id); | 46 | return(id); |
45 | } | 47 | } |
46 | } | 48 | } |
@@ -50,12 +52,14 @@ int OpenInstr(char *VInstrName) { | @@ -50,12 +52,14 @@ int OpenInstr(char *VInstrName) { | ||
50 | id =0; | 52 | id =0; |
51 | while((DD_Var[id] != NULL) && (id < MaxIDNumber)) id++; | 53 | while((DD_Var[id] != NULL) && (id < MaxIDNumber)) id++; |
52 | if(id >= MaxIDNumber) { | 54 | if(id >= MaxIDNumber) { |
55 | + //printf("TOO many instruments open\n"); | ||
53 | return(TOOMANYREQ); /* No room */ | 56 | return(TOOMANYREQ); /* No room */ |
54 | } | 57 | } |
55 | /* Open reference NC file */ | 58 | /* Open reference NC file */ |
56 | if((ddbase = getenv("DDBASE")) == NULL) return(NOREFFILE); | 59 | if((ddbase = getenv("DDBASE")) == NULL) return(NOREFFILE); |
57 | strcpy(refname,ddbase); | 60 | strcpy(refname,ddbase); |
58 | strcat(refname,REFNAME); | 61 | strcat(refname,REFNAME); |
62 | + //printf("Openning nc file %s\n", refname); | ||
59 | 63 | ||
60 | status = nc_open(refname, NC_NOWRITE|NC_SHARE,&refID); | 64 | status = nc_open(refname, NC_NOWRITE|NC_SHARE,&refID); |
61 | 65 | ||
@@ -176,7 +180,7 @@ int OpenInstr(char *VInstrName) { | @@ -176,7 +180,7 @@ int OpenInstr(char *VInstrName) { | ||
176 | * Closes this ID and return number of IDs remained in use | 180 | * Closes this ID and return number of IDs remained in use |
177 | */ | 181 | */ |
178 | int CloseID(int ID) { | 182 | int CloseID(int ID) { |
179 | - printf("\tclosing instrument %i\n", ID); | 183 | + //printf("\tclosing instrument %i\n", ID); |
180 | // TODO | 184 | // TODO |
181 | return 1; | 185 | return 1; |
182 | int status; | 186 | int status; |
src/SERVER/DD_Server.c
@@ -257,7 +257,7 @@ void pack_variables(XDR * xdrs, const DD_data_t * data, const u_int max_number) | @@ -257,7 +257,7 @@ void pack_variables(XDR * xdrs, const DD_data_t * data, const u_int max_number) | ||
257 | } | 257 | } |
258 | 258 | ||
259 | int send_var_data(const DD_data_t * data, const int socket_id, int last_flag) { | 259 | int send_var_data(const DD_data_t * data, const int socket_id, int last_flag) { |
260 | - printf("\tDEBUG : send_var_data\n"); | 260 | + //printf("\tDEBUG : send_var_data\n"); |
261 | XDR xdrs; | 261 | XDR xdrs; |
262 | caddr_t buff; | 262 | caddr_t buff; |
263 | int max_number, packet_size; | 263 | int max_number, packet_size; |
@@ -265,9 +265,9 @@ int send_var_data(const DD_data_t * data, const int socket_id, int last_flag) { | @@ -265,9 +265,9 @@ int send_var_data(const DD_data_t * data, const int socket_id, int last_flag) { | ||
265 | u_int n; | 265 | u_int n; |
266 | 266 | ||
267 | max_number = get_max_number(data); | 267 | max_number = get_max_number(data); |
268 | - printf("\t\tmax_number : %i\n", max_number); | 268 | + //printf("\t\tmax_number : %i\n", max_number); |
269 | packet_size = get_packet_size(data); | 269 | packet_size = get_packet_size(data); |
270 | - printf("\t\tpacket_size : %i\n", packet_size); | 270 | + //printf("\t\tpacket_size : %i\n", packet_size); |
271 | 271 | ||
272 | if((error = PutHeader(data->type, | 272 | if((error = PutHeader(data->type, |
273 | data->DimNumber+1, | 273 | data->DimNumber+1, |
@@ -429,12 +429,12 @@ int get_table_name(char * instrument_name, char * out) { | @@ -429,12 +429,12 @@ int get_table_name(char * instrument_name, char * out) { | ||
429 | } | 429 | } |
430 | 430 | ||
431 | int datatable_has_data(char * table_name, double start, double stop) { | 431 | int datatable_has_data(char * table_name, double start, double stop) { |
432 | - printf("in datatable_has_data : table_name: %s, start: %f, stop : %f\n", table_name, start, stop); | 432 | + //printf("in datatable_has_data : table_name: %s, start: %f, stop : %f\n", table_name, start, stop); |
433 | int ans = 0, rc; | 433 | int ans = 0, rc; |
434 | char * query = malloc( 1024 * sizeof(char) ); | 434 | char * query = malloc( 1024 * sizeof(char) ); |
435 | memset(query, 0, 1024); | 435 | memset(query, 0, 1024); |
436 | sprintf(query, "SELECT count(Time) FROM %s WHERE Time>=%f AND Time<%f;", table_name, start, stop); | 436 | sprintf(query, "SELECT count(Time) FROM %s WHERE Time>=%f AND Time<%f;", table_name, start, stop); |
437 | - printf("\t\t has data query : %s\n", query); | 437 | + //printf("\t\t has data query : %s\n", query); |
438 | sqlite3 * db; | 438 | sqlite3 * db; |
439 | sqlite3_stmt * res; | 439 | sqlite3_stmt * res; |
440 | sqlite3_open("amda.db", &db); | 440 | sqlite3_open("amda.db", &db); |
@@ -442,15 +442,15 @@ int datatable_has_data(char * table_name, double start, double stop) { | @@ -442,15 +442,15 @@ int datatable_has_data(char * table_name, double start, double stop) { | ||
442 | rc=sqlite3_step(res); | 442 | rc=sqlite3_step(res); |
443 | if(rc==SQLITE_ROW) { | 443 | if(rc==SQLITE_ROW) { |
444 | ans = sqlite3_column_int(res, 0); | 444 | ans = sqlite3_column_int(res, 0); |
445 | - printf("row found : %i\n", ans); | 445 | + //printf("row found : %i\n", ans); |
446 | } | 446 | } |
447 | else { | 447 | else { |
448 | - printf("no row found\n"); | 448 | + //printf("no row found\n"); |
449 | } | 449 | } |
450 | sqlite3_finalize(res); | 450 | sqlite3_finalize(res); |
451 | sqlite3_close(db); | 451 | sqlite3_close(db); |
452 | free(query); | 452 | free(query); |
453 | - printf("before return : %i\n", ans); | 453 | + //printf("before return : %i\n", ans); |
454 | return ans; | 454 | return ans; |
455 | } | 455 | } |
456 | 456 | ||
@@ -524,8 +524,7 @@ void log_ddvar(DD_Var_t * ddvar, char * filename) { | @@ -524,8 +524,7 @@ void log_ddvar(DD_Var_t * ddvar, char * filename) { | ||
524 | int k; for(k=0;k<m;k++) { | 524 | int k; for(k=0;k<m;k++) { |
525 | fprintf(ptr, "%f,", ((double*)ddvar->VarData[i].Variables[j])[k]); | 525 | fprintf(ptr, "%f,", ((double*)ddvar->VarData[i].Variables[j])[k]); |
526 | } | 526 | } |
527 | - fprintf(ptr, "\n"); | ||
528 | - } | 527 | + fprintf(ptr, "\n"); } |
529 | fprintf(ptr, "\n"); | 528 | fprintf(ptr, "\n"); |
530 | } | 529 | } |
531 | 530 | ||
@@ -534,8 +533,8 @@ void log_ddvar(DD_Var_t * ddvar, char * filename) { | @@ -534,8 +533,8 @@ void log_ddvar(DD_Var_t * ddvar, char * filename) { | ||
534 | 533 | ||
535 | int get_data_from_table(char * table_name, struct RequestData * request) { | 534 | int get_data_from_table(char * table_name, struct RequestData * request) { |
536 | int rc; | 535 | int rc; |
537 | - printf("\t\tinstrument start time : %f\n", get_instrument_time(request->instrument_id)); | ||
538 | - printf("\t\tinterval value : %f\n", DD_Time2Double(request->time)); | 536 | + //printf("\t\tinstrument start time : %f\n", get_instrument_time(request->instrument_id)); |
537 | + //printf("\t\tinterval value : %f\n", DD_Time2Double(request->time)); | ||
539 | double start_time = get_instrument_time(request->instrument_id); | 538 | double start_time = get_instrument_time(request->instrument_id); |
540 | double stop_time, dt; dt = DD_Time2Double(request->time); | 539 | double stop_time, dt; dt = DD_Time2Double(request->time); |
541 | stop_time = start_time + dt + 10; | 540 | stop_time = start_time + dt + 10; |
@@ -562,7 +561,7 @@ int get_data_from_table(char * table_name, struct RequestData * request) { | @@ -562,7 +561,7 @@ int get_data_from_table(char * table_name, struct RequestData * request) { | ||
562 | 561 | ||
563 | int i;for(i=0;i<request->variable_count;i++) { | 562 | int i;for(i=0;i<request->variable_count;i++) { |
564 | char * var_name = request->variable_names[i]; | 563 | char * var_name = request->variable_names[i]; |
565 | - printf("\tVariable name: %s\n", var_name); | 564 | + //printf("\tVariable name: %s\n", var_name); |
566 | if( strcmp(var_name, "Time") != 0) { | 565 | if( strcmp(var_name, "Time") != 0) { |
567 | IntArray * p_dim=NULL; p_dim = get_parameter_dimension(var_name, table_name); | 566 | IntArray * p_dim=NULL; p_dim = get_parameter_dimension(var_name, table_name); |
568 | if(p_dim!=NULL) { | 567 | if(p_dim!=NULL) { |
@@ -580,8 +579,8 @@ int get_data_from_table(char * table_name, struct RequestData * request) { | @@ -580,8 +579,8 @@ int get_data_from_table(char * table_name, struct RequestData * request) { | ||
580 | 579 | ||
581 | } | 580 | } |
582 | else { | 581 | else { |
583 | - printf("MUTLTIDIM DATA : Come back to this later\n"); | ||
584 | - printf("\tp_dim : %i\n", p_dim->size); | 582 | + //printf("MUTLTIDIM DATA : Come back to this later\n"); |
583 | + //printf("\tp_dim : %i\n", p_dim->size); | ||
585 | } | 584 | } |
586 | 585 | ||
587 | // set parameter data dimensions | 586 | // set parameter data dimensions |
@@ -708,13 +707,13 @@ void create_instrument_time_table() { | @@ -708,13 +707,13 @@ void create_instrument_time_table() { | ||
708 | } | 707 | } |
709 | 708 | ||
710 | double get_instrument_time(int instrument_id) { | 709 | double get_instrument_time(int instrument_id) { |
711 | - printf("in get_instrument_time id : %i\n", instrument_id); | 710 | + //printf("in get_instrument_time id : %i\n", instrument_id); |
712 | // selection query | 711 | // selection query |
713 | char * q = malloc(1024 * sizeof(char)); | 712 | char * q = malloc(1024 * sizeof(char)); |
714 | double ans = -1; | 713 | double ans = -1; |
715 | int rc; | 714 | int rc; |
716 | sprintf(q, "SELECT start FROM instrument_time WHERE id=%i LIMIT 1;", instrument_id); | 715 | sprintf(q, "SELECT start FROM instrument_time WHERE id=%i LIMIT 1;", instrument_id); |
717 | - printf("query : -%s-\n", q); | 716 | + //printf("query : -%s-\n", q); |
718 | sqlite3 * db; | 717 | sqlite3 * db; |
719 | sqlite3_stmt * res; | 718 | sqlite3_stmt * res; |
720 | sqlite3_open("amda.db", &db); | 719 | sqlite3_open("amda.db", &db); |
@@ -722,15 +721,15 @@ double get_instrument_time(int instrument_id) { | @@ -722,15 +721,15 @@ double get_instrument_time(int instrument_id) { | ||
722 | rc=sqlite3_step(res); | 721 | rc=sqlite3_step(res); |
723 | if(rc==SQLITE_ROW) { | 722 | if(rc==SQLITE_ROW) { |
724 | ans = sqlite3_column_double(res, 0); | 723 | ans = sqlite3_column_double(res, 0); |
725 | - printf("Row found : %f\n", ans); | 724 | + //printf("Row found : %f\n", ans); |
726 | } | 725 | } |
727 | else { | 726 | else { |
728 | - printf("No row found\n"); | 727 | + //printf("No row found\n"); |
729 | } | 728 | } |
730 | sqlite3_finalize(res); | 729 | sqlite3_finalize(res); |
731 | sqlite3_close(db); | 730 | sqlite3_close(db); |
732 | free(q); | 731 | free(q); |
733 | - printf("before return :%f\n", ans); | 732 | + //printf("before return :%f\n", ans); |
734 | return ans; | 733 | return ans; |
735 | } | 734 | } |
736 | int set_instrument_time(int instrument_id, double time) { | 735 | int set_instrument_time(int instrument_id, double time) { |
@@ -838,7 +837,7 @@ void Serv(int socket_id) { | @@ -838,7 +837,7 @@ void Serv(int socket_id) { | ||
838 | *----------------------------------------------*/ | 837 | *----------------------------------------------*/ |
839 | err=request_call(&r, socket_id, &done_flag, &TicketID, &RemainID); | 838 | err=request_call(&r, socket_id, &done_flag, &TicketID, &RemainID); |
840 | 839 | ||
841 | - } while(done_flag== 0);/* end while(done_flag) */ | 840 | + } while(!done_flag);/* end while(done_flag) */ |
842 | 841 | ||
843 | 842 | ||
844 | endend: | 843 | endend: |
src/SERVER/request.c
@@ -257,11 +257,11 @@ int request_call_close_instrument(struct RequestData * request, int socket_id, i | @@ -257,11 +257,11 @@ int request_call_close_instrument(struct RequestData * request, int socket_id, i | ||
257 | } | 257 | } |
258 | 258 | ||
259 | int request_call_set_time(struct RequestData * request, DD_Var_t * ddvar, int socket_id) { | 259 | int request_call_set_time(struct RequestData * request, DD_Var_t * ddvar, int socket_id) { |
260 | - printf("\tinstrument id : %i\n", request->instrument_id); | ||
261 | - printf("\tstart ddtime : %s\n", request->time); | 260 | + //printf("\tinstrument id : %i\n", request->instrument_id); |
261 | + //printf("\tstart ddtime : %s\n", request->time); | ||
262 | double time_s; | 262 | double time_s; |
263 | time_s = DD_Time2Double(request->time); | 263 | time_s = DD_Time2Double(request->time); |
264 | - printf("\tstart double : %f\n", time_s); | 264 | + //printf("\tstart double : %f\n", time_s); |
265 | int err; | 265 | int err; |
266 | if(request->instrument_id < 0) err = NOID; | 266 | if(request->instrument_id < 0) err = NOID; |
267 | if(err >= 0) err = SetTime(ddvar,DD_Time2Double(request->time)); | 267 | if(err >= 0) err = SetTime(ddvar,DD_Time2Double(request->time)); |
@@ -300,22 +300,26 @@ int request_call_data_info(struct RequestData * request, DD_Var_t * ddvar, int s | @@ -300,22 +300,26 @@ int request_call_data_info(struct RequestData * request, DD_Var_t * ddvar, int s | ||
300 | 300 | ||
301 | int request_call_get_ticket(struct RequestData * request, int socket_id, int * done_flag, int * ticket_id) { | 301 | int request_call_get_ticket(struct RequestData * request, int socket_id, int * done_flag, int * ticket_id) { |
302 | int err; | 302 | int err; |
303 | + printf("Checking ticket : login: %s, tick: %s\n", request->login, request->ticket); | ||
303 | err= CheckTicket(request->login, request->ticket); | 304 | err= CheckTicket(request->login, request->ticket); |
305 | + printf("err: %i\n", err); | ||
304 | Put2Log(request->user_id,request->host,request->login,err); /* Log file */ | 306 | Put2Log(request->user_id,request->host,request->login,err); /* Log file */ |
307 | + printf("Getting ticket : user_id: %i, host: %s, err: %i\n", request->user_id, request->host, err); | ||
305 | if(err>= 0) *ticket_id = GetTicket(request->user_id,request->host,err); | 308 | if(err>= 0) *ticket_id = GetTicket(request->user_id,request->host,err); |
309 | + printf("\tticket id : %i\n", *ticket_id); | ||
306 | PutHeader(*ticket_id,0,0,socket_id); | 310 | PutHeader(*ticket_id,0,0,socket_id); |
307 | *done_flag= 1; | 311 | *done_flag= 1; |
308 | return err; | 312 | return err; |
309 | } | 313 | } |
310 | 314 | ||
311 | double get_instrument_time2(int instrument_id) { | 315 | double get_instrument_time2(int instrument_id) { |
312 | - printf("in get_instrument_time2 id : %i\n", instrument_id); | 316 | + //printf("in get_instrument_time2 id : %i\n", instrument_id); |
313 | // selection query | 317 | // selection query |
314 | char * q = malloc(1024 * sizeof(char)); | 318 | char * q = malloc(1024 * sizeof(char)); |
315 | double ans = -1; | 319 | double ans = -1; |
316 | int rc; | 320 | int rc; |
317 | sprintf(q, "SELECT start FROM instrument_time WHERE id=%i LIMIT 1;", instrument_id); | 321 | sprintf(q, "SELECT start FROM instrument_time WHERE id=%i LIMIT 1;", instrument_id); |
318 | - printf("query : -%s-\n", q); | 322 | + //printf("query : -%s-\n", q); |
319 | sqlite3 * db; | 323 | sqlite3 * db; |
320 | sqlite3_stmt * res; | 324 | sqlite3_stmt * res; |
321 | sqlite3_open("amda.db", &db); | 325 | sqlite3_open("amda.db", &db); |
@@ -323,25 +327,25 @@ double get_instrument_time2(int instrument_id) { | @@ -323,25 +327,25 @@ double get_instrument_time2(int instrument_id) { | ||
323 | rc=sqlite3_step(res); | 327 | rc=sqlite3_step(res); |
324 | if(rc==SQLITE_ROW) { | 328 | if(rc==SQLITE_ROW) { |
325 | ans = sqlite3_column_double(res, 0); | 329 | ans = sqlite3_column_double(res, 0); |
326 | - printf("Row found : %f\n", ans); | 330 | + //printf("Row found : %f\n", ans); |
327 | } | 331 | } |
328 | else { | 332 | else { |
329 | - printf("No row found\n"); | 333 | + //printf("No row found\n"); |
330 | } | 334 | } |
331 | sqlite3_finalize(res); | 335 | sqlite3_finalize(res); |
332 | sqlite3_close(db); | 336 | sqlite3_close(db); |
333 | free(q); | 337 | free(q); |
334 | - printf("before return :%f\n", ans); | 338 | + //printf("before return :%f\n", ans); |
335 | return ans; | 339 | return ans; |
336 | } | 340 | } |
337 | 341 | ||
338 | int datatable_has_data2(char * table_name, double start, double stop) { | 342 | int datatable_has_data2(char * table_name, double start, double stop) { |
339 | - printf("in datatable_has_data2 : table_name:%s, start:%f, stop:%f\n", table_name, start, stop); | 343 | + //printf("in datatable_has_data2 : table_name:%s, start:%f, stop:%f\n", table_name, start, stop); |
340 | int ans = 0, rc; | 344 | int ans = 0, rc; |
341 | char * query = malloc( 1024 * sizeof(char) ); | 345 | char * query = malloc( 1024 * sizeof(char) ); |
342 | memset(query, 0, 1024); | 346 | memset(query, 0, 1024); |
343 | sprintf(query, "SELECT count(Time) FROM %s WHERE Time>=%f AND Time<%f;", table_name, start, stop); | 347 | sprintf(query, "SELECT count(Time) FROM %s WHERE Time>=%f AND Time<%f;", table_name, start, stop); |
344 | - printf("\t\t has data query : %s\n", query); | 348 | + //printf("\t\t has data query : %s\n", query); |
345 | sqlite3 * db; | 349 | sqlite3 * db; |
346 | sqlite3_stmt * res; | 350 | sqlite3_stmt * res; |
347 | sqlite3_open("amda.db", &db); | 351 | sqlite3_open("amda.db", &db); |
@@ -349,21 +353,21 @@ int datatable_has_data2(char * table_name, double start, double stop) { | @@ -349,21 +353,21 @@ int datatable_has_data2(char * table_name, double start, double stop) { | ||
349 | rc=sqlite3_step(res); | 353 | rc=sqlite3_step(res); |
350 | if(rc==SQLITE_ROW) { | 354 | if(rc==SQLITE_ROW) { |
351 | ans = sqlite3_column_int(res, 0); | 355 | ans = sqlite3_column_int(res, 0); |
352 | - printf("row found :%i\n", ans); | 356 | + //printf("row found :%i\n", ans); |
353 | } | 357 | } |
354 | else { | 358 | else { |
355 | - printf("no row found\n"); | 359 | + //printf("no row found\n"); |
356 | } | 360 | } |
357 | sqlite3_finalize(res); | 361 | sqlite3_finalize(res); |
358 | sqlite3_close(db); | 362 | sqlite3_close(db); |
359 | free(query); | 363 | free(query); |
360 | - printf("before return : %i\n", ans); | 364 | + //printf("before return : %i\n", ans); |
361 | return ans; | 365 | return ans; |
362 | } | 366 | } |
363 | int request_call_data_get(struct RequestData * request, int socket_id, int * done_flag, int * ticket_id) { | 367 | int request_call_data_get(struct RequestData * request, int socket_id, int * done_flag, int * ticket_id) { |
364 | int err,serr; | 368 | int err,serr; |
365 | - printf("\tparameters : "); | ||
366 | - print_string_array(request->variable_names, request->variable_count); | 369 | + //printf("\tparameters : "); |
370 | + //print_string_array(request->variable_names, request->variable_count); | ||
367 | // note the time at this point | 371 | // note the time at this point |
368 | struct timespec t0, t1; | 372 | struct timespec t0, t1; |
369 | clock_gettime(CLOCK_MONOTONIC_RAW, &t0); | 373 | clock_gettime(CLOCK_MONOTONIC_RAW, &t0); |
@@ -386,15 +390,15 @@ int request_call_data_get(struct RequestData * request, int socket_id, int * don | @@ -386,15 +390,15 @@ int request_call_data_get(struct RequestData * request, int socket_id, int * don | ||
386 | has_vi=has_virtual_instrument(table_name); | 390 | has_vi=has_virtual_instrument(table_name); |
387 | if(has_vi) { | 391 | if(has_vi) { |
388 | // try to get data for this instrument between start and stop dates | 392 | // try to get data for this instrument between start and stop dates |
389 | - printf("Instrument id : %i\n", request->instrument_id); | 393 | + //printf("Instrument id : %i\n", request->instrument_id); |
390 | double start_time; start_time = get_instrument_time(request->instrument_id); | 394 | double start_time; start_time = get_instrument_time(request->instrument_id); |
391 | - printf("start_time %f\n", start_time); | ||
392 | - printf("request time str : %s\n", request->time); | 395 | + //printf("start_time %f\n", start_time); |
396 | + //printf("request time str : %s\n", request->time); | ||
393 | double stop_time; stop_time = start_time + DD_Time2Double(request->time); | 397 | double stop_time; stop_time = start_time + DD_Time2Double(request->time); |
394 | - printf("before datatable_has_data2 call : table_name:%s, start_time:%f, stop_time:%f\n", table_name, start_time,stop_time); | 398 | + //printf("before datatable_has_data2 call : table_name:%s, start_time:%f, stop_time:%f\n", table_name, start_time,stop_time); |
395 | int has_data; | 399 | int has_data; |
396 | has_data = datatable_has_data(table_name, start_time, stop_time); | 400 | has_data = datatable_has_data(table_name, start_time, stop_time); |
397 | - printf("in request_call_data_get : has_data : %i\n", has_data); | 401 | + //printf("in request_call_data_get : has_data : %i\n", has_data); |
398 | if(has_data || 1) { | 402 | if(has_data || 1) { |
399 | err = get_data_from_table(table_name, request); | 403 | err = get_data_from_table(table_name, request); |
400 | } | 404 | } |
@@ -416,8 +420,8 @@ int request_call_data_get(struct RequestData * request, int socket_id, int * don | @@ -416,8 +420,8 @@ int request_call_data_get(struct RequestData * request, int socket_id, int * don | ||
416 | // note time at this point | 420 | // note time at this point |
417 | clock_gettime(CLOCK_MONOTONIC_RAW, &t1); | 421 | clock_gettime(CLOCK_MONOTONIC_RAW, &t1); |
418 | uint64_t ns = (t1.tv_sec - t0.tv_sec) * 1000000 + (t1.tv_nsec - t0.tv_nsec) / 1000; | 422 | uint64_t ns = (t1.tv_sec - t0.tv_sec) * 1000000 + (t1.tv_nsec - t0.tv_nsec) / 1000; |
419 | - printf("\t\t\tREQUEST TIME :%" PRIu64 "\n", ns); | ||
420 | - printf("\t\t\t\t %f ms\n", ns / 1000.); | 423 | + //printf("\t\t\tREQUEST TIME :%" PRIu64 "\n", ns); |
424 | + //printf("\t\t\t\t %f ms\n", ns / 1000.); | ||
421 | // TODO - free DD_Var_t object | 425 | // TODO - free DD_Var_t object |
422 | //DD_Var[r.instrument_id] = NULL; | 426 | //DD_Var[r.instrument_id] = NULL; |
423 | return err; | 427 | return err; |
@@ -438,6 +442,7 @@ int request_call(struct RequestData * request, int socket_id, int * done_flag, i | @@ -438,6 +442,7 @@ int request_call(struct RequestData * request, int socket_id, int * done_flag, i | ||
438 | case TIMESETREQ: | 442 | case TIMESETREQ: |
439 | printf("REQUEST : TIMESETREQ\n"); | 443 | printf("REQUEST : TIMESETREQ\n"); |
440 | err=request_call_set_time(request, DD_Var[request->instrument_id], socket_id); | 444 | err=request_call_set_time(request, DD_Var[request->instrument_id], socket_id); |
445 | + printf("SetTime err : %i\n", err); | ||
441 | set_instrument_time(request->instrument_id, DD_Time2Double(request->time)); | 446 | set_instrument_time(request->instrument_id, DD_Time2Double(request->time)); |
442 | break; | 447 | break; |
443 | case DATAINFOREQ: | 448 | case DATAINFOREQ: |