- 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
This commit is contained in:
David Anderson 2008-02-03 21:46:30 +00:00
parent c891a167d6
commit 7ea74282f4
8 changed files with 39 additions and 11 deletions

View File

@ -1082,3 +1082,19 @@ David Feb 2 2008
forum_moderate_thread.php forum_moderate_thread.php
forum_moderate_thread_action.php forum_moderate_thread_action.php
forum_thread.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

View File

@ -345,7 +345,7 @@ int ACTIVE_TASK::start(bool first_time) {
} }
if (wup->project->verify_files_on_app_start) { if (wup->project->verify_files_on_app_start) {
FILE_INFO* fip=0; fip=0;
retval = gstate.input_files_available(result, true, &fip); retval = gstate.input_files_available(result, true, &fip);
if (retval) { if (retval) {
if (fip) { if (fip) {

View File

@ -30,6 +30,7 @@
#endif #endif
#include "parse.h" #include "parse.h"
#include "util.h"
#include "error_numbers.h" #include "error_numbers.h"
#include "prefs.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))) { if (xp.parse_str(tag, "source_scheduler", source_scheduler, sizeof(source_scheduler))) {
continue; 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)) { if (xp.parse_bool(tag, "run_on_batteries", run_on_batteries)) {
mask.run_on_batteries = true; mask.run_on_batteries = true;
continue; continue;
@ -598,7 +605,7 @@ int GLOBAL_PREFS::parse_file(
int GLOBAL_PREFS::write(MIOFILE& f) { int GLOBAL_PREFS::write(MIOFILE& f) {
f.printf( f.printf(
"<global_preferences>\n" "<global_preferences>\n"
" <mod_time>%d</mod_time>\n" " <mod_time>%f</mod_time>\n"
"%s%s" "%s%s"
" <suspend_if_no_recent_input>%f</suspend_if_no_recent_input>\n" " <suspend_if_no_recent_input>%f</suspend_if_no_recent_input>\n"
" <start_hour>%f</start_hour>\n" " <start_hour>%f</start_hour>\n"

View File

@ -130,7 +130,7 @@ public:
struct GLOBAL_PREFS { struct GLOBAL_PREFS {
int mod_time; double mod_time;
bool run_on_batteries; bool run_on_batteries;
// poorly named; what it really means is: // poorly named; what it really means is:
// if false, suspend while on batteries // if false, suspend while on batteries

View File

@ -689,12 +689,14 @@ int handle_global_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) {
bool same_account = !strcmp( bool same_account = !strcmp(
sreq.global_prefs_source_email_hash, reply.email_hash 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) { if (have_master_prefs) {
parse_int(sreq.global_prefs_xml, "<mod_time>", master_mod_time); parse_double(sreq.global_prefs_xml, "<mod_time>", master_mod_time);
if (master_mod_time > dtime()) master_mod_time = dtime();
} }
if (have_db_prefs) { if (have_db_prefs) {
parse_int(reply.user.global_prefs, "<mod_time>", db_mod_time); parse_double(reply.user.global_prefs, "<mod_time>", 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); //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 // 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) { if (have_db_prefs && db_mod_time > master_mod_time) {
log_messages.printf(SCHED_MSG_LOG::MSG_DEBUG, "sending db prefs in reply\n"); log_messages.printf(SCHED_MSG_LOG::MSG_DEBUG, "sending db prefs in reply\n");
reply.send_global_prefs = true; reply.send_global_prefs = true;

View File

@ -1029,7 +1029,10 @@ void GLOBAL_PREFS::parse(const char* buf, const char* venue) {
defaults(); defaults();
parse_int(buf, "<mod_time>", mod_time); // mod_time is outside of venue if (parse_double(buf, "<mod_time>", mod_time)) {
// mod_time is outside of venue
if (mod_time > dtime()) mod_time = dtime();
}
extract_venue(buf, venue, buf2); extract_venue(buf, venue, buf2);
parse_double(buf2, "<disk_max_used_gb>", disk_max_used_gb); parse_double(buf2, "<disk_max_used_gb>", disk_max_used_gb);
parse_double(buf2, "<disk_max_used_pct>", disk_max_used_pct); parse_double(buf2, "<disk_max_used_pct>", disk_max_used_pct);

View File

@ -123,7 +123,7 @@ struct CLIENT_APP_VERSION {
// subset of global prefs used by scheduler // subset of global prefs used by scheduler
// //
struct GLOBAL_PREFS { struct GLOBAL_PREFS {
int mod_time; double mod_time;
double disk_max_used_gb; double disk_max_used_gb;
double disk_max_used_pct; double disk_max_used_pct;
double disk_min_free_gb; double disk_min_free_gb;

View File

@ -30,7 +30,7 @@
int main() { int main() {
SCHED_SHMEM* ssp; SCHED_SHMEM* ssp;
int retval, i; int retval;
void* p; void* p;
SCHED_CONFIG config; SCHED_CONFIG config;