Skip to content

Commit

Permalink
- XML parsing: when parsing int/double/bool and fail to find end tag,
Browse files Browse the repository at this point in the history
    don't modify the reference arg.
- scheduler: improved messages for preferences

svn path=/trunk/boinc/; revision=15757
  • Loading branch information
davidpanderson committed Aug 5, 2008
1 parent d6f02a6 commit 1c139a5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
13 changes: 12 additions & 1 deletion checkin_notes
Original file line number Diff line number Diff line change
Expand Up @@ -6163,10 +6163,21 @@ David 5 Aug 2008
parse.C,h

David 5 Aug 2008
- client: if fail to parse global_prefs.xml, delete it and reset global prefs
- client: if fail to parse global_prefs.xml,
delete it and reset global prefs
(which may have been modified by the attempt at parsing)

client/
cs_prefs.C
lib/
prefs.C,h

David 5 Aug 2008
- XML parsing: when parsing int/double/bool and fail to find end tag,
don't modify the reference arg.
- scheduler: improved messages for preferences

sched/
handle_request.C
lib/
parse.C
10 changes: 6 additions & 4 deletions lib/parse.C
Original file line number Diff line number Diff line change
Expand Up @@ -587,15 +587,15 @@ bool XML_PARSER::parse_int(char* parsed_tag, const char* start_tag, int& i) {
return false;
}
}
int j = strtol(buf, &end, 0);
int val = strtol(buf, &end, 0);
if (errno == ERANGE) return false;
if (end != buf+strlen(buf)) return false;

eof = get(tag, sizeof(tag), is_tag);
if (eof) return false;
if (!is_tag) return false;
if (strcmp(tag, end_tag)) return false;
i = j;
i = val;
return true;
}

Expand All @@ -621,13 +621,14 @@ bool XML_PARSER::parse_double(char* parsed_tag, const char* start_tag, double& x
return false;
}
}
x = strtod(buf, &end);
double val = strtod(buf, &end);
if (end != buf+strlen(buf)) return false;

eof = get(tag, sizeof(tag), is_tag);
if (eof) return false;
if (!is_tag) return false;
if (strcmp(tag, end_tag)) return false;
x = val;
return true;
}

Expand All @@ -654,7 +655,7 @@ bool XML_PARSER::parse_bool(char* parsed_tag, const char* start_tag, bool& b) {
eof = get(buf, sizeof(buf), is_tag);
if (eof) return false;
if (is_tag) return false;
b = (strtol(buf, &end, 0) != 0);
bool val = (strtol(buf, &end, 0) != 0);
if (end != buf+strlen(buf)) return false;

end_tag[0] = '/';
Expand All @@ -663,6 +664,7 @@ bool XML_PARSER::parse_bool(char* parsed_tag, const char* start_tag, bool& b) {
if (eof) return false;
if (!is_tag) return false;
if (strcmp(tag, end_tag)) return false;
b = val;
return true;
}

Expand Down
18 changes: 15 additions & 3 deletions sched/handle_request.C
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,12 @@ int handle_global_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) {
if (db_mod_time > dtime()) db_mod_time = dtime();
}

//log_messages.printf(MSG_DEBUG, "have_master:%d have_working: %d have_db: %d\n", have_master_prefs, have_working_prefs, have_db_prefs);
if (config.debug_prefs) {
log_messages.printf(MSG_DEBUG,
"have_master:%d have_working: %d have_db: %d\n",
have_master_prefs, have_working_prefs, have_db_prefs
);
}

// decide which prefs to use for sched decisions,
// and parse them into sreq.global_prefs
Expand Down Expand Up @@ -868,9 +873,16 @@ int handle_global_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) {

// decide whether to send DB prefs in reply msg
//
//log_messages.printf(MSG_DEBUG, "have db %d; dbmod %f; global mod %f\n", have_db_prefs, db_mod_time, sreq.global_prefs.mod_time);
if (config.debug_prefs) {
log_messages.printf(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(MSG_DEBUG, "sending db prefs in reply\n");
if (config.debug_prefs) {
log_messages.printf(MSG_DEBUG, "sending db prefs in reply\n");
}
reply.send_global_prefs = true;
}
return 0;
Expand Down

0 comments on commit 1c139a5

Please sign in to comment.