Skip to content

Commit

Permalink
Merge pull request #5258 from BOINC/dpa_prefs6
Browse files Browse the repository at this point in the history
client: ignore old prefs sent by projects or AM
  • Loading branch information
davidpanderson authored Jun 15, 2023
2 parents 21b5a66 + 208c3b5 commit c43b4b3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
15 changes: 10 additions & 5 deletions client/acct_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,13 +799,18 @@ void ACCT_MGR_OP::handle_reply(int http_op_retval) {
// process prefs if any
//
if (!global_prefs_xml.empty()) {
retval = gstate.save_global_prefs(
global_prefs_xml.c_str(), ami.master_url, ami.master_url
double mod_time = GLOBAL_PREFS::parse_mod_time(
global_prefs_xml.c_str()
);
if (retval) {
msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't save global prefs");
if (mod_time > gstate.global_prefs.mod_time) {
retval = gstate.save_global_prefs(
global_prefs_xml.c_str(), ami.master_url, ami.master_url
);
if (retval) {
msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't save global prefs");
}
read_prefs = true;
}
read_prefs = true;
}

// process prefs if prefs or venue changed
Expand Down
2 changes: 1 addition & 1 deletion client/cs_account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ int CLIENT_STATE::add_project(
if (strlen(email_addr)) {
md5_block(
(unsigned char*)email_addr,
strlen(email_addr),
(int)strlen(email_addr),
project->email_hash
);
}
Expand Down
3 changes: 2 additions & 1 deletion client/cs_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,8 @@ int CLIENT_STATE::handle_scheduler_reply(
// if the scheduler reply includes global preferences,
// insert extra elements, write to disk, and parse
//
if (sr.global_prefs_xml) {
double mod_time = sr.global_prefs_xml?GLOBAL_PREFS::parse_mod_time(sr.global_prefs_xml):0;
if (sr.global_prefs_xml && mod_time > gstate.global_prefs.mod_time) {
// ignore prefs if we're using prefs from account mgr
// BAM! currently has mixed http, https; trim off
char* p = strchr(global_prefs.source_project, '/');
Expand Down
7 changes: 7 additions & 0 deletions lib/prefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,3 +936,10 @@ int GLOBAL_PREFS::write_subset(MIOFILE& f, GLOBAL_PREFS_MASK& mask) {
return 0;
}

// parse the <mod_time> element from a prefs XML string
//
double GLOBAL_PREFS::parse_mod_time(const char* p) {
const char *q = strstr(p, "<mod_time>");
if (!q) return 0;
return atof(q+strlen("<mod_time>"));
}
1 change: 1 addition & 0 deletions lib/prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ struct GLOBAL_PREFS {
inline double cpu_scheduling_period() {
return cpu_scheduling_period_minutes*60;
}
static double parse_mod_time(const char*);
};

#endif

0 comments on commit c43b4b3

Please sign in to comment.