- scheduler: replace choose_download_url_by_timezone with

replace_download_url_by_timezone.


svn path=/trunk/boinc/; revision=17427
This commit is contained in:
David Anderson 2009-03-02 23:47:11 +00:00
parent 9059e026cf
commit 2d707927ab
5 changed files with 44 additions and 24 deletions

View File

@ -2469,3 +2469,12 @@ Rom 2 Mar 2009
openssl/
<Various Files>
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

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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<url>%s/%s</url>", i?"\n ":"", serverlist[i].name, path);
start+=sprintf(start, "%s<url>%s%s</url>", 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<url>%s/%s</url>", "\n ", serverlist[i].name, path);
start+=sprintf(start, "%s<url>%s%s</url>", "\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, "<url>"))) {
// p is at current position
// q is at beginning of next "<url>" 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 </url>
@ -220,29 +225,35 @@ int add_download_servers(char *old_xml, char *new_xml, int tz) {
}
r += strlen("</url>");
// parse out the URL
// r points to the end of the whole "<url>...</url>" tag
// parse out the URL into 'path'
//
if (!parse_str(q, "<url>", 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 <url> 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 <url> tag.
//
p = r;
}
strcpy(new_xml, r);