From 4a3355d9aeb9259a7f391b81dcd075c0a8d33d17 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 27 Sep 2002 20:36:03 +0000 Subject: [PATCH] changed name of prefs_mod_time svn path=/trunk/boinc/; revision=441 --- db/db.h | 2 +- db/db_mysql.C | 6 +++--- db/schema.sql | 2 +- html/user/prefs.inc | 2 +- sched/handle_request.C | 25 +++++++++++++------------ sched/server_types.C | 22 +++++++++++----------- sched/server_types.h | 6 +++--- sched/validate_test.C | 2 +- 8 files changed, 34 insertions(+), 33 deletions(-) diff --git a/db/db.h b/db/db.h index 3d00ab9d1a..4fa5e824e1 100644 --- a/db/db.h +++ b/db/db.h @@ -116,7 +116,7 @@ struct USER { double expavg_credit; // credit per second, recent average double expavg_time; // when the above was computed char global_prefs[MAX_BLOB_SIZE]; // global preferences - unsigned int prefs_mod_time; // When the preferences were last updated + unsigned int global_prefs_mod_time; // When global prefs were last updated // zero if they're not defined char project_prefs[MAX_BLOB_SIZE]; int teamid; // if the user is part of a team diff --git a/db/db_mysql.C b/db/db_mysql.C index 053d1a9fe7..0a60742fbd 100644 --- a/db/db_mysql.C +++ b/db/db_mysql.C @@ -120,7 +120,7 @@ void struct_to_str(void* vp, char* q, int type) { "web_password='%s', authenticator='%s', " "country='%s', postal_code='%s', " "total_credit=%f, expavg_credit=%f, expavg_time=%f, " - "global_prefs='%s', prefs_mod_time=%d, project_prefs='%s', " + "global_prefs='%s', global_prefs_mod_time=%d, project_prefs='%s', " "teamid=%d", up->id, up->create_time, @@ -134,7 +134,7 @@ void struct_to_str(void* vp, char* q, int type) { up->expavg_credit, up->expavg_time, up->global_prefs, - up->prefs_mod_time, + up->global_prefs_mod_time, up->project_prefs, up->teamid ); @@ -296,7 +296,7 @@ void row_to_struct(MYSQL_ROW& r, void* vp, int type) { up->expavg_credit = atof(r[i++]); up->expavg_time = atof(r[i++]); strcpy(up->global_prefs, r[i++]); - up->prefs_mod_time = atoi(r[i++]); + up->global_prefs_mod_time = atoi(r[i++]); strcpy(up->project_prefs, r[i++]); up->teamid = atoi(r[i++]); break; diff --git a/db/schema.sql b/db/schema.sql index db15744b89..b995c92dd0 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -49,7 +49,7 @@ create table user ( expavg_credit float not null, expavg_time float not null, global_prefs blob, - prefs_mod_time integer not null, + global_prefs_mod_time integer not null, project_prefs blob, teamid integer not null, primary key (id) diff --git a/html/user/prefs.inc b/html/user/prefs.inc index 5d36915e89..5433a45f6e 100644 --- a/html/user/prefs.inc +++ b/html/user/prefs.inc @@ -323,7 +323,7 @@ function project_prefs_make_xml($prefs) { function global_prefs_update($user, $prefs) { $prefs_xml = global_prefs_make_xml($prefs); $now = time(); - mysql_query("update user set global_prefs='$prefs_xml', prefs_mod_time=$now where id=$user->id"); + mysql_query("update user set global_prefs='$prefs_xml', global_prefs_mod_time=$now where id=$user->id"); $user->global_prefs = $prefs_xml; } diff --git a/sched/handle_request.C b/sched/handle_request.C index 767be3ec02..a3a22225e8 100644 --- a/sched/handle_request.C +++ b/sched/handle_request.C @@ -224,21 +224,23 @@ int update_host_record(SCHEDULER_REQUEST& sreq, HOST& host) { return 0; } -// If the client sent prefs, and they're more recent than ours, +// If the client sent global prefs, and they're more recent than ours, // update user record in DB. -// If we our DB has more recent prefs than client's, send them. +// If we our DB has more recent global prefs than client's, send them. // -int handle_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { - if (sreq.prefs_mod_time > reply.user.prefs_mod_time && strlen(sreq.prefs_xml)) { - strncpy(reply.user.prefs, sreq.prefs_xml, sizeof(reply.user.prefs)); - reply.user.prefs_mod_time = sreq.prefs_mod_time; - if (reply.user.prefs_mod_time > (unsigned)time(0)) { - reply.user.prefs_mod_time = (unsigned)time(0); +int handle_global_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { + if (sreq.global_prefs_mod_time > reply.user.global_prefs_mod_time + && strlen(sreq.global_prefs_xml) + ) { + strncpy(reply.user.global_prefs, sreq.global_prefs_xml, sizeof(reply.user.global_prefs)); + reply.user.global_prefs_mod_time = sreq.global_prefs_mod_time; + if (reply.user.global_prefs_mod_time > (unsigned)time(0)) { + reply.user.global_prefs_mod_time = (unsigned)time(0); } db_user_update(reply.user); } - if (reply.user.prefs_mod_time > sreq.prefs_mod_time) { - reply.send_prefs = true; + if (reply.user.global_prefs_mod_time > sreq.global_prefs_mod_time) { + reply.send_global_prefs = true; } return 0; } @@ -447,7 +449,6 @@ void send_code_sign_key( } } } else { - fprintf(stderr, "%d: didn't get code sign key, sending one\n", getpid()); reply.code_sign_key = strdup(code_sign_key); } } @@ -475,7 +476,7 @@ void process_request( return; } - handle_prefs(sreq, reply); + handle_global_prefs(sreq, reply); handle_results(sreq, reply, reply.host); diff --git a/sched/server_types.C b/sched/server_types.C index b7241c2f9a..dbac35f0c4 100644 --- a/sched/server_types.C +++ b/sched/server_types.C @@ -30,12 +30,12 @@ using namespace std; #include "server_types.h" SCHEDULER_REQUEST::SCHEDULER_REQUEST() { - prefs_xml = 0; + global_prefs_xml = 0; code_sign_key = 0; } SCHEDULER_REQUEST::~SCHEDULER_REQUEST() { - if (prefs_xml) free(prefs_xml); + if (global_prefs_xml) free(global_prefs_xml); if (code_sign_key) free(code_sign_key); } @@ -46,8 +46,8 @@ int SCHEDULER_REQUEST::parse(FILE* fin) { strcpy(authenticator, ""); hostid = 0; work_req_seconds = 0; - prefs_mod_time = 0; - prefs_xml = strdup(""); + global_prefs_mod_time = 0; + global_prefs_xml = strdup(""); fgets(buf, 256, fin); if (!match_tag(buf, "")) return 1; @@ -59,13 +59,13 @@ int SCHEDULER_REQUEST::parse(FILE* fin) { else if (parse_str(buf, "", platform_name, sizeof(platform_name))) continue; else if (parse_int(buf, "", core_client_version)) continue; else if (parse_int(buf, "", work_req_seconds)) continue; - else if (parse_int(buf, "", (int)prefs_mod_time)) { + else if (parse_int(buf, "", (int)global_prefs_mod_time)) { continue; } else if (match_tag(buf, "")) { while (fgets(buf, 256, fin)) { if (strstr(buf, "")) break; - strcatdup(prefs_xml, buf); + strcatdup(global_prefs_xml, buf); } } else if (match_tag(buf, "")) { @@ -99,7 +99,7 @@ SCHEDULER_REPLY::SCHEDULER_REPLY() { hostid = 0; strcpy(message, ""); strcpy(message_priority, ""); - send_prefs = false; + send_global_prefs = false; code_sign_key = 0; code_sign_key_signature = 0; memset(&user, 0, sizeof(user)); @@ -144,12 +144,12 @@ int SCHEDULER_REPLY::write(FILE* fout) { fprintf(fout, "%d\n", hostid); } - if (send_prefs) { + if (send_global_prefs) { fprintf(fout, - "%d\n", - user.prefs_mod_time + "%d\n", + user.global_prefs_mod_time ); - fputs(user.prefs, fout); + fputs(user.global_prefs, fout); } // acknowledge results diff --git a/sched/server_types.h b/sched/server_types.h index 5ad403fdc8..444c60a6d6 100644 --- a/sched/server_types.h +++ b/sched/server_types.h @@ -32,8 +32,8 @@ struct SCHEDULER_REQUEST { int core_client_version; int rpc_seqno; int work_req_seconds; - unsigned int prefs_mod_time; - char* prefs_xml; + unsigned int global_prefs_mod_time; + char* global_prefs_xml; char* code_sign_key; HOST host; @@ -53,7 +53,7 @@ struct SCHEDULER_REPLY { char message_priority[256]; int hostid; // send this only if nonzero. // this tells client to reset rpc_seqno - bool send_prefs; // whether to send preferences + bool send_global_prefs; // whether to send global preferences USER user; HOST host; vector apps; diff --git a/sched/validate_test.C b/sched/validate_test.C index 674019c2d5..21ecd32a8d 100644 --- a/sched/validate_test.C +++ b/sched/validate_test.C @@ -118,7 +118,7 @@ int check_set(vector results, int& canonical, double& credit) { sum += results[i].claimed_credit; } } - credit + sum/(neq-2); + credit = sum/(neq-2); } // free malloced files