changed name of prefs_mod_time

svn path=/trunk/boinc/; revision=441
This commit is contained in:
David Anderson 2002-09-27 20:36:03 +00:00
parent 0b8ea015c5
commit 4a3355d9ae
8 changed files with 34 additions and 33 deletions

View File

@ -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

View File

@ -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;

View File

@ -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)

View File

@ -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;
}

View File

@ -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);

View File

@ -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, "<scheduler_request>")) return 1;
@ -59,13 +59,13 @@ int SCHEDULER_REQUEST::parse(FILE* fin) {
else if (parse_str(buf, "<platform_name>", platform_name, sizeof(platform_name))) continue;
else if (parse_int(buf, "<core_client_version>", core_client_version)) continue;
else if (parse_int(buf, "<work_req_seconds>", work_req_seconds)) continue;
else if (parse_int(buf, "<prefs_mod_time>", (int)prefs_mod_time)) {
else if (parse_int(buf, "<global_prefs_mod_time>", (int)global_prefs_mod_time)) {
continue;
}
else if (match_tag(buf, "<preferences>")) {
while (fgets(buf, 256, fin)) {
if (strstr(buf, "</preferences>")) break;
strcatdup(prefs_xml, buf);
strcatdup(global_prefs_xml, buf);
}
}
else if (match_tag(buf, "<host_info>")) {
@ -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, "<hostid>%d</hostid>\n", hostid);
}
if (send_prefs) {
if (send_global_prefs) {
fprintf(fout,
"<prefs_mod_time>%d</prefs_mod_time>\n",
user.prefs_mod_time
"<global_prefs_mod_time>%d</global_prefs_mod_time>\n",
user.global_prefs_mod_time
);
fputs(user.prefs, fout);
fputs(user.global_prefs, fout);
}
// acknowledge results

View File

@ -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<APP> apps;

View File

@ -118,7 +118,7 @@ int check_set(vector<RESULT> results, int& canonical, double& credit) {
sum += results[i].claimed_credit;
}
}
credit + sum/(neq-2);
credit = sum/(neq-2);
}
// free malloced files