- client: more stuff for replicated trickle ups

svn path=/trunk/boinc/; revision=24255
This commit is contained in:
David Anderson 2011-09-22 05:39:42 +00:00
parent a676fda344
commit 3a7def077a
4 changed files with 42 additions and 28 deletions

View File

@ -6349,3 +6349,11 @@ David 21 Sept 2011
schema.sql schema.sql
py/Boinc/ py/Boinc/
setup_project.py setup_project.py
David 21 Sept 2011
- client: more stuff for replicated trickle ups
client/
cs_trickle.cpp
client_types.cpp
http_curl.cpp

View File

@ -178,7 +178,7 @@ static bool parse_rsc_param(XML_PARSER& xp, const char* end_tag, int& rsc_type,
// //
int PROJECT::parse_state(XML_PARSER& xp) { int PROJECT::parse_state(XML_PARSER& xp) {
char buf[256]; char buf[256];
std::string sched_url; std::string sched_url, stemp;
string str1, str2; string str1, str2;
int retval, rt; int retval, rt;
double x; double x;
@ -312,6 +312,9 @@ int PROJECT::parse_state(XML_PARSER& xp) {
if (xp.parse_bool("scheduler_rpc_in_progress", btemp)) continue; if (xp.parse_bool("scheduler_rpc_in_progress", btemp)) continue;
if (xp.parse_bool("use_symlinks", use_symlinks)) continue; if (xp.parse_bool("use_symlinks", use_symlinks)) continue;
if (xp.parse_bool("anonymous_platform", btemp)) continue; if (xp.parse_bool("anonymous_platform", btemp)) continue;
if (xp.parse_string("trickle_up_url", stemp)) {
trickle_up_ops.push_back(new TRICKLE_UP_OP(stemp));
}
if (log_flags.unparsed_xml) { if (log_flags.unparsed_xml) {
msg_printf(0, MSG_INFO, msg_printf(0, MSG_INFO,
"[unparsed_xml] PROJECT::parse_state(): unrecognized: %s", "[unparsed_xml] PROJECT::parse_state(): unrecognized: %s",
@ -477,6 +480,13 @@ int PROJECT::write_state(MIOFILE& out, bool gui_rpc) {
" <code_sign_key>\n%s\n</code_sign_key>\n", code_sign_key " <code_sign_key>\n%s\n</code_sign_key>\n", code_sign_key
); );
} }
for (i=0; i<trickle_up_ops.size(); i++) {
TRICKLE_UP_OP* t = trickle_up_ops[i];
out.printf(
" <trickle_up_url>%s</trickle_up_url>\n",
t->url.c_str()
);
}
} }
out.printf( out.printf(
"</project>\n" "</project>\n"

View File

@ -171,11 +171,13 @@ void send_replicated_trickles(PROJECT* p, string& msg) {
} }
// A scheduler reply gave us a list of trickle handler URLs. // A scheduler reply gave us a list of trickle handler URLs.
// If this is different than the list we currently have, replace it. // Add and remove as needed.
// //
void update_trickle_up_urls(PROJECT* p, vector<string> &urls) { void update_trickle_up_urls(PROJECT* p, vector<string> &urls) {
unsigned int i, j; unsigned int i, j;
bool lists_equal = true;
// add new URLs
//
for (i=0; i<urls.size(); i++) { for (i=0; i<urls.size(); i++) {
string& url = urls[i]; string& url = urls[i];
bool found = false; bool found = false;
@ -187,36 +189,31 @@ void update_trickle_up_urls(PROJECT* p, vector<string> &urls) {
} }
} }
if (!found) { if (!found) {
lists_equal = false; p->trickle_up_ops.push_back(new TRICKLE_UP_OP(url));
break; break;
} }
} }
if (lists_equal) {
for (j=0; j<p->trickle_up_ops.size(); j++) { // remove old URLs
TRICKLE_UP_OP *t = p->trickle_up_ops[j]; //
bool found = false; vector<TRICKLE_UP_OP*>::iterator iter = p->trickle_up_ops.begin();
for (i=0; i<urls.size(); i++) { while (iter != p->trickle_up_ops.end()) {
string& url = urls[i]; TRICKLE_UP_OP *t = *iter;
if (t->url == url) { bool found = false;
found = true; for (i=0; i<urls.size(); i++) {
break; string& url = urls[i];
} if (t->url == url) {
} found = true;
if (!found) {
lists_equal = false;
break; break;
} }
} }
} if (!found) {
if (lists_equal) return; gstate.http_ops->remove(&(t->gui_http->http_op));
for (j=0; j<p->trickle_up_ops.size(); j++) { delete t;
TRICKLE_UP_OP *t = p->trickle_up_ops[j]; iter = p->trickle_up_ops.erase(iter);
delete t; } else {
} iter++;
p->trickle_up_ops.clear(); }
for (i=0; i<urls.size(); i++) {
string& url = urls[i];
p->trickle_up_ops.push_back(new TRICKLE_UP_OP(url));
} }
} }

View File

@ -740,7 +740,6 @@ int HTTP_OP_SET::remove(HTTP_OP* p) {
} }
iter++; iter++;
} }
msg_printf(NULL, MSG_INTERNAL_ERROR, "HTTP operation not found");
return ERR_NOT_FOUND; return ERR_NOT_FOUND;
} }