*** empty log message ***

svn path=/trunk/boinc/; revision=5120
This commit is contained in:
David Anderson 2005-01-14 03:32:16 +00:00
parent fcd5fde1d9
commit aa1fceb978
5 changed files with 86 additions and 14 deletions

View File

@ -22680,7 +22680,7 @@ David 13 Jan 2005
db_update.php
Rom 13 Jan 2005
- Checkin the changes nessassary to hide threads in the forum code.
- Checkin the changes necessary to hide threads in the forum code.
By: Rob Ogilvie
- Hidden threads should not be visible through a direct call
@ -22688,3 +22688,28 @@ Rom 13 Jan 2005
forum.inc
html/user/
forum_thread.php
David 13 Jan 2005
- modified DB_BASE::enumerate() so that it returns:
- zero if returning a row
- ERR_DB_NOT_FOUND if reached end of result set
- other values indicated DB errors (e.g. lost connection to server)
Strange as it may seem, until now we didn't have a way of
knowing that enumerate() had errored out.
As a result, e.g., db_dump would happily generate
a zero-entry user or host file
if the DB happened to disconnect during the select.
- changed db_dump.C to check error returns from enumerate(),
and exit() on DB failure
- changed xml_escape() to completely remove
control characters except for 9, 10, 13
db/
db_base.C
lib/
error_numbers.h
parse.C
sched/
db_dump.C

View File

@ -218,7 +218,9 @@ int DB_BASE::enumerate(char* clause, bool use_use_result) {
if (!row) {
mysql_free_result(cursor.rp);
cursor.active = false;
return 1;
int x = mysql_errno(db->mysql);
if (x) return x;
return ERR_DB_NOT_FOUND;
} else {
db_parse(row);
}

View File

@ -74,7 +74,7 @@
#define ERR_USER_REJECTED -135
// user rejected executable file
#define ERR_DB_NOT_FOUND -136
// no rows found in lookup()
// no rows found in lookup() or enumerate()
#define ERR_DB_NOT_UNIQUE -137
// not unique in lookup()
#define ERR_DB_CANT_CONNECT -138

View File

@ -315,9 +315,18 @@ void xml_escape(string& in, string& out) {
out += "<";
} else if (in[i] == '&') {
out += "&";
} else if (x < 32 || x>127) {
} else if (x>127) {
sprintf(buf, "&#%d;", x);
out += buf;
} else if (x<32) {
switch(x) {
case 9:
case 10:
case 13:
sprintf(buf, "&#%d;", x);
out += buf;
break;
}
} else {
out += in[i];
}

View File

@ -284,7 +284,12 @@ void NUMBERED_ZFILE::set_id(int id) {
}
void write_host(HOST& host, FILE* f, bool detail) {
int retval;
string p_vendor, p_model, os_name, os_version;
xml_escape(host.p_vendor, p_vendor);
xml_escape(host.p_model, p_model);
xml_escape(host.os_name, os_name);
xml_escape(host.os_version, os_version);
fprintf(f,
"<host>\n"
" <id>%d</id>\n",
@ -315,10 +320,10 @@ void write_host(HOST& host, FILE* f, bool detail) {
host.total_credit,
host.expavg_credit,
host.expavg_time,
host.p_vendor,
host.p_model,
host.os_name,
host.os_version
p_vendor.c_str(),
p_model.c_str(),
os_name.c_str(),
os_version.c_str()
);
if (detail) {
fprintf(f,
@ -411,11 +416,17 @@ void write_user(USER& user, FILE* f, bool detail) {
if (detail && user.show_hosts) {
DB_HOST host;
sprintf(buf, "where userid=%d", user.id);
while (!host.enumerate(buf)) {
while (1) {
retval = host.enumerate(buf)
if (retval) break;
if (host.total_credit > 0) {
write_host(host, f, false);
}
}
if (retval != ERR_DB_NOT_FOUND) {
boinc_db.print_error("host enum");
exit(retval);
}
}
#endif
fprintf(f,
@ -428,6 +439,7 @@ void write_team(TEAM& team, FILE* f, bool detail) {
char buf[256];
string name;
string url, name_html, description;
int retval;
xml_escape(team.name, name);
@ -480,9 +492,15 @@ void write_team(TEAM& team, FILE* f, bool detail) {
);
if (detail) {
sprintf(buf, "where teamid=%d", team.id);
while (!user.enumerate(buf)) {
while (1) {
retval = user.enumerate(buf);
if (retval) break;
write_user(user, f, false);
}
if (retval != ERR_DB_NOT_FOUND) {
boinc_db.print_error("user enum");
exit(retval);
}
}
fprintf(f,
"</team>\n"
@ -607,7 +625,7 @@ int tables_file(char* dir) {
int ENUMERATION::make_it_happen(char* output_dir) {
unsigned int i;
int n;
int n, retval;
DB_USER user;
DB_TEAM team;
DB_HOST host;
@ -644,7 +662,9 @@ int ENUMERATION::make_it_happen(char* output_dir) {
switch(table) {
case TABLE_USER:
n = 0;
while (!user.enumerate(clause, true)) {
while (1) {
retval = user.enumerate(clause, true);
if (retval) break;
for (i=0; i<outputs.size(); i++) {
OUTPUT& out = outputs[i];
if (sort == SORT_ID && out.recs_per_file) {
@ -657,10 +677,16 @@ int ENUMERATION::make_it_happen(char* output_dir) {
}
}
}
if (retval != ERR_DB_NOT_FOUND) {
boinc_db.print_error("user enum");
exit(retval);
}
break;
case TABLE_HOST:
n = 0;
while(!host.enumerate(clause)) {
while(1) {
retval = host.enumerate(clause);
if (retval) break;
for (i=0; i<outputs.size(); i++) {
OUTPUT& out = outputs[i];
if (sort == SORT_ID && out.recs_per_file) {
@ -673,10 +699,16 @@ int ENUMERATION::make_it_happen(char* output_dir) {
}
}
}
if (retval != ERR_DB_NOT_FOUND) {
boinc_db.print_error("host enum");
exit(retval);
}
break;
case TABLE_TEAM:
n = 0;
while(!team.enumerate(clause)) {
while(1) {
retval = team.enumerate(clause);
if (retval) break;
for (i=0; i<outputs.size(); i++) {
OUTPUT& out = outputs[i];
if (sort == SORT_ID && out.recs_per_file) {
@ -689,6 +721,10 @@ int ENUMERATION::make_it_happen(char* output_dir) {
}
}
}
if (retval != ERR_DB_NOT_FOUND) {
boinc_db.print_error("team enum");
exit(retval);
}
break;
}
for (i=0; i<outputs.size(); i++) {