diff --git a/checkin_notes b/checkin_notes index 2870a6aad3..03001dea28 100644 --- a/checkin_notes +++ b/checkin_notes @@ -2469,3 +2469,12 @@ Rom 2 Mar 2009 openssl/ + +David 2 Mar 2009 + - scheduler: replace choose_download_url_by_timezone with + replace_download_url_by_timezone. + + sched/ + sched_timezone.cpp + sched_config.cpp,h + sched_send.cpp diff --git a/sched/sched_config.cpp b/sched/sched_config.cpp index c84768943b..54f1f5bd75 100644 --- a/sched/sched_config.cpp +++ b/sched/sched_config.cpp @@ -111,7 +111,7 @@ int SCHED_CONFIG::parse(FILE* f) { if (xp.parse_int(tag, "min_core_client_version", min_core_client_version)) continue; if (xp.parse_int(tag, "min_core_client_version_announced", min_core_client_version_announced)) continue; if (xp.parse_int(tag, "min_core_client_upgrade_deadline", min_core_client_upgrade_deadline)) continue; - if (xp.parse_bool(tag, "choose_download_url_by_timezone", choose_download_url_by_timezone)) 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_bool(tag, "cache_md5_info", cache_md5_info)) continue; if (xp.parse_bool(tag, "nowork_skip", nowork_skip)) 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 865c4ed39d..5ec4261aac 100644 --- a/sched/sched_config.h +++ b/sched/sched_config.h @@ -67,7 +67,7 @@ public: int min_core_client_version; int min_core_client_version_announced; int min_core_client_upgrade_deadline; - bool choose_download_url_by_timezone; + char replace_download_url_by_timezone[256]; bool cache_md5_info; bool nowork_skip; bool resend_lost_results; diff --git a/sched/sched_send.cpp b/sched/sched_send.cpp index 15a0476a65..c0cf16a785 100644 --- a/sched/sched_send.cpp +++ b/sched/sched_send.cpp @@ -915,7 +915,7 @@ int add_wu_to_reply( if (avp) { APP_VERSION av2=*avp, *avp2=&av2; - if (config.choose_download_url_by_timezone) { + if (strlen(config.replace_download_url_by_timezone)) { process_av_timezone(avp, av2); } @@ -941,7 +941,7 @@ int add_wu_to_reply( return retval; } wu3 = wu2; - if (config.choose_download_url_by_timezone) { + if (strlen(config.replace_download_url_by_timezone)) { process_wu_timezone(wu2, wu3); } diff --git a/sched/sched_timezone.cpp b/sched/sched_timezone.cpp index 25312f6cf8..103e7640b3 100644 --- a/sched/sched_timezone.cpp +++ b/sched/sched_timezone.cpp @@ -27,6 +27,7 @@ #include "server_types.h" #include "sched_msgs.h" +#include "sched_config.h" #ifdef _USING_FCGI_ #include "boinc_fcgi.h" @@ -184,13 +185,13 @@ int make_download_list(char *buffer, char *path, int tz) { // 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); + start+=sprintf(start, "%s%s%s", i?"\n ":"", serverlist[i].name, path); } // 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); + start+=sprintf(start, "%s%s%s", "\n ", serverlist[i].name, path); } return (start-buffer); @@ -205,12 +206,16 @@ int add_download_servers(char *old_xml, char *new_xml, int tz) { // search for next URL to do surgery on while ((q=strstr(p, ""))) { + // p is at current position + // q is at beginning of next "" tag + char *s; char path[1024]; int len = q-p; + // copy everything from p to q to new_xml + // strncpy(new_xml, p, len); - new_xml += len; // locate next instance of @@ -220,29 +225,35 @@ int add_download_servers(char *old_xml, char *new_xml, int tz) { } r += strlen(""); - // parse out the URL + // r points to the end of the whole "..." tag + // parse out the URL into 'path' // if (!parse_str(q, "", path, 1024)) { return 1; } - - // find start of 'download/' + + // check if path contains the string specified in config.xml // - if (!(s=strstr(path,"download/"))) { - return 1; + 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 { + // 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) { + return 1; + } + new_xml += len; + // advance pointer to start looking for next tag. + // + p=r; } - - // insert new download list in place of the original one - // - len = make_download_list(new_xml, s, tz); - if (len<0) { - return 1; - } - new_xml += len; - - // advance pointer to start looking for next tag. - // - p = r; } strcpy(new_xml, r);