From ecf08e05cdfea8406cdde231fb592159bc928c37 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 15 Jul 2004 18:54:17 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=3880 --- checkin_notes | 35 +++++++++++++ db/db_base.C | 12 ++--- html/inc/cache.inc | 3 ++ html/user/account_created.php | 6 ++- html/user/download.php | 5 +- html/user/show_user.php | 43 +++++++++++----- html/user/top_hosts.php | 2 +- html/user/top_teams.php | 2 +- html/user/top_users.php | 1 + lib/parse.C | 8 ++- lib/parse.h | 1 + sched/db_dump.C | 94 ++++++++++++++++++----------------- sched/handle_request.C | 2 + sched/sched_config.C | 3 ++ sched/sched_config.h | 1 + sched/sched_send.C | 20 ++++---- 16 files changed, 159 insertions(+), 79 deletions(-) diff --git a/checkin_notes b/checkin_notes index 127f50c1f0..360f808d2a 100755 --- a/checkin_notes +++ b/checkin_notes @@ -15248,3 +15248,38 @@ Brian 14 July 2004 Rom July 15 2004 - Tag for 4.00 release, all platforms boinc_release_4_00 + +David + - server: better messages on DB errors + - web: cache system looks for "format=xml" in cache args, + sends as MIME type XML if so + - added CGI interface to get user stats as XML + - top_*.php: forgot to exit() in case of too-large offset + - xml_escape(): change \n to space + - db_dump: error checking; add fields to team output; + only output items with nonzero total_credit + - scheduler: we were doing an optimization of not opening the DB + in case there's no work and client not returning results. + Don't do this if this is initial request from host + (otherwise it won't get hostid, and will detach project) + - add "enforce_delay_bound" to SCHED_CONFIG + (NOTE TO PROJECTS: unless you pub + in your config.xml, the scheduler will send results + to hosts that are too slow to complete them within delay bound.) + + db/ + db_base.C + html/ + inc/ + cache.inc + user/ + account_created.php + download.php + show_user.php + top_*.php + lib/ + parse.C,h + sched/ + db_dump.C + handle_request.C + sched_config.C,h diff --git a/db/db_base.C b/db/db_base.C index 47d291f39b..b138f72fcb 100644 --- a/db/db_base.C +++ b/db/db_base.C @@ -30,7 +30,7 @@ int DB_CONN::do_query(char* p) { int retval; retval = mysql_query(mysql, p); if (retval) { - fprintf(stderr, "Database error: query=%s\n", p); + fprintf(stderr, "Database error: %s\nquery=%s\n", error_string(), p); } return retval; } @@ -53,11 +53,7 @@ int DB_CONN::insert_id() { } void DB_CONN::print_error(char* p) { - if (mysql) { - fprintf(stderr, "%s: Database error: %s\n", p, mysql_error(mysql)); - } else { - fprintf(stderr, "%s: Database error\n", p); - } + fprintf(stderr, "%s: Database error: %s\n", p, error_string()); } const char* DB_CONN::error_string() { @@ -167,6 +163,10 @@ int DB_BASE::enumerate(char* clause) { x = db->do_query(query); if (x) return mysql_errno(db->mysql); + + // can't use mysql_use_results() here; if you do, + // any other transactions will fail + // cursor.rp = mysql_store_result(db->mysql); if (!cursor.rp) return mysql_errno(db->mysql); } diff --git a/html/inc/cache.inc b/html/inc/cache.inc index 4e604b7ad2..d96c6e4010 100644 --- a/html/inc/cache.inc +++ b/html/inc/cache.inc @@ -24,6 +24,9 @@ function start_cache($max_age, $params=""){ } else { // Otherwise serve the cached version and exit // + if (strstr($params, "format=xml")) { + header('Content-type: text/xml'); + } readfile($path); exit; } diff --git a/html/user/account_created.php b/html/user/account_created.php index 6fce9554e3..46ef057c67 100644 --- a/html/user/account_created.php +++ b/html/user/account_created.php @@ -10,7 +10,11 @@

Your account ID has been emailed to $email_addr.
- Please wait until you receive this email (it may take a minute or two). + Please wait until you receive this email. + If it doesn't arrive in a minute or two, + your ISP may be blocking it as 'spam'. + In this case please contact your ISP and + ask them to not block email from ".URL_BASE.". "; } else { echo "

Activate your ".PROJECT." account

\n"; diff --git a/html/user/download.php b/html/user/download.php index 42e8893a2f..03f62fb3ea 100644 --- a/html/user/download.php +++ b/html/user/download.php @@ -36,7 +36,10 @@ require_once("../inc/download.inc");

If your computer is not one of the above types, you can - download and compile the BOINC software yourself. +

BOINC can be customized for languages other than English diff --git a/html/user/show_user.php b/html/user/show_user.php index 1dffb4de1c..2ce272ce06 100644 --- a/html/user/show_user.php +++ b/html/user/show_user.php @@ -1,25 +1,42 @@ name"); - start_table(); - show_user_summary_public($user); - end_table(); - page_tail(); + if ($format == "xml") { + require_once("../inc/xml.inc"); + if ($user) { + show_user_xml($user); + } else { + xml_error("no such user ID"); + } } else { - page_head("Can't find user"); - echo "There is no account with that id.\n

"; - page_tail(); + if ($user) { + page_head("Account data for $user->name"); + start_table(); + show_user_summary_public($user); + end_table(); + page_tail(); + } else { + page_head("Can't find user"); + echo "There is no account with that ID.\n

"; + page_tail(); + } } + end_cache($cache_args); ?> diff --git a/html/user/top_hosts.php b/html/user/top_hosts.php index c822d1cd58..1554f2f032 100644 --- a/html/user/top_hosts.php +++ b/html/user/top_hosts.php @@ -18,7 +18,7 @@ page_head("Limit exceeded"); echo "Sorry - first 1000 only."; page_tail(); - + exit(); } require_once("../inc/db.inc"); diff --git a/html/user/top_teams.php b/html/user/top_teams.php index a1983892c3..d0282d82fa 100644 --- a/html/user/top_teams.php +++ b/html/user/top_teams.php @@ -18,7 +18,7 @@ page_head("Limit exceeded"); echo "Sorry - first 1000 only."; page_tail(); - + exit(); } require_once("../inc/db.inc"); diff --git a/html/user/top_users.php b/html/user/top_users.php index 28c649ea5e..789241818f 100644 --- a/html/user/top_users.php +++ b/html/user/top_users.php @@ -18,6 +18,7 @@ page_head("Limit exceeded"); echo "Sorry - first 1000 only."; page_tail(); + exit(); } require_once("../inc/db.inc"); diff --git a/lib/parse.C b/lib/parse.C index c05cf6deb1..2f5c8e4df6 100644 --- a/lib/parse.C +++ b/lib/parse.C @@ -271,12 +271,19 @@ void xml_escape(string& in, string& out) { out += "<"; } else if (in[i] == '&') { out += "&"; + } else if (in[i] == '\n') { + out += " "; } else { out += in[i]; } } } +void xml_escape(char* in, string& out) { + string foo = in; + xml_escape(foo, out); +} + void xml_unescape(string& in, string& out) { int i; out = ""; @@ -292,4 +299,3 @@ void xml_unescape(string& in, string& out) { } } } - diff --git a/lib/parse.h b/lib/parse.h index c544be8276..aa0fd2600b 100644 --- a/lib/parse.h +++ b/lib/parse.h @@ -43,6 +43,7 @@ extern int read_file_malloc(const char* pathname, char*& str); extern void replace_element(char* buf, char* start, char* end, char* replacement); extern char* sgets(char* buf, int len, char* &in); extern void xml_escape(std::string&, std::string&); +extern void xml_escape(char*, std::string&); extern void xml_unescape(std::string&, std::string&); extern void extract_venue(char*, char*, char*); diff --git a/sched/db_dump.C b/sched/db_dump.C index 093b0f06e1..c42f050551 100644 --- a/sched/db_dump.C +++ b/sched/db_dump.C @@ -204,15 +204,12 @@ protected: int compression; public: FILE* f; - ZFILE(string tag_, int comp) - : tag(tag_), compression(comp), f(0) - {printf("zfile const comp %d\n", compression);} + ZFILE(string tag_, int comp): tag(tag_), compression(comp), f(0) {} ~ZFILE() { close(); } void open(const char* filename) { close(); - printf("opening %s\n", filename); f = fopen(filename, "w"); if (!f) { log_messages.printf(SCHED_MSG_LOG::CRITICAL, "db_dump: Couldn't open %s for output\n", filename); @@ -234,16 +231,13 @@ public: if (f) { fprintf(f, "\n", tag.c_str()); fclose(f); - printf("close compression: %d\n", compression); switch(compression) { case COMPRESSION_ZIP: sprintf(buf, "zip -q %s", current_path); - printf("system: %s\n", buf); system(buf); break; case COMPRESSION_GZIP: sprintf(buf, "gzip -fq %s", current_path); - printf("system: %s\n", buf); system(buf); break; } @@ -278,6 +272,7 @@ void NUMBERED_ZFILE::set_id(int id) { } } +#if 0 void string_replace(string& str, string& old, string& newstr) { string::size_type oldlen = old.size(); string::size_type newlen = newstr.size(); @@ -309,8 +304,11 @@ void xml_escape(char* in, string& out) { string_replace(out, x4, y4); string_replace(out, x5, y5); } +#endif void write_host(HOST& host, FILE* f, bool detail) { + int retval; + fprintf(f, "\n" " %d\n", @@ -318,7 +316,11 @@ void write_host(HOST& host, FILE* f, bool detail) { ); if (detail) { DB_USER user; - user.lookup_id(host.userid); + retval = user.lookup_id(host.userid); + if (retval) { + log_messages.printf(SCHED_MSG_LOG::CRITICAL, "user lookup: %d\n", retval); + exit(1); + } if (user.show_hosts) { fprintf(f, " %d\n", @@ -444,8 +446,9 @@ void write_user(USER& user, FILE* f, bool detail) { void write_team(TEAM& team, FILE* f, bool detail) { DB_USER user; char buf[256]; - string name; + string url, name_html, description; + xml_escape(team.name, name); fprintf(f, @@ -463,39 +466,37 @@ void write_team(TEAM& team, FILE* f, bool detail) { team.expavg_time, team.nusers ); + + fprintf(f, + " %d\n", + team.create_time + ); + if (strlen(team.url)) { + xml_escape(team.url, url); + fprintf(f, + " %s\n", + url.c_str() + ); + } + if (strlen(team.name_html)) { + xml_escape(team.name_html, name_html); + fprintf(f, + "%s\n", + name_html.c_str() + ); + } + if (strlen(team.description)) { + xml_escape(team.description, description); + fprintf(f, + "%s\n", + description.c_str() + ); + } + fprintf(f, + " %s\n", + team.country + ); if (detail) { - string url, name_html, description; - - - fprintf(f, - " %d\n", - team.create_time - ); - if (strlen(team.url)) { - xml_escape(team.url, url); - fprintf(f, - " %s\n", - url.c_str() - ); - } - if (strlen(team.name_html)) { - xml_escape(team.name_html, name_html); - fprintf(f, - "%s\n", - name_html.c_str() - ); - } - if (strlen(team.description)) { - xml_escape(team.description, description); - fprintf(f, - "%s\n", - description.c_str() - ); - } - fprintf(f, - " %s\n", - team.country - ); sprintf(buf, "where teamid=%d", team.id); while (!user.enumerate(buf)) { write_user(user, f, false); @@ -635,7 +636,6 @@ int ENUMERATION::make_it_happen(char* output_dir) { for (i=0; i 0 order by id"); break; case SORT_TOTAL_CREDIT: - strcpy(clause, "order by total_credit desc"); + strcpy(clause, "where total_credit > 0 order by total_credit desc"); break; case SORT_EXPAVG_CREDIT: - strcpy(clause, "order by expavg_credit desc"); + strcpy(clause, "where total_credit > 0 order by expavg_credit desc"); break; } switch(table) { case TABLE_USER: n = 0; - while(!user.enumerate(clause)) { + while (!user.enumerate(clause)) { for (i=0; i 0) && ss.no_work() && (sreq.results.size() == 0) + && (sreq.hostid != 0) ) { strcat(reply.message, "No work available"); strcpy(reply.message_priority, "low"); diff --git a/sched/sched_config.C b/sched/sched_config.C index 0f14d8f148..d0093ec084 100644 --- a/sched/sched_config.C +++ b/sched/sched_config.C @@ -66,6 +66,9 @@ int SCHED_CONFIG::parse(char* buf) { if (match_tag(buf, "")) { ignore_upload_certificates = true; } + if (match_tag(buf, "")) { + enforce_delay_bound = true; + } parse_int(buf, "", min_sendwork_interval); parse_int(buf, "", max_wus_to_send); parse_int(buf, "", daily_result_quota); diff --git a/sched/sched_config.h b/sched/sched_config.h index 7f37d8f938..d143e281c6 100644 --- a/sched/sched_config.h +++ b/sched/sched_config.h @@ -42,6 +42,7 @@ public: bool non_cpu_intensive; bool homogeneous_redundancy; bool ignore_upload_certificates; + bool enforce_delay_bound; int daily_result_quota; // max results per host per day int parse(char*); diff --git a/sched/sched_send.C b/sched/sched_send.C index 92e9b3a585..de08a27785 100644 --- a/sched/sched_send.C +++ b/sched/sched_send.C @@ -167,16 +167,18 @@ bool wu_is_feasible( return false; } - double wu_wallclock_time = estimate_wallclock_duration(wu, host, resource_share_fraction); - int host_remaining_time = 0; // TODO + if (config.enforce_delay_bound) { + double wu_wallclock_time = estimate_wallclock_duration(wu, host, resource_share_fraction); + int host_remaining_time = 0; // TODO - if (host_remaining_time + wu_wallclock_time > wu.delay_bound) { - log_messages.printf( - SCHED_MSG_LOG::DEBUG, "[WU#%d %s] needs requires %d seconds on [HOST#%d]; delay_bound is %d\n", - wu.id, wu.name, (int)wu_wallclock_time, host.id, wu.delay_bound - ); - wreq.insufficient_speed = true; - return false; + if (host_remaining_time + wu_wallclock_time > wu.delay_bound) { + log_messages.printf( + SCHED_MSG_LOG::DEBUG, "[WU#%d %s] needs requires %d seconds on [HOST#%d]; delay_bound is %d\n", + wu.id, wu.name, (int)wu_wallclock_time, host.id, wu.delay_bound + ); + wreq.insufficient_speed = true; + return false; + } } return true;