From e0cea3178123a88f2fe997b0a589dcefae56b841 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 30 Jul 2010 21:43:23 +0000 Subject: [PATCH] - API: add result name to APP_INFO_DATA structure (for Volpex) - scheduler: add max_download_urls_per_file config option (to limit the length of workunit.xml_doc, which is currently capped at 64KB). From Bernd. svn path=/trunk/boinc/; revision=22082 --- checkin_notes | 15 ++++++++++++ client/app_start.cpp | 1 + doc/help.php | 2 +- doc/manager_links.php | 11 ++++++++- lib/app_ipc.cpp | 6 +++++ lib/app_ipc.h | 1 + sched/sched_config.cpp | 1 + sched/sched_config.h | 1 + sched/sched_timezone.cpp | 51 +++++++++++++++++++++++++--------------- 9 files changed, 68 insertions(+), 21 deletions(-) diff --git a/checkin_notes b/checkin_notes index bf17d71ee9..9288c76556 100644 --- a/checkin_notes +++ b/checkin_notes @@ -5642,3 +5642,18 @@ Rom 30 Jul 2010 client/ net_stats.cpp sysmon_win.cpp + +David 30 Jul 2010 + - API: add result name to APP_INFO_DATA structure (for Volpex) + - scheduler: add max_download_urls_per_file config option + (to limit the length of workunit.xml_doc, + which is currently capped at 64KB). + From Bernd. + + client/ + app_start.cpp + lib/ + app_ipc.cpp,h + sched/ + sched_timezone.cpp + sched_config.cpp,h diff --git a/client/app_start.cpp b/client/app_start.cpp index c13bf5aa1d..0b8e4cdc85 100644 --- a/client/app_start.cpp +++ b/client/app_start.cpp @@ -220,6 +220,7 @@ int ACTIVE_TASK::write_app_init_file() { strcpy(aid.authenticator, wup->project->authenticator); aid.slot = slot; strcpy(aid.wu_name, wup->name); + strcpy(aid.result_name, result->name); aid.user_total_credit = wup->project->user_total_credit; aid.user_expavg_credit = wup->project->user_expavg_credit; aid.host_total_credit = wup->project->host_total_credit; diff --git a/doc/help.php b/doc/help.php index cfaa5468b9..ae5987d576 100644 --- a/doc/help.php +++ b/doc/help.php @@ -4,7 +4,7 @@ require_once("spoken_languages.php"); require_once("help_db.php"); require_once("../html/inc/translation.inc"); -page_head("Live help via Internet phone or email"); +page_head("Live help via Skype or email"); echo "

diff --git a/doc/manager_links.php b/doc/manager_links.php index 92781cba7a..692b3b1f4d 100644 --- a/doc/manager_links.php +++ b/doc/manager_links.php @@ -35,13 +35,22 @@ if (($target == "advanced") && version_compare($version, "5.10.0", ">=")) { } } else if (($target == "simple") && version_compare($version, "6.2.0", ">=")) { if ($controlid == "6024") { + // "Show info about BOINC" item on Mac simple-view menu + // header('Location: http://boinc.berkeley.edu'); } else if ($controlid == "6025") { + // "Show info about BOINC manager" item on Mac simple-view menu + // header('Location: http://boinc.berkeley.edu/wiki/Simple_view'); } else if ($controlid == "6035") { + // "Show info about BOINC and BOINC Manager" + // item on Mac simple-view menu ?? do we need this item? + // header('Location: http://boinc.berkeley.edu/wiki/BOINC_Help'); } else { - header('Location: http://boinc.berkeley.edu/wiki/Simple_view'); + // the question-mark button + // + header('Location: http://boinc.berkeley.edu/wiki/BOINC_Help'); } } else if ($target == "advanced_preferences") { header('Location: http://boinc.berkeley.edu/wiki/Preferences'); diff --git a/lib/app_ipc.cpp b/lib/app_ipc.cpp index f051705dc2..a9781f7542 100644 --- a/lib/app_ipc.cpp +++ b/lib/app_ipc.cpp @@ -86,6 +86,7 @@ void APP_INIT_DATA::copy(const APP_INIT_DATA& a) { memcpy(project_dir, a.project_dir, 256); memcpy(boinc_dir, a.boinc_dir, 256); memcpy(wu_name, a.wu_name, 256); + memcpy(result_name, a.result_name, 256); memcpy(authenticator, a.authenticator, 256); memcpy(&shmem_seg_name, &a.shmem_seg_name, sizeof(SHMEM_SEG_NAME)); @@ -169,6 +170,9 @@ int write_init_data_file(FILE* f, APP_INIT_DATA& ai) { if (strlen(ai.wu_name)) { fprintf(f, "%s\n", ai.wu_name); } + if (strlen(ai.result_name)) { + fprintf(f, "%s\n", ai.result_name); + } #ifdef _WIN32 if (strlen(ai.shmem_seg_name)) { fprintf(f, "%s\n", ai.shmem_seg_name); @@ -234,6 +238,7 @@ void APP_INIT_DATA::clear() { strcpy(project_dir, ""); strcpy(boinc_dir, ""); strcpy(wu_name, ""); + strcpy(result_name, ""); strcpy(authenticator, ""); slot = 0; user_total_credit = 0; @@ -324,6 +329,7 @@ int parse_init_data_file(FILE* f, APP_INIT_DATA& ai) { if (xp.parse_str(tag, "boinc_dir", ai.boinc_dir, sizeof(ai.boinc_dir))) continue; if (xp.parse_str(tag, "authenticator", ai.authenticator, sizeof(ai.authenticator))) continue; if (xp.parse_str(tag, "wu_name", ai.wu_name, sizeof(ai.wu_name))) continue; + if (xp.parse_str(tag, "result_name", ai.result_name, sizeof(ai.result_name))) continue; #ifdef _WIN32 if (xp.parse_str(tag, "comm_obj_name", ai.shmem_seg_name, sizeof(ai.shmem_seg_name))) continue; #else diff --git a/lib/app_ipc.h b/lib/app_ipc.h index 7f5037179e..0358b234b5 100644 --- a/lib/app_ipc.h +++ b/lib/app_ipc.h @@ -160,6 +160,7 @@ struct APP_INIT_DATA { char project_dir[256]; char boinc_dir[256]; char wu_name[256]; + char result_name[256]; char authenticator[256]; int slot; double user_total_credit; diff --git a/sched/sched_config.cpp b/sched/sched_config.cpp index 8bfcb2e703..9f5b5228e3 100644 --- a/sched/sched_config.cpp +++ b/sched/sched_config.cpp @@ -248,6 +248,7 @@ int SCHED_CONFIG::parse(FILE* f) { if (xp.parse_double(tag, "reliable_max_error_rate", reliable_max_error_rate)) continue; if (xp.parse_double(tag, "reliable_reduced_delay_bound", reliable_reduced_delay_bound)) continue; if (xp.parse_str(tag, "replace_download_url_by_timezone", replace_download_url_by_timezone, sizeof(replace_download_url_by_timezone))) continue; + if (xp.parse_int(tag, "max_download_urls_per_file", max_download_urls_per_file)) continue; if (xp.parse_int(tag, "report_max", report_max)) continue; if (xp.parse_bool(tag, "request_time_stats_log", request_time_stats_log)) continue; if (xp.parse_bool(tag, "resend_lost_results", resend_lost_results)) continue; diff --git a/sched/sched_config.h b/sched/sched_config.h index 2af80da4e3..c7b38010fd 100644 --- a/sched/sched_config.h +++ b/sched/sched_config.h @@ -140,6 +140,7 @@ struct SCHED_CONFIG { double reliable_reduced_delay_bound; // Reduce the delay bounds for reliable hosts by this percent char replace_download_url_by_timezone[256]; + int max_download_urls_per_file; int report_max; bool request_time_stats_log; bool resend_lost_results; diff --git a/sched/sched_timezone.cpp b/sched/sched_timezone.cpp index db45ea1f93..a0c7d44e25 100644 --- a/sched/sched_timezone.cpp +++ b/sched/sched_timezone.cpp @@ -148,7 +148,7 @@ URLTYPE* read_download_list() { "File %s contained no valid entries!\n" "Format of this file is one or more lines containing:\n" "TIMEZONE_OFFSET_IN_SEC http://some.url.path\n", - download_servers + download_servers ); free(cached); return NULL; @@ -172,8 +172,9 @@ URLTYPE* read_download_list() { // return number of bytes written, or <0 to indicate an error // -int make_download_list(char *buffer, char *path, int tz) { - char *start=buffer; +int make_download_list(char *buffer, char *path, unsigned int lim, int tz) { + char *start = buffer; + unsigned int l,len = 0; int i; // global variable used in the compare() function @@ -185,16 +186,19 @@ int make_download_list(char *buffer, char *path, int tz) { // print list of servers in sorted order. // Space is to format them nicely // - for (i=0; strlen(serverlist[i].name); i++) { - start+=sprintf(start, "%s%s%s", i?"\n ":"", serverlist[i].name, path); + for (i=0; + strlen(serverlist[i].name) && (config.max_download_urls_per_file ?(i < config.max_download_urls_per_file) :true); + i++ + ) { + l = sprintf(start, "%s%s%s", i?"\n ":"", serverlist[i].name, path); + len += l; + if (len >= lim) { + *start = '\0'; + return (start-buffer); + } + start += l; } - // make a second copy in the same order - // - for (i=0; strlen(serverlist[i].name); i++) { - start+=sprintf(start, "%s%s%s", "\n ", serverlist[i].name, path); - } - return (start-buffer); } @@ -202,8 +206,9 @@ int make_download_list(char *buffer, char *path, int tz) { // int add_download_servers(char *old_xml, char *new_xml, int tz) { char *p, *q, *r; - - p=r=old_xml; + int total_free = BLOB_SIZE - strlen(old_xml); + + p = (r = old_xml); // search for next URL to do surgery on while ((q=strstr(p, ""))) { @@ -212,7 +217,7 @@ int add_download_servers(char *old_xml, char *new_xml, int tz) { char *s; char path[1024]; - int len = q-p; + int len = q-p; // copy everything from p to q to new_xml // @@ -221,7 +226,7 @@ int add_download_servers(char *old_xml, char *new_xml, int tz) { // locate next instance of // - if (!(r=strstr(q, ""))) { + if (!(r = strstr(q, ""))) { return 1; } r += strlen(""); @@ -235,19 +240,27 @@ int add_download_servers(char *old_xml, char *new_xml, int tz) { // check if path contains the string specified in config.xml // - if (!(s=strstr(path,config.replace_download_url_by_timezone))) { + if (!(s = strstr(path,config.replace_download_url_by_timezone))) { // if it doesn't, just copy the whole tag as it is strncpy(new_xml, q, r-q); new_xml += r-q; p=r; } else { + // calculate free space available for URL replaces + int lim = total_free - (len - (p - old_xml)); + // find end of the specified replace string, // i.e. start of the 'path' s += strlen(config.replace_download_url_by_timezone); + // insert new download list in place of the original single URL - // - len = make_download_list(new_xml, s, tz); - if (len<0) { + len = make_download_list(new_xml, s, lim, tz); + if (len == 0) { + // if the replacement would exceed the maximum XML length, + // just keep the original URL + len = r-q; + strncpy(new_xml, q, len); + } else if (len < 0) { return 1; } new_xml += len;