From 7ea74282f446ce1553ceda48bb7fd914022cbe4e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 3 Feb 2008 21:46:30 +0000 Subject: [PATCH] - client: limit global prefs mod time to now - server: limit global prefs mod time to now These changes address the situation where a server sends out prefs with mod time far in the future, and there's no way to undo them svn path=/trunk/boinc/; revision=14664 --- checkin_notes | 16 ++++++++++++++++ client/app_start.C | 2 +- lib/prefs.C | 11 +++++++++-- lib/prefs.h | 2 +- sched/handle_request.C | 10 ++++++---- sched/server_types.C | 5 ++++- sched/server_types.h | 2 +- sched/show_shmem.C | 2 +- 8 files changed, 39 insertions(+), 11 deletions(-) diff --git a/checkin_notes b/checkin_notes index da0c9b6f38..695e237091 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1082,3 +1082,19 @@ David Feb 2 2008 forum_moderate_thread.php forum_moderate_thread_action.php forum_thread.php + +David Feb 3 2008 + - client: limit global prefs mod time to now + - server: limit global prefs mod time to now + These changes address the situation where a server + sends out prefs with mod time far in the future, + and there's no way to undo them + + client/ + app_start.C + lib/ + prefs.C,h + sched/ + handle_request.C + server_types.C,h + show_shmem.C diff --git a/client/app_start.C b/client/app_start.C index 5c17a4a7a6..92d4d07ad1 100644 --- a/client/app_start.C +++ b/client/app_start.C @@ -345,7 +345,7 @@ int ACTIVE_TASK::start(bool first_time) { } if (wup->project->verify_files_on_app_start) { - FILE_INFO* fip=0; + fip=0; retval = gstate.input_files_available(result, true, &fip); if (retval) { if (fip) { diff --git a/lib/prefs.C b/lib/prefs.C index dfcf4b0ec7..e6370a1489 100644 --- a/lib/prefs.C +++ b/lib/prefs.C @@ -30,6 +30,7 @@ #endif #include "parse.h" +#include "util.h" #include "error_numbers.h" #include "prefs.h" @@ -434,7 +435,13 @@ int GLOBAL_PREFS::parse_override( if (xp.parse_str(tag, "source_scheduler", source_scheduler, sizeof(source_scheduler))) { continue; } - if (xp.parse_int(tag, "mod_time", mod_time)) continue; + if (xp.parse_double(tag, "mod_time", mod_time)) { + double now = dtime(); + if (mod_time > now) { + mod_time = now; + } + continue; + } if (xp.parse_bool(tag, "run_on_batteries", run_on_batteries)) { mask.run_on_batteries = true; continue; @@ -598,7 +605,7 @@ int GLOBAL_PREFS::parse_file( int GLOBAL_PREFS::write(MIOFILE& f) { f.printf( "\n" - " %d\n" + " %f\n" "%s%s" " %f\n" " %f\n" diff --git a/lib/prefs.h b/lib/prefs.h index ae1b66f473..2a85b242ad 100644 --- a/lib/prefs.h +++ b/lib/prefs.h @@ -130,7 +130,7 @@ public: struct GLOBAL_PREFS { - int mod_time; + double mod_time; bool run_on_batteries; // poorly named; what it really means is: // if false, suspend while on batteries diff --git a/sched/handle_request.C b/sched/handle_request.C index 2be13dc094..d782d4633d 100644 --- a/sched/handle_request.C +++ b/sched/handle_request.C @@ -689,12 +689,14 @@ int handle_global_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { bool same_account = !strcmp( sreq.global_prefs_source_email_hash, reply.email_hash ); - int master_mod_time=0, db_mod_time=0; + double master_mod_time=0, db_mod_time=0; if (have_master_prefs) { - parse_int(sreq.global_prefs_xml, "", master_mod_time); + parse_double(sreq.global_prefs_xml, "", master_mod_time); + if (master_mod_time > dtime()) master_mod_time = dtime(); } if (have_db_prefs) { - parse_int(reply.user.global_prefs, "", db_mod_time); + parse_double(reply.user.global_prefs, "", db_mod_time); + if (db_mod_time > dtime()) db_mod_time = dtime(); } //log_messages.printf(SCHED_MSG_LOG::MSG_DEBUG, "have_master:%d have_working: %d have_db: %d\n", have_master_prefs, have_working_prefs, have_db_prefs); @@ -755,7 +757,7 @@ int handle_global_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // decide whether to send DB prefs in reply msg // - //log_messages.printf(SCHED_MSG_LOG::MSG_DEBUG, "have db %d; dbmod %d; global mod %d\n", have_db_prefs, db_mod_time, sreq.global_prefs.mod_time); + //log_messages.printf(SCHED_MSG_LOG::MSG_DEBUG, "have db %d; dbmod %f; global mod %f\n", have_db_prefs, db_mod_time, sreq.global_prefs.mod_time); if (have_db_prefs && db_mod_time > master_mod_time) { log_messages.printf(SCHED_MSG_LOG::MSG_DEBUG, "sending db prefs in reply\n"); reply.send_global_prefs = true; diff --git a/sched/server_types.C b/sched/server_types.C index 51f9e33dc1..b23678b5cc 100644 --- a/sched/server_types.C +++ b/sched/server_types.C @@ -1029,7 +1029,10 @@ void GLOBAL_PREFS::parse(const char* buf, const char* venue) { defaults(); - parse_int(buf, "", mod_time); // mod_time is outside of venue + if (parse_double(buf, "", mod_time)) { + // mod_time is outside of venue + if (mod_time > dtime()) mod_time = dtime(); + } extract_venue(buf, venue, buf2); parse_double(buf2, "", disk_max_used_gb); parse_double(buf2, "", disk_max_used_pct); diff --git a/sched/server_types.h b/sched/server_types.h index 7b4b7c0962..9a8d33211d 100644 --- a/sched/server_types.h +++ b/sched/server_types.h @@ -123,7 +123,7 @@ struct CLIENT_APP_VERSION { // subset of global prefs used by scheduler // struct GLOBAL_PREFS { - int mod_time; + double mod_time; double disk_max_used_gb; double disk_max_used_pct; double disk_min_free_gb; diff --git a/sched/show_shmem.C b/sched/show_shmem.C index 2b6f2c12a7..662aba7df7 100644 --- a/sched/show_shmem.C +++ b/sched/show_shmem.C @@ -30,7 +30,7 @@ int main() { SCHED_SHMEM* ssp; - int retval, i; + int retval; void* p; SCHED_CONFIG config;