2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-01-20 23:22:22 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2003-07-02 02:02:18 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2003-07-02 02:02:18 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-01-20 23:22:22 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
2002-06-21 06:52:47 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2003-01-02 23:12:05 +00:00
|
|
|
|
2010-05-11 19:10:29 +00:00
|
|
|
#include "cpp.h"
|
|
|
|
|
2004-03-04 11:41:43 +00:00
|
|
|
#ifdef _WIN32
|
2004-06-16 23:16:08 +00:00
|
|
|
#include "boinc_win.h"
|
2010-05-11 19:10:29 +00:00
|
|
|
#else
|
2005-11-21 18:34:44 +00:00
|
|
|
#include "config.h"
|
2004-07-13 13:54:09 +00:00
|
|
|
#include <cmath>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <ctime>
|
2004-03-04 11:41:43 +00:00
|
|
|
#endif
|
2002-06-21 06:52:47 +00:00
|
|
|
|
2007-02-21 16:26:51 +00:00
|
|
|
#include "str_util.h"
|
2009-06-16 20:54:44 +00:00
|
|
|
#include "str_replace.h"
|
2003-01-02 23:12:05 +00:00
|
|
|
#include "util.h"
|
|
|
|
#include "parse.h"
|
|
|
|
#include "error_numbers.h"
|
2005-03-10 22:05:42 +00:00
|
|
|
#include "filesys.h"
|
2003-01-02 23:12:05 +00:00
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
#include "client_state.h"
|
2002-06-21 06:52:47 +00:00
|
|
|
#include "client_types.h"
|
2004-04-08 08:15:23 +00:00
|
|
|
#include "client_msgs.h"
|
2002-06-21 06:52:47 +00:00
|
|
|
#include "file_names.h"
|
|
|
|
#include "log_flags.h"
|
2005-06-11 00:30:11 +00:00
|
|
|
#include "main.h"
|
2002-06-21 06:52:47 +00:00
|
|
|
#include "scheduler_op.h"
|
|
|
|
|
2004-06-30 18:17:21 +00:00
|
|
|
using std::vector;
|
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
SCHEDULER_OP::SCHEDULER_OP(HTTP_OP_SET* h) {
|
2006-07-09 20:59:41 +00:00
|
|
|
cur_proj = NULL;
|
2002-06-21 06:52:47 +00:00
|
|
|
state = SCHEDULER_OP_STATE_IDLE;
|
|
|
|
http_op.http_op_state = HTTP_STATE_IDLE;
|
|
|
|
http_ops = h;
|
|
|
|
}
|
|
|
|
|
2005-05-14 19:45:24 +00:00
|
|
|
// See if there's a pending master file fetch.
|
|
|
|
// If so, start it and return true.
|
2003-05-13 18:55:07 +00:00
|
|
|
//
|
|
|
|
bool SCHEDULER_OP::check_master_fetch_start() {
|
|
|
|
int retval;
|
|
|
|
|
2005-06-01 21:51:32 +00:00
|
|
|
PROJECT* p = gstate.next_project_master_pending();
|
|
|
|
if (!p) return false;
|
|
|
|
retval = init_master_fetch(p);
|
2005-05-16 06:49:07 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(p, MSG_INTERNAL_ERROR,
|
2005-12-06 07:23:12 +00:00
|
|
|
"Couldn't start download of scheduler list: %s", boincerror(retval)
|
2005-05-16 06:49:07 +00:00
|
|
|
);
|
2007-05-14 19:18:45 +00:00
|
|
|
p->master_fetch_failures++;
|
|
|
|
backoff(p, "scheduler list fetch failed\n");
|
2005-05-16 06:49:07 +00:00
|
|
|
return false;
|
2003-05-13 18:55:07 +00:00
|
|
|
}
|
2005-12-06 07:23:12 +00:00
|
|
|
msg_printf(p, MSG_INFO, "Fetching scheduler list");
|
2005-05-16 06:49:07 +00:00
|
|
|
return true;
|
2003-05-13 18:55:07 +00:00
|
|
|
}
|
|
|
|
|
2010-10-20 23:45:49 +00:00
|
|
|
#ifndef SIM
|
|
|
|
|
2005-06-01 21:51:32 +00:00
|
|
|
// try to initiate an RPC to the given project.
|
2005-07-05 08:58:49 +00:00
|
|
|
// If there are multiple schedulers, start with a random one.
|
|
|
|
// User messages and backoff() is done at this level.
|
2002-07-15 05:34:32 +00:00
|
|
|
//
|
2006-08-24 20:33:46 +00:00
|
|
|
int SCHEDULER_OP::init_op_project(PROJECT* p, int r) {
|
2002-07-15 05:34:32 +00:00
|
|
|
int retval;
|
2003-01-02 23:12:05 +00:00
|
|
|
char err_msg[256];
|
2002-07-15 05:34:32 +00:00
|
|
|
|
2005-07-05 08:58:49 +00:00
|
|
|
reason = r;
|
2006-06-22 19:40:30 +00:00
|
|
|
if (log_flags.sched_op_debug) {
|
2007-10-15 22:08:24 +00:00
|
|
|
msg_printf(p, MSG_INFO,
|
2010-04-29 20:32:51 +00:00
|
|
|
"[sched_op] Starting scheduler request"
|
2006-06-22 19:40:30 +00:00
|
|
|
);
|
|
|
|
}
|
2002-07-15 05:34:32 +00:00
|
|
|
|
2005-06-01 05:49:51 +00:00
|
|
|
// if project has no schedulers,
|
|
|
|
// skip everything else and just get its master file.
|
2002-07-15 05:34:32 +00:00
|
|
|
//
|
2005-06-01 21:51:32 +00:00
|
|
|
if (p->scheduler_urls.size() == 0) {
|
|
|
|
retval = init_master_fetch(p);
|
2005-06-01 05:49:51 +00:00
|
|
|
if (retval) {
|
|
|
|
sprintf(err_msg,
|
2005-12-06 07:23:12 +00:00
|
|
|
"Scheduler list fetch initialization failed: %d\n", retval
|
2005-06-01 05:49:51 +00:00
|
|
|
);
|
2005-06-01 21:51:32 +00:00
|
|
|
backoff(p, err_msg);
|
2005-06-01 05:49:51 +00:00
|
|
|
}
|
|
|
|
return retval;
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
2005-06-01 05:49:51 +00:00
|
|
|
|
2006-12-21 16:56:33 +00:00
|
|
|
if (reason == RPC_REASON_INIT) {
|
2009-01-10 00:48:22 +00:00
|
|
|
work_fetch.set_initial_work_request();
|
2006-12-21 16:56:33 +00:00
|
|
|
if (!gstate.cpu_benchmarks_done()) {
|
|
|
|
gstate.cpu_benchmarks_set_defaults();
|
|
|
|
}
|
|
|
|
}
|
2006-08-24 20:33:46 +00:00
|
|
|
|
2005-06-01 05:49:51 +00:00
|
|
|
url_index = 0;
|
2005-06-01 21:51:32 +00:00
|
|
|
retval = gstate.make_scheduler_request(p);
|
2005-06-01 05:49:51 +00:00
|
|
|
if (!retval) {
|
2005-06-01 21:51:32 +00:00
|
|
|
retval = start_rpc(p);
|
2003-01-02 23:12:05 +00:00
|
|
|
}
|
|
|
|
if (retval) {
|
|
|
|
sprintf(err_msg,
|
2006-12-21 16:56:33 +00:00
|
|
|
"scheduler request to %s failed: %s\n",
|
2005-06-29 06:14:35 +00:00
|
|
|
p->get_scheduler_url(url_index, url_random), boincerror(retval)
|
2003-01-02 23:12:05 +00:00
|
|
|
);
|
2005-06-01 21:51:32 +00:00
|
|
|
backoff(p, err_msg);
|
2005-11-10 06:03:39 +00:00
|
|
|
} else {
|
|
|
|
// RPC started OK, so we must have network connectivity.
|
|
|
|
// Now's a good time to check for new BOINC versions
|
2007-03-04 02:30:48 +00:00
|
|
|
// and project list
|
2005-11-10 06:03:39 +00:00
|
|
|
//
|
2010-09-27 20:34:47 +00:00
|
|
|
if (!config.no_info_fetch) {
|
|
|
|
gstate.new_version_check();
|
|
|
|
gstate.all_projects_list_check();
|
|
|
|
}
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
return retval;
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
|
|
|
|
2010-10-20 23:45:49 +00:00
|
|
|
#endif
|
|
|
|
|
2005-01-24 22:13:32 +00:00
|
|
|
// One of the following errors occurred:
|
|
|
|
// - connection failure in fetching master file
|
|
|
|
// - connection failure in scheduler RPC
|
|
|
|
// - got master file, but it didn't have any <scheduler> elements
|
|
|
|
// - tried all schedulers, none responded
|
|
|
|
// - sent nonzero work request, got a reply with no work
|
|
|
|
//
|
|
|
|
// Back off contacting this project's schedulers,
|
|
|
|
// and output an error msg if needed
|
2002-10-16 23:50:41 +00:00
|
|
|
//
|
2007-01-24 22:55:00 +00:00
|
|
|
void SCHEDULER_OP::backoff(PROJECT* p, const char *reason_msg) {
|
2006-12-21 16:56:33 +00:00
|
|
|
char buf[1024];
|
2003-06-09 23:50:49 +00:00
|
|
|
|
2009-02-25 17:41:22 +00:00
|
|
|
if (gstate.in_abort_sequence) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-06-11 22:15:25 +00:00
|
|
|
if (p->master_fetch_failures >= gstate.master_fetch_retry_cap) {
|
2006-12-21 16:56:33 +00:00
|
|
|
sprintf(buf,
|
|
|
|
"%d consecutive failures fetching scheduler list",
|
|
|
|
p->master_fetch_failures
|
2005-12-06 07:23:12 +00:00
|
|
|
);
|
2002-12-02 23:09:45 +00:00
|
|
|
p->master_url_fetch_pending = true;
|
2006-12-21 16:56:33 +00:00
|
|
|
p->set_min_rpc_time(gstate.now + gstate.master_fetch_interval, buf);
|
2005-12-06 03:18:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-06-09 23:50:49 +00:00
|
|
|
|
2005-12-06 03:18:02 +00:00
|
|
|
// if nrpc failures is master_fetch_period,
|
|
|
|
// then set master_url_fetch_pending and initialize again
|
|
|
|
//
|
|
|
|
if (p->nrpc_failures == gstate.master_fetch_period) {
|
|
|
|
p->master_url_fetch_pending = true;
|
|
|
|
p->min_rpc_time = 0;
|
|
|
|
p->nrpc_failures = 0;
|
|
|
|
p->master_fetch_failures++;
|
2002-11-26 00:47:57 +00:00
|
|
|
}
|
2005-12-06 03:18:02 +00:00
|
|
|
|
2006-04-18 23:30:32 +00:00
|
|
|
// if network is down, don't count it as RPC failure
|
|
|
|
//
|
2006-07-17 22:18:17 +00:00
|
|
|
if (!net_status.need_physical_connection) {
|
2006-04-18 23:30:32 +00:00
|
|
|
p->nrpc_failures++;
|
|
|
|
}
|
2006-04-19 04:53:42 +00:00
|
|
|
//msg_printf(p, MSG_INFO, "nrpc_failures %d need_conn %d", p->nrpc_failures, gstate.need_physical_connection);
|
2005-12-06 03:18:02 +00:00
|
|
|
|
|
|
|
int n = p->nrpc_failures;
|
|
|
|
if (n > gstate.retry_cap) n = gstate.retry_cap;
|
|
|
|
double exp_backoff = calculate_exponential_backoff(
|
|
|
|
n, gstate.sched_retry_delay_min, gstate.sched_retry_delay_max
|
|
|
|
);
|
2005-12-06 07:23:12 +00:00
|
|
|
//msg_printf(p, MSG_INFO, "simulating backoff of %f", exp_backoff);
|
2007-01-24 22:55:00 +00:00
|
|
|
p->set_min_rpc_time(gstate.now + exp_backoff, reason_msg);
|
2002-10-16 23:50:41 +00:00
|
|
|
}
|
|
|
|
|
2009-02-10 19:30:59 +00:00
|
|
|
|
|
|
|
// RPC failed, either on startup or later.
|
|
|
|
// If RPC was requested by project or acct mgr, or init,
|
2009-03-04 22:55:57 +00:00
|
|
|
// keep trying (subject to backoff); otherwise give up.
|
|
|
|
// The other cases (results_dur, need_work, project req, and trickle_up)
|
|
|
|
// will be retriggered automatically
|
2009-02-10 19:30:59 +00:00
|
|
|
//
|
2009-02-14 00:05:02 +00:00
|
|
|
void SCHEDULER_OP::rpc_failed(const char* msg) {
|
|
|
|
backoff(cur_proj, msg);
|
2009-02-10 19:30:59 +00:00
|
|
|
switch (cur_proj->sched_rpc_pending) {
|
|
|
|
case RPC_REASON_INIT:
|
|
|
|
case RPC_REASON_ACCT_MGR_REQ:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
cur_proj->sched_rpc_pending = 0;
|
|
|
|
}
|
|
|
|
cur_proj = 0;
|
|
|
|
}
|
|
|
|
|
2010-08-27 18:22:59 +00:00
|
|
|
static void request_string(char* buf) {
|
|
|
|
bool first = true;
|
|
|
|
strcpy(buf, "");
|
2011-03-25 03:44:09 +00:00
|
|
|
for (int i=0; i<coprocs.n_rsc; i++) {
|
|
|
|
if (rsc_work_fetch[i].req_secs) {
|
|
|
|
if (!first) strcat(buf, " and ");
|
2011-04-19 05:14:45 +00:00
|
|
|
strcat(buf, rsc_name(i));
|
2011-03-25 03:44:09 +00:00
|
|
|
first = false;
|
|
|
|
}
|
2010-08-27 18:22:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
// low-level routine to initiate an RPC
|
2003-01-02 23:12:05 +00:00
|
|
|
// If successful, creates an HTTP_OP that must be polled
|
2004-09-22 22:09:54 +00:00
|
|
|
// PRECONDITION: the request file has been created
|
2002-07-15 05:34:32 +00:00
|
|
|
//
|
2005-06-01 21:51:32 +00:00
|
|
|
int SCHEDULER_OP::start_rpc(PROJECT* p) {
|
2002-07-15 05:34:32 +00:00
|
|
|
int retval;
|
2009-06-02 22:53:57 +00:00
|
|
|
char request_file[1024], reply_file[1024], buf[256];
|
2011-04-24 21:33:51 +00:00
|
|
|
const char *trickle_up_msg;
|
2002-06-21 06:52:47 +00:00
|
|
|
|
2005-06-01 21:51:32 +00:00
|
|
|
safe_strcpy(scheduler_url, p->get_scheduler_url(url_index, url_random));
|
2002-06-21 06:52:47 +00:00
|
|
|
if (log_flags.sched_ops) {
|
2006-09-01 22:21:20 +00:00
|
|
|
msg_printf(p, MSG_INFO,
|
2009-01-03 06:01:17 +00:00
|
|
|
"Sending scheduler request: %s.", rpc_reason_string(reason)
|
2006-09-01 22:21:20 +00:00
|
|
|
);
|
2011-04-14 01:04:10 +00:00
|
|
|
if (p->trickle_up_pending && reason != RPC_REASON_TRICKLE_UP) {
|
|
|
|
trickle_up_msg = ", sending trickle-up message";
|
|
|
|
} else {
|
|
|
|
trickle_up_msg = "";
|
|
|
|
}
|
2010-08-27 18:22:59 +00:00
|
|
|
request_string(buf);
|
|
|
|
if (strlen(buf)) {
|
2009-01-22 21:29:09 +00:00
|
|
|
if (p->nresults_returned) {
|
|
|
|
msg_printf(p, MSG_INFO,
|
2011-04-14 01:04:10 +00:00
|
|
|
"Reporting %d completed tasks, requesting new tasks for %s%s",
|
|
|
|
p->nresults_returned, buf, trickle_up_msg
|
2009-01-22 21:29:09 +00:00
|
|
|
);
|
|
|
|
} else {
|
2011-04-14 01:04:10 +00:00
|
|
|
msg_printf(p, MSG_INFO, "Requesting new tasks for %s%s", buf, trickle_up_msg);
|
2009-01-22 21:29:09 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (p->nresults_returned) {
|
|
|
|
msg_printf(p, MSG_INFO,
|
2011-04-14 01:04:10 +00:00
|
|
|
"Reporting %d completed tasks, not requesting new tasks%s",
|
|
|
|
p->nresults_returned, trickle_up_msg
|
2009-01-22 21:29:09 +00:00
|
|
|
);
|
|
|
|
} else {
|
2011-04-14 01:04:10 +00:00
|
|
|
msg_printf(p, MSG_INFO, "Not reporting or requesting tasks%s", trickle_up_msg);
|
2009-01-22 21:29:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (log_flags.sched_op_debug) {
|
2011-03-25 03:44:09 +00:00
|
|
|
for (int i=0; i<coprocs.n_rsc; i++) {
|
2009-09-02 22:14:28 +00:00
|
|
|
msg_printf(p, MSG_INFO,
|
2011-12-16 19:45:31 +00:00
|
|
|
"[sched_op] %s work request: %.2f seconds; %.2f devices",
|
2011-03-25 03:44:09 +00:00
|
|
|
rsc_name(i),
|
|
|
|
rsc_work_fetch[i].req_secs,
|
|
|
|
rsc_work_fetch[i].req_instances
|
2009-01-03 06:01:17 +00:00
|
|
|
);
|
|
|
|
}
|
2002-06-21 06:52:47 +00:00
|
|
|
}
|
2003-07-02 02:02:18 +00:00
|
|
|
|
2007-03-13 19:33:27 +00:00
|
|
|
get_sched_request_filename(*p, request_file, sizeof(request_file));
|
|
|
|
get_sched_reply_filename(*p, reply_file, sizeof(reply_file));
|
2004-09-22 22:09:54 +00:00
|
|
|
|
2009-02-10 19:30:59 +00:00
|
|
|
cur_proj = p;
|
2011-10-18 04:23:03 +00:00
|
|
|
retval = http_op.init_post(p, scheduler_url, request_file, reply_file);
|
2005-06-01 05:49:51 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
if (log_flags.sched_ops) {
|
|
|
|
msg_printf(p, MSG_INFO,
|
2009-03-10 22:14:16 +00:00
|
|
|
"Scheduler request initialization failed: %s", boincerror(retval)
|
2007-01-25 23:39:06 +00:00
|
|
|
);
|
|
|
|
}
|
2009-02-14 00:05:02 +00:00
|
|
|
rpc_failed("Scheduler request initialization failed");
|
2005-06-01 05:49:51 +00:00
|
|
|
return retval;
|
|
|
|
}
|
2009-02-10 19:30:59 +00:00
|
|
|
http_ops->insert(&http_op);
|
2005-06-01 21:51:32 +00:00
|
|
|
p->rpc_seqno++;
|
2002-06-21 06:52:47 +00:00
|
|
|
state = SCHEDULER_OP_STATE_RPC;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
// initiate a fetch of a project's master URL file
|
|
|
|
//
|
2005-06-01 21:51:32 +00:00
|
|
|
int SCHEDULER_OP::init_master_fetch(PROJECT* p) {
|
2002-07-15 05:34:32 +00:00
|
|
|
int retval;
|
2005-03-10 00:43:22 +00:00
|
|
|
char master_filename[256];
|
|
|
|
|
2007-03-13 19:33:27 +00:00
|
|
|
get_master_filename(*p, master_filename, sizeof(master_filename));
|
2002-07-15 05:34:32 +00:00
|
|
|
|
2006-06-22 19:40:30 +00:00
|
|
|
if (log_flags.sched_op_debug) {
|
2010-04-29 20:32:51 +00:00
|
|
|
msg_printf(p, MSG_INFO, "[sched_op] Fetching master file");
|
2006-06-22 19:40:30 +00:00
|
|
|
}
|
2009-02-14 00:05:02 +00:00
|
|
|
cur_proj = p;
|
2011-10-18 04:23:03 +00:00
|
|
|
retval = http_op.init_get(p, p->master_url, master_filename, true);
|
2009-02-14 00:05:02 +00:00
|
|
|
if (retval) {
|
|
|
|
if (log_flags.sched_ops) {
|
|
|
|
msg_printf(p, MSG_INFO,
|
|
|
|
"Master file fetch failed: %s", boincerror(retval)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
rpc_failed("Master file fetch initialization failed");
|
|
|
|
return retval;
|
|
|
|
}
|
2009-02-10 19:30:59 +00:00
|
|
|
http_ops->insert(&http_op);
|
2002-07-15 05:34:32 +00:00
|
|
|
state = SCHEDULER_OP_STATE_GET_MASTER;
|
2002-06-21 06:52:47 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// parse a master file.
|
|
|
|
//
|
2005-06-01 21:51:32 +00:00
|
|
|
int SCHEDULER_OP::parse_master_file(PROJECT* p, vector<std::string> &urls) {
|
2007-01-23 22:29:19 +00:00
|
|
|
char buf[256], buf2[256];
|
2005-03-10 00:43:22 +00:00
|
|
|
char master_filename[256];
|
2005-03-09 23:28:37 +00:00
|
|
|
std::string str;
|
2002-06-21 06:52:47 +00:00
|
|
|
FILE* f;
|
2007-01-23 22:29:19 +00:00
|
|
|
int n;
|
2003-06-09 23:50:49 +00:00
|
|
|
|
2007-03-13 19:33:27 +00:00
|
|
|
get_master_filename(*p, master_filename, sizeof(master_filename));
|
2005-03-10 22:05:42 +00:00
|
|
|
f = boinc_fopen(master_filename, "r");
|
2002-06-21 06:52:47 +00:00
|
|
|
if (!f) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(p, MSG_INTERNAL_ERROR, "Can't open scheduler list file");
|
2002-06-21 06:52:47 +00:00
|
|
|
return ERR_FOPEN;
|
|
|
|
}
|
2005-06-01 21:51:32 +00:00
|
|
|
p->scheduler_urls.clear();
|
2002-06-21 06:52:47 +00:00
|
|
|
while (fgets(buf, 256, f)) {
|
2005-05-05 20:51:54 +00:00
|
|
|
|
|
|
|
// allow for the possibility of > 1 tag per line here
|
|
|
|
// (UMTS may collapse lines)
|
|
|
|
//
|
2005-06-01 21:51:32 +00:00
|
|
|
char* q = buf;
|
|
|
|
while (q && parse_str(q, "<scheduler>", str)) {
|
2007-01-23 22:29:19 +00:00
|
|
|
push_unique(str, urls);
|
2005-06-01 21:51:32 +00:00
|
|
|
q = strstr(q, "</scheduler>");
|
2005-11-04 06:56:06 +00:00
|
|
|
if (q) q += strlen("</scheduler>");
|
2002-06-21 06:52:47 +00:00
|
|
|
}
|
2007-01-23 22:29:19 +00:00
|
|
|
|
|
|
|
// check for new syntax: <link ...>
|
|
|
|
//
|
|
|
|
q = buf;
|
|
|
|
while (q) {
|
2007-04-03 19:35:33 +00:00
|
|
|
n = sscanf(q, "<link rel=\"boinc_scheduler\" href=\"%s", buf2);
|
2007-01-23 22:29:19 +00:00
|
|
|
if (n == 1) {
|
2007-11-12 23:08:43 +00:00
|
|
|
char* q2 = strchr(buf2, '"');
|
2007-06-20 23:16:30 +00:00
|
|
|
if (q2) *q2 = 0;
|
2007-06-13 19:54:24 +00:00
|
|
|
strip_whitespace(buf2);
|
2007-01-23 22:29:19 +00:00
|
|
|
str = string(buf2);
|
|
|
|
push_unique(str, urls);
|
|
|
|
}
|
|
|
|
q = strchr(q, '>');
|
|
|
|
if (q) q = strchr(q, '<');
|
|
|
|
}
|
2002-06-21 06:52:47 +00:00
|
|
|
}
|
2002-08-29 04:19:51 +00:00
|
|
|
fclose(f);
|
2006-06-22 19:40:30 +00:00
|
|
|
if (log_flags.sched_op_debug) {
|
2007-10-15 22:08:24 +00:00
|
|
|
msg_printf(p, MSG_INFO,
|
2010-04-29 20:32:51 +00:00
|
|
|
"[sched_op] Found %d scheduler URLs in master file\n",
|
2006-06-22 19:40:30 +00:00
|
|
|
(int)urls.size()
|
|
|
|
);
|
|
|
|
}
|
2003-06-09 23:50:49 +00:00
|
|
|
|
2005-03-10 00:43:22 +00:00
|
|
|
// couldn't find any scheduler URLs in the master file?
|
2003-01-02 23:12:05 +00:00
|
|
|
//
|
|
|
|
if ((int) urls.size() == 0) {
|
2009-02-10 19:33:46 +00:00
|
|
|
p->sched_rpc_pending = 0;
|
2003-10-21 18:18:41 +00:00
|
|
|
return ERR_XML_PARSE;
|
2003-01-02 23:12:05 +00:00
|
|
|
}
|
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
// A master file has just been read.
|
2005-03-09 23:28:37 +00:00
|
|
|
// transfer scheduler URLs to project.
|
2002-07-15 05:34:32 +00:00
|
|
|
// Return true if any of them is new
|
|
|
|
//
|
2005-06-01 21:51:32 +00:00
|
|
|
bool SCHEDULER_OP::update_urls(PROJECT* p, vector<std::string> &urls) {
|
2002-07-15 05:34:32 +00:00
|
|
|
unsigned int i, j;
|
|
|
|
bool found, any_new;
|
|
|
|
|
|
|
|
any_new = false;
|
|
|
|
for (i=0; i<urls.size(); i++) {
|
|
|
|
found = false;
|
2005-06-01 21:51:32 +00:00
|
|
|
for (j=0; j<p->scheduler_urls.size(); j++) {
|
|
|
|
if (urls[i] == p->scheduler_urls[j]) {
|
2002-07-15 05:34:32 +00:00
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) any_new = true;
|
|
|
|
}
|
|
|
|
|
2005-06-01 21:51:32 +00:00
|
|
|
p->scheduler_urls.clear();
|
2002-07-15 05:34:32 +00:00
|
|
|
for (i=0; i<urls.size(); i++) {
|
2005-06-01 21:51:32 +00:00
|
|
|
p->scheduler_urls.push_back(urls[i]);
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return any_new;
|
|
|
|
}
|
|
|
|
|
2010-10-20 23:45:49 +00:00
|
|
|
#ifndef SIM
|
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
// poll routine. If an operation is in progress, check for completion
|
|
|
|
//
|
2002-08-22 22:28:51 +00:00
|
|
|
bool SCHEDULER_OP::poll() {
|
2008-12-31 23:07:59 +00:00
|
|
|
int retval;
|
2005-03-09 23:28:37 +00:00
|
|
|
vector<std::string> urls;
|
2009-02-09 22:00:31 +00:00
|
|
|
bool changed;
|
2002-06-21 06:52:47 +00:00
|
|
|
|
|
|
|
switch(state) {
|
|
|
|
case SCHEDULER_OP_STATE_GET_MASTER:
|
2002-07-15 05:34:32 +00:00
|
|
|
// here we're fetching the master file for a project
|
|
|
|
//
|
2002-06-21 06:52:47 +00:00
|
|
|
if (http_op.http_op_state == HTTP_STATE_DONE) {
|
2005-06-01 21:51:32 +00:00
|
|
|
state = SCHEDULER_OP_STATE_IDLE;
|
|
|
|
cur_proj->master_url_fetch_pending = false;
|
2002-06-21 06:52:47 +00:00
|
|
|
http_ops->remove(&http_op);
|
2002-07-15 05:34:32 +00:00
|
|
|
if (http_op.http_op_retval == 0) {
|
2006-06-22 19:40:30 +00:00
|
|
|
if (log_flags.sched_op_debug) {
|
2007-10-15 22:08:24 +00:00
|
|
|
msg_printf(cur_proj, MSG_INFO,
|
2010-04-29 20:32:51 +00:00
|
|
|
"[sched_op] Got master file; parsing"
|
2006-06-22 19:40:30 +00:00
|
|
|
);
|
|
|
|
}
|
2005-06-01 21:51:32 +00:00
|
|
|
retval = parse_master_file(cur_proj, urls);
|
2005-06-11 00:30:11 +00:00
|
|
|
if (retval || (urls.size()==0)) {
|
2003-01-02 23:12:05 +00:00
|
|
|
// master file parse failed.
|
|
|
|
//
|
2007-05-14 19:18:45 +00:00
|
|
|
cur_proj->master_fetch_failures++;
|
2009-02-14 00:05:02 +00:00
|
|
|
rpc_failed("Couldn't parse scheduler list");
|
2003-01-02 23:12:05 +00:00
|
|
|
} else {
|
2005-06-01 21:51:32 +00:00
|
|
|
// parse succeeded
|
|
|
|
//
|
2006-08-24 20:33:46 +00:00
|
|
|
msg_printf(cur_proj, MSG_INFO, "Master file download succeeded");
|
2005-06-01 21:51:32 +00:00
|
|
|
cur_proj->master_fetch_failures = 0;
|
|
|
|
changed = update_urls(cur_proj, urls);
|
2011-01-06 23:09:13 +00:00
|
|
|
|
2005-06-01 21:51:32 +00:00
|
|
|
// reenable scheduler RPCs if have new URLs
|
2003-01-02 23:12:05 +00:00
|
|
|
//
|
2002-07-15 05:34:32 +00:00
|
|
|
if (changed) {
|
2005-06-01 21:51:32 +00:00
|
|
|
cur_proj->min_rpc_time = 0;
|
|
|
|
cur_proj->nrpc_failures = 0;
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
}
|
2002-07-15 05:34:32 +00:00
|
|
|
} else {
|
2003-01-02 23:12:05 +00:00
|
|
|
// master file fetch failed.
|
2002-07-15 05:34:32 +00:00
|
|
|
//
|
2007-05-14 19:18:45 +00:00
|
|
|
char buf[256];
|
|
|
|
sprintf(buf, "Scheduler list fetch failed: %s",
|
|
|
|
boincerror(http_op.http_op_retval)
|
|
|
|
);
|
|
|
|
cur_proj->master_fetch_failures++;
|
2009-02-14 00:05:02 +00:00
|
|
|
rpc_failed("Master file request failed");
|
2003-01-02 23:12:05 +00:00
|
|
|
}
|
2009-04-15 06:22:53 +00:00
|
|
|
gstate.set_client_state_dirty("Master fetch complete");
|
2006-07-19 20:19:18 +00:00
|
|
|
gstate.request_work_fetch("Master fetch complete");
|
2005-06-01 21:51:32 +00:00
|
|
|
cur_proj = NULL;
|
|
|
|
return true;
|
2002-06-21 06:52:47 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCHEDULER_OP_STATE_RPC:
|
2003-01-02 23:12:05 +00:00
|
|
|
|
|
|
|
// here we're doing a scheduler RPC
|
2002-07-15 05:34:32 +00:00
|
|
|
//
|
2002-06-21 06:52:47 +00:00
|
|
|
if (http_op.http_op_state == HTTP_STATE_DONE) {
|
2005-06-01 21:51:32 +00:00
|
|
|
state = SCHEDULER_OP_STATE_IDLE;
|
2002-06-21 06:52:47 +00:00
|
|
|
http_ops->remove(&http_op);
|
2002-07-15 05:34:32 +00:00
|
|
|
if (http_op.http_op_retval) {
|
2003-07-01 22:44:58 +00:00
|
|
|
if (log_flags.sched_ops) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(cur_proj, MSG_INFO,
|
2006-04-19 04:53:42 +00:00
|
|
|
"Scheduler request failed: %s", http_op.error_msg
|
2002-07-15 05:34:32 +00:00
|
|
|
);
|
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
|
|
|
|
// scheduler RPC failed. Try another scheduler if one exists
|
|
|
|
//
|
2005-06-01 05:49:51 +00:00
|
|
|
while (1) {
|
|
|
|
url_index++;
|
2005-06-07 21:46:11 +00:00
|
|
|
if (url_index == (int)cur_proj->scheduler_urls.size()) {
|
|
|
|
break;
|
|
|
|
}
|
2005-06-01 21:51:32 +00:00
|
|
|
retval = start_rpc(cur_proj);
|
|
|
|
if (!retval) return true;
|
2005-06-01 05:49:51 +00:00
|
|
|
}
|
2005-06-07 21:46:11 +00:00
|
|
|
if (url_index == (int) cur_proj->scheduler_urls.size()) {
|
2009-02-14 00:05:02 +00:00
|
|
|
rpc_failed("Scheduler request failed");
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
|
|
|
} else {
|
2008-12-31 23:07:59 +00:00
|
|
|
retval = gstate.handle_scheduler_reply(cur_proj, scheduler_url);
|
2007-05-14 19:18:45 +00:00
|
|
|
switch (retval) {
|
2007-07-06 23:09:59 +00:00
|
|
|
case 0:
|
|
|
|
break;
|
2007-05-14 19:18:45 +00:00
|
|
|
case ERR_PROJECT_DOWN:
|
|
|
|
backoff(cur_proj, "project is down");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
backoff(cur_proj, "can't parse scheduler reply");
|
|
|
|
break;
|
2003-01-02 23:12:05 +00:00
|
|
|
}
|
2011-01-06 23:09:13 +00:00
|
|
|
cur_proj->sched_rpc_pending = 0;
|
2009-02-09 22:00:31 +00:00
|
|
|
// do this after handle_scheduler_reply()
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
2005-06-01 21:51:32 +00:00
|
|
|
cur_proj = NULL;
|
2009-04-15 06:22:53 +00:00
|
|
|
gstate.set_client_state_dirty("RPC complete");
|
2006-07-10 00:46:07 +00:00
|
|
|
gstate.request_work_fetch("RPC complete");
|
2005-06-01 21:51:32 +00:00
|
|
|
return true;
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
2005-06-01 21:51:32 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
|
2010-10-20 23:45:49 +00:00
|
|
|
#endif
|
|
|
|
|
2005-06-01 21:51:32 +00:00
|
|
|
void SCHEDULER_OP::abort(PROJECT* p) {
|
|
|
|
if (state != SCHEDULER_OP_STATE_IDLE && cur_proj == p) {
|
|
|
|
gstate.http_ops->remove(&http_op);
|
|
|
|
state = SCHEDULER_OP_STATE_IDLE;
|
|
|
|
cur_proj = NULL;
|
2002-06-21 06:52:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-20 23:45:49 +00:00
|
|
|
void SCHEDULER_REPLY::clear() {
|
|
|
|
hostid = 0;
|
|
|
|
request_delay = 0;
|
|
|
|
next_rpc_delay = 0;
|
2002-09-29 00:32:11 +00:00
|
|
|
global_prefs_xml = 0;
|
|
|
|
project_prefs_xml = 0;
|
2002-07-07 20:39:24 +00:00
|
|
|
code_sign_key = 0;
|
|
|
|
code_sign_key_signature = 0;
|
2010-10-20 23:45:49 +00:00
|
|
|
strcpy(master_url, "");
|
|
|
|
code_sign_key = 0;
|
|
|
|
code_sign_key_signature = 0;
|
|
|
|
message_ack = false;
|
|
|
|
project_is_down = false;
|
|
|
|
send_full_workload = false;
|
|
|
|
send_time_stats_log = 0;
|
|
|
|
send_job_log = 0;
|
|
|
|
messages.clear();
|
|
|
|
scheduler_version = 0;
|
|
|
|
got_rss_feeds = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SCHEDULER_REPLY::SCHEDULER_REPLY() {
|
|
|
|
clear();
|
2002-07-07 20:39:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SCHEDULER_REPLY::~SCHEDULER_REPLY() {
|
2002-09-29 00:32:11 +00:00
|
|
|
if (global_prefs_xml) free(global_prefs_xml);
|
|
|
|
if (project_prefs_xml) free(project_prefs_xml);
|
2002-07-07 20:39:24 +00:00
|
|
|
if (code_sign_key) free(code_sign_key);
|
|
|
|
if (code_sign_key_signature) free(code_sign_key_signature);
|
|
|
|
}
|
|
|
|
|
2010-10-20 23:45:49 +00:00
|
|
|
#ifndef SIM
|
|
|
|
|
2011-03-25 03:44:09 +00:00
|
|
|
static void handle_no_rsc_apps(const char* name, PROJECT* p, bool value) {
|
|
|
|
int i = rsc_index(name);
|
|
|
|
if (i < 0) return;
|
|
|
|
p->no_rsc_apps[i] = value;
|
|
|
|
}
|
|
|
|
|
2004-09-27 22:55:56 +00:00
|
|
|
// parse a scheduler reply.
|
|
|
|
// Some of the items go into the SCHEDULER_REPLY object.
|
|
|
|
// Others are copied straight to the PROJECT
|
|
|
|
//
|
2003-07-03 05:01:29 +00:00
|
|
|
int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) {
|
2011-08-11 06:17:33 +00:00
|
|
|
char buf[256], msg_buf[1024], pri_buf[256], attr_buf[256];
|
2005-08-17 22:08:35 +00:00
|
|
|
int retval;
|
2004-06-12 04:45:36 +00:00
|
|
|
MIOFILE mf;
|
2011-08-09 21:44:14 +00:00
|
|
|
XML_PARSER xp(&mf);
|
2005-03-09 23:28:37 +00:00
|
|
|
std::string delete_file_name;
|
2011-08-09 21:44:14 +00:00
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
mf.init_file(in);
|
2010-11-10 20:23:20 +00:00
|
|
|
bool found_start_tag = false, btemp;
|
2007-09-03 23:00:22 +00:00
|
|
|
double cpid_time = 0;
|
2002-08-15 21:21:08 +00:00
|
|
|
|
2010-10-20 23:45:49 +00:00
|
|
|
clear();
|
2008-05-15 23:05:28 +00:00
|
|
|
strcpy(host_venue, project->host_venue);
|
|
|
|
// the project won't send us a venue if it's doing maintenance
|
|
|
|
// or doesn't check the DB because no work.
|
|
|
|
// Don't overwrite the host venue in that case.
|
2009-12-21 17:49:28 +00:00
|
|
|
sr_feeds.clear();
|
2011-09-20 18:49:38 +00:00
|
|
|
trickle_up_urls.clear();
|
2002-06-21 06:52:47 +00:00
|
|
|
|
2004-10-15 19:19:03 +00:00
|
|
|
// First line should either be tag (HTTP 1.0) or
|
2002-08-12 21:54:19 +00:00
|
|
|
// hex length of response (HTTP 1.1)
|
2004-10-15 19:19:03 +00:00
|
|
|
//
|
2011-08-11 06:17:33 +00:00
|
|
|
while (!xp.get_tag(attr_buf, sizeof(attr_buf))) {
|
2004-10-15 19:19:03 +00:00
|
|
|
if (!found_start_tag) {
|
2011-08-11 06:17:33 +00:00
|
|
|
if (xp.match_tag("scheduler_reply")) {
|
2004-10-15 19:19:03 +00:00
|
|
|
found_start_tag = true;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2011-08-11 06:17:33 +00:00
|
|
|
if (xp.match_tag("/scheduler_reply")) {
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-13 23:28:47 +00:00
|
|
|
// update statistics after parsing the scheduler reply
|
2006-05-21 21:11:28 +00:00
|
|
|
// add new record if vector is empty or we have a new day
|
|
|
|
//
|
2005-04-13 23:28:47 +00:00
|
|
|
if (project->statistics.empty() || project->statistics.back().day!=dday()) {
|
2010-11-19 17:12:10 +00:00
|
|
|
double cutoff = dday() - config.save_stats_days*86400;
|
|
|
|
// delete old stats; fill in the gaps if some days missing
|
|
|
|
//
|
2006-05-17 01:48:39 +00:00
|
|
|
while (!project->statistics.empty()) {
|
|
|
|
DAILY_STATS& ds = project->statistics[0];
|
2010-11-19 17:12:10 +00:00
|
|
|
if (ds.day >= cutoff) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (project->statistics.size() > 1) {
|
|
|
|
DAILY_STATS& ds2 = project->statistics[1];
|
|
|
|
if (ds2.day <= cutoff) {
|
|
|
|
project->statistics.erase(project->statistics.begin());
|
|
|
|
} else {
|
|
|
|
ds.day = cutoff;
|
|
|
|
break;
|
|
|
|
}
|
2006-05-17 01:48:39 +00:00
|
|
|
} else {
|
2010-11-19 17:12:10 +00:00
|
|
|
ds.day = cutoff;
|
2006-05-17 01:48:39 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-04-13 23:28:47 +00:00
|
|
|
}
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-08-11 04:45:16 +00:00
|
|
|
DAILY_STATS nds;
|
|
|
|
project->statistics.push_back(nds);
|
2005-04-13 23:28:47 +00:00
|
|
|
}
|
2005-08-11 04:45:16 +00:00
|
|
|
DAILY_STATS& ds = project->statistics.back();
|
|
|
|
ds.day=dday();
|
|
|
|
ds.user_total_credit=project->user_total_credit;
|
|
|
|
ds.user_expavg_credit=project->user_expavg_credit;
|
|
|
|
ds.host_total_credit=project->host_total_credit;
|
|
|
|
ds.host_expavg_credit=project->host_expavg_credit;
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-13 23:28:47 +00:00
|
|
|
project->write_statistics_file();
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2007-09-03 23:00:22 +00:00
|
|
|
if (cpid_time) {
|
|
|
|
project->cpid_time = cpid_time;
|
|
|
|
} else {
|
|
|
|
project->cpid_time = project->user_create_time;
|
|
|
|
}
|
2005-04-13 18:38:55 +00:00
|
|
|
return 0;
|
2005-02-18 23:43:28 +00:00
|
|
|
}
|
2011-08-11 06:17:33 +00:00
|
|
|
else if (xp.parse_str("project_name", project->project_name, sizeof(project->project_name))) {
|
2006-03-07 23:21:30 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-08-11 06:17:33 +00:00
|
|
|
else if (xp.parse_str("master_url", master_url, sizeof(master_url))) {
|
2006-03-07 21:58:14 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-08-11 06:17:33 +00:00
|
|
|
else if (xp.parse_str("symstore", project->symstore, sizeof(project->symstore))) continue;
|
|
|
|
else if (xp.parse_str("user_name", project->user_name, sizeof(project->user_name))) continue;
|
|
|
|
else if (xp.parse_double("user_total_credit", project->user_total_credit)) continue;
|
|
|
|
else if (xp.parse_double("user_expavg_credit", project->user_expavg_credit)) continue;
|
|
|
|
else if (xp.parse_double("user_create_time", project->user_create_time)) continue;
|
|
|
|
else if (xp.parse_double("cpid_time", cpid_time)) continue;
|
|
|
|
else if (xp.parse_str("team_name", project->team_name, sizeof(project->team_name))) continue;
|
|
|
|
else if (xp.parse_int("hostid", hostid)) continue;
|
|
|
|
else if (xp.parse_double("host_total_credit", project->host_total_credit)) continue;
|
|
|
|
else if (xp.parse_double("host_expavg_credit", project->host_expavg_credit)) continue;
|
|
|
|
else if (xp.parse_str("host_venue", host_venue, sizeof(host_venue))) continue;
|
|
|
|
else if (xp.parse_double("host_create_time", project->host_create_time)) continue;
|
|
|
|
else if (xp.parse_double("request_delay", request_delay)) continue;
|
|
|
|
else if (xp.parse_double("next_rpc_delay", next_rpc_delay)) continue;
|
|
|
|
else if (xp.match_tag("global_preferences")) {
|
2003-02-11 19:41:08 +00:00
|
|
|
retval = dup_element_contents(
|
2011-08-11 06:17:33 +00:00
|
|
|
xp.f->f,
|
2003-02-11 00:52:44 +00:00
|
|
|
"</global_preferences>",
|
2003-02-11 19:41:08 +00:00
|
|
|
&global_prefs_xml
|
2003-02-11 00:52:44 +00:00
|
|
|
);
|
2006-03-02 22:51:41 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-03-02 22:51:41 +00:00
|
|
|
"Can't parse global prefs in scheduler reply: %s",
|
|
|
|
boincerror(retval)
|
|
|
|
);
|
|
|
|
return retval;
|
|
|
|
}
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("project_preferences")) {
|
2003-02-11 19:41:08 +00:00
|
|
|
retval = dup_element_contents(
|
2011-08-11 06:17:33 +00:00
|
|
|
xp.f->f,
|
2003-02-11 00:52:44 +00:00
|
|
|
"</project_preferences>",
|
2003-02-11 19:41:08 +00:00
|
|
|
&project_prefs_xml
|
2003-02-11 00:52:44 +00:00
|
|
|
);
|
2006-03-02 22:51:41 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-03-02 22:51:41 +00:00
|
|
|
"Can't parse project prefs in scheduler reply: %s",
|
|
|
|
boincerror(retval)
|
|
|
|
);
|
|
|
|
return retval;
|
|
|
|
}
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("gui_urls")) {
|
2004-09-27 19:44:40 +00:00
|
|
|
std::string foo;
|
2011-08-11 06:17:33 +00:00
|
|
|
retval = copy_element_contents(xp.f->f, "</gui_urls>", foo);
|
2006-03-02 22:51:41 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-03-02 22:51:41 +00:00
|
|
|
"Can't parse GUI URLs in scheduler reply: %s",
|
|
|
|
boincerror(retval)
|
|
|
|
);
|
|
|
|
return retval;
|
2004-09-27 19:44:40 +00:00
|
|
|
}
|
2006-03-02 22:51:41 +00:00
|
|
|
project->gui_urls = "<gui_urls>\n"+foo+"</gui_urls>\n";
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("code_sign_key")) {
|
2003-02-11 19:41:08 +00:00
|
|
|
retval = dup_element_contents(
|
2011-08-11 06:17:33 +00:00
|
|
|
xp.f->f,
|
2003-02-11 00:52:44 +00:00
|
|
|
"</code_sign_key>",
|
2003-02-11 19:41:08 +00:00
|
|
|
&code_sign_key
|
2003-02-11 00:52:44 +00:00
|
|
|
);
|
2002-07-11 01:09:53 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't parse code sign key in scheduler reply: %s",
|
|
|
|
boincerror(retval)
|
2005-02-23 06:19:20 +00:00
|
|
|
);
|
2002-07-11 01:09:53 +00:00
|
|
|
return ERR_XML_PARSE;
|
2002-08-25 07:54:33 +00:00
|
|
|
}
|
2011-08-31 16:36:17 +00:00
|
|
|
strip_whitespace(code_sign_key);
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("code_sign_key_signature")) {
|
2003-02-11 19:41:08 +00:00
|
|
|
retval = dup_element_contents(
|
2011-08-11 06:17:33 +00:00
|
|
|
xp.f->f,
|
2003-02-11 00:52:44 +00:00
|
|
|
"</code_sign_key_signature>",
|
2003-02-11 19:41:08 +00:00
|
|
|
&code_sign_key_signature
|
2003-02-11 00:52:44 +00:00
|
|
|
);
|
2006-03-02 22:51:41 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-03-02 22:51:41 +00:00
|
|
|
"Can't parse code sign key signature in scheduler reply: %s",
|
|
|
|
boincerror(retval)
|
|
|
|
);
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("app")) {
|
2002-06-21 06:52:47 +00:00
|
|
|
APP app;
|
2011-08-09 21:44:14 +00:00
|
|
|
retval = app.parse(xp);
|
2004-08-12 12:44:55 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't parse application in scheduler reply: %s",
|
|
|
|
boincerror(retval)
|
2005-02-23 06:19:20 +00:00
|
|
|
);
|
2004-08-12 12:44:55 +00:00
|
|
|
} else {
|
|
|
|
apps.push_back(app);
|
|
|
|
}
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("file_info")) {
|
2002-06-21 06:52:47 +00:00
|
|
|
FILE_INFO file_info;
|
2011-08-09 21:44:14 +00:00
|
|
|
retval = file_info.parse(xp);
|
2004-08-12 12:44:55 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't parse file info in scheduler reply: %s",
|
|
|
|
boincerror(retval)
|
2005-02-23 06:19:20 +00:00
|
|
|
);
|
2004-08-12 12:44:55 +00:00
|
|
|
} else {
|
|
|
|
file_infos.push_back(file_info);
|
|
|
|
}
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("app_version")) {
|
2002-06-21 06:52:47 +00:00
|
|
|
APP_VERSION av;
|
2011-08-09 21:44:14 +00:00
|
|
|
retval = av.parse(xp);
|
2004-08-12 12:44:55 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't parse application version in scheduler reply: %s",
|
|
|
|
boincerror(retval)
|
2005-02-23 06:19:20 +00:00
|
|
|
);
|
2004-08-12 12:44:55 +00:00
|
|
|
} else {
|
|
|
|
app_versions.push_back(av);
|
|
|
|
}
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("workunit")) {
|
2002-06-21 06:52:47 +00:00
|
|
|
WORKUNIT wu;
|
2011-08-09 21:44:14 +00:00
|
|
|
retval = wu.parse(xp);
|
2004-08-12 12:44:55 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't parse workunit in scheduler reply: %s",
|
|
|
|
boincerror(retval)
|
2005-02-23 06:19:20 +00:00
|
|
|
);
|
2004-08-12 12:44:55 +00:00
|
|
|
} else {
|
|
|
|
workunits.push_back(wu);
|
|
|
|
}
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("result")) {
|
2002-06-21 06:52:47 +00:00
|
|
|
RESULT result; // make sure this is here so constructor
|
|
|
|
// gets called each time
|
2011-08-09 21:44:14 +00:00
|
|
|
retval = result.parse_server(xp);
|
2004-08-12 12:44:55 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't parse task in scheduler reply: %s",
|
|
|
|
boincerror(retval)
|
2005-02-23 06:19:20 +00:00
|
|
|
);
|
2004-08-12 12:44:55 +00:00
|
|
|
} else {
|
|
|
|
results.push_back(result);
|
|
|
|
}
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("result_ack")) {
|
2002-06-21 06:52:47 +00:00
|
|
|
RESULT result;
|
2011-08-11 06:17:33 +00:00
|
|
|
retval = result.parse_name(xp, "/result_ack");
|
2004-08-12 12:44:55 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"Can't parse ack in scheduler reply: %s",
|
|
|
|
boincerror(retval)
|
2005-02-23 06:19:20 +00:00
|
|
|
);
|
2004-08-12 12:44:55 +00:00
|
|
|
} else {
|
|
|
|
result_acks.push_back(result);
|
|
|
|
}
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("result_abort")) {
|
2006-05-25 20:10:08 +00:00
|
|
|
RESULT result;
|
2011-08-11 06:17:33 +00:00
|
|
|
retval = result.parse_name(xp, "/result_abort");
|
2006-05-25 20:10:08 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-05-25 20:10:08 +00:00
|
|
|
"Can't parse result abort in scheduler reply: %s",
|
|
|
|
boincerror(retval)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
result_abort.push_back(result);
|
|
|
|
}
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("result_abort_if_not_started")) {
|
2006-05-25 20:10:08 +00:00
|
|
|
RESULT result;
|
2011-08-11 06:17:33 +00:00
|
|
|
retval = result.parse_name(xp, "/result_abort_if_not_started");
|
2006-05-25 20:10:08 +00:00
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2007-03-22 02:38:45 +00:00
|
|
|
"Can't parse result abort-if-not-started in scheduler reply: %s",
|
2006-05-25 20:10:08 +00:00
|
|
|
boincerror(retval)
|
|
|
|
);
|
|
|
|
} else {
|
2007-03-22 02:38:45 +00:00
|
|
|
result_abort_if_not_started.push_back(result);
|
2006-05-25 20:10:08 +00:00
|
|
|
}
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_string("delete_file_info", delete_file_name)) {
|
2005-03-09 23:28:37 +00:00
|
|
|
file_deletes.push_back(delete_file_name);
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_str("message", msg_buf, sizeof(msg_buf))) {
|
|
|
|
parse_attr(attr_buf, "priority", pri_buf, sizeof(pri_buf));
|
2005-01-31 22:19:03 +00:00
|
|
|
USER_MESSAGE um(msg_buf, pri_buf);
|
|
|
|
messages.push_back(um);
|
2002-06-21 06:52:47 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_bool("message_ack", message_ack)) {
|
2010-05-13 22:19:02 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_bool("project_is_down", project_is_down)) {
|
2010-05-13 22:19:02 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_str("email_hash", project->email_hash, sizeof(project->email_hash))) {
|
2004-04-19 20:56:57 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_str("cross_project_id", project->cross_project_id, sizeof(project->cross_project_id))) {
|
2004-04-19 20:56:57 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("trickle_down")) {
|
2004-05-15 22:09:26 +00:00
|
|
|
retval = gstate.handle_trickle_down(project, in);
|
|
|
|
if (retval) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR,
|
2006-01-17 22:48:09 +00:00
|
|
|
"handle_trickle_down failed: %s", boincerror(retval)
|
2005-02-23 06:19:20 +00:00
|
|
|
);
|
2004-05-15 22:09:26 +00:00
|
|
|
}
|
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_bool("non_cpu_intensive", project->non_cpu_intensive)) {
|
2004-05-18 18:33:01 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_bool("ended", project->ended)) {
|
2007-05-24 16:07:21 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_bool("no_cpu_apps", btemp)) {
|
2010-11-10 20:23:20 +00:00
|
|
|
if (!project->anonymous_platform) {
|
2011-03-25 03:44:09 +00:00
|
|
|
handle_no_rsc_apps("CPU", project, btemp);
|
2010-11-10 20:23:20 +00:00
|
|
|
}
|
2010-11-09 19:04:24 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_bool("no_cuda_apps", btemp)) {
|
2010-11-10 20:23:20 +00:00
|
|
|
if (!project->anonymous_platform) {
|
2011-08-31 11:08:13 +00:00
|
|
|
handle_no_rsc_apps(GPU_TYPE_NVIDIA, project, btemp);
|
2010-11-10 20:23:20 +00:00
|
|
|
}
|
2010-11-09 19:04:24 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_bool("no_ati_apps", btemp)) {
|
2010-11-10 20:23:20 +00:00
|
|
|
if (!project->anonymous_platform) {
|
2011-08-31 11:08:13 +00:00
|
|
|
handle_no_rsc_apps(GPU_TYPE_ATI, project, btemp);
|
2011-03-25 03:44:09 +00:00
|
|
|
}
|
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_str("no_rsc_apps", buf, sizeof(buf))) {
|
2011-03-25 03:44:09 +00:00
|
|
|
if (!project->anonymous_platform) {
|
|
|
|
handle_no_rsc_apps(buf, project, btemp);
|
2010-11-10 20:23:20 +00:00
|
|
|
}
|
2010-11-09 19:04:24 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_bool("verify_files_on_app_start", project->verify_files_on_app_start)) {
|
2006-06-20 17:36:28 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_bool("send_full_workload", send_full_workload)) {
|
2010-05-13 22:19:02 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_int("send_time_stats_log", send_time_stats_log)){
|
2007-04-13 22:55:18 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_int("send_job_log", send_job_log)) {
|
2007-04-13 22:55:18 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_int("scheduler_version", scheduler_version)) {
|
2006-06-23 20:05:12 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("project_files")) {
|
2011-08-09 21:44:14 +00:00
|
|
|
retval = project->parse_project_files(xp, true);
|
2006-12-17 03:34:31 +00:00
|
|
|
#ifdef ENABLE_AUTO_UPDATE
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("auto_update")) {
|
2011-08-09 21:44:14 +00:00
|
|
|
retval = auto_update.parse(xp);
|
2006-12-21 16:56:33 +00:00
|
|
|
if (!retval) auto_update.present = true;
|
2006-12-19 17:41:30 +00:00
|
|
|
#endif
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.match_tag("rss_feeds")) {
|
2009-12-23 00:58:27 +00:00
|
|
|
got_rss_feeds = true;
|
2011-09-20 18:49:38 +00:00
|
|
|
parse_rss_feed_descs(xp, sr_feeds);
|
|
|
|
continue;
|
|
|
|
} else if (xp.match_tag("trickle_up_urls")) {
|
|
|
|
parse_trickle_up_urls(xp, trickle_up_urls);
|
2010-09-08 20:20:02 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_int("userid", project->userid)) {
|
2011-02-23 20:47:25 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else if (xp.parse_int("teamid", project->teamid)) {
|
2011-02-23 20:47:25 +00:00
|
|
|
continue;
|
2011-08-11 06:17:33 +00:00
|
|
|
} else {
|
2006-06-22 19:40:30 +00:00
|
|
|
if (log_flags.unparsed_xml) {
|
2009-02-23 04:54:04 +00:00
|
|
|
msg_printf(project, MSG_INFO,
|
2011-08-11 06:17:33 +00:00
|
|
|
"[unparsed_xml] SCHEDULER_REPLY::parse(): unrecognized %s\n",
|
|
|
|
xp.parsed_tag
|
2006-06-22 19:40:30 +00:00
|
|
|
);
|
|
|
|
}
|
2002-06-21 06:52:47 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-15 19:19:03 +00:00
|
|
|
if (found_start_tag) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR, "No close tag in scheduler reply");
|
2004-10-15 19:19:03 +00:00
|
|
|
} else {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(project, MSG_INTERNAL_ERROR, "No start tag in scheduler reply");
|
2004-10-15 19:19:03 +00:00
|
|
|
}
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
2010-10-20 23:45:49 +00:00
|
|
|
#endif
|
2004-12-08 00:40:19 +00:00
|
|
|
|
2005-01-31 22:19:03 +00:00
|
|
|
USER_MESSAGE::USER_MESSAGE(char* m, char* p) {
|
|
|
|
message = m;
|
|
|
|
priority = p;
|
|
|
|
}
|
|
|
|
|