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
|
|
|
|
2004-03-04 11:41:43 +00:00
|
|
|
#ifdef _WIN32
|
2004-06-16 23:16:08 +00:00
|
|
|
#include "boinc_win.h"
|
2004-03-04 11:41:43 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
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"
|
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"
|
|
|
|
|
2006-12-17 03:34:31 +00:00
|
|
|
//#define ENABLE_AUTO_UPDATE
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
"[sched_op_debug] 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
|
|
|
//
|
|
|
|
gstate.new_version_check();
|
2007-03-19 19:13:40 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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];
|
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
|
|
|
);
|
2009-01-22 21:29:09 +00:00
|
|
|
if (cpu_work_fetch.req_secs || cuda_work_fetch.req_secs) {
|
2009-06-02 22:53:57 +00:00
|
|
|
if (coproc_cuda) {
|
|
|
|
if (cpu_work_fetch.req_secs && cuda_work_fetch.req_secs) {
|
|
|
|
sprintf(buf, " for CPU and GPU");
|
|
|
|
} else if (cpu_work_fetch.req_secs) {
|
|
|
|
sprintf(buf, " for CPU");
|
|
|
|
} else {
|
|
|
|
sprintf(buf, " for GPU");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
strcpy(buf, "");
|
|
|
|
}
|
2009-01-22 21:29:09 +00:00
|
|
|
if (p->nresults_returned) {
|
|
|
|
msg_printf(p, MSG_INFO,
|
2009-06-02 22:53:57 +00:00
|
|
|
"Reporting %d completed tasks, requesting new tasks%s",
|
|
|
|
p->nresults_returned, buf
|
2009-01-22 21:29:09 +00:00
|
|
|
);
|
|
|
|
} else {
|
2009-06-02 22:53:57 +00:00
|
|
|
msg_printf(p, MSG_INFO, "Requesting new tasks%s", buf);
|
2009-01-22 21:29:09 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (p->nresults_returned) {
|
|
|
|
msg_printf(p, MSG_INFO,
|
|
|
|
"Reporting %d completed tasks, not requesting new tasks",
|
|
|
|
p->nresults_returned
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
msg_printf(p, MSG_INFO, "Not reporting or requesting tasks");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (log_flags.sched_op_debug) {
|
2009-01-03 06:01:17 +00:00
|
|
|
msg_printf(p, MSG_INFO,
|
2009-02-27 18:46:00 +00:00
|
|
|
"[sched_op_debug] CPU work request: %.2f seconds; %d idle CPUs",
|
2009-01-03 06:01:17 +00:00
|
|
|
cpu_work_fetch.req_secs, cpu_work_fetch.req_instances
|
|
|
|
);
|
|
|
|
if (coproc_cuda) {
|
|
|
|
msg_printf(p, MSG_INFO,
|
2009-02-27 18:46:00 +00:00
|
|
|
"[sched_op_debug] CUDA work request: %.2f seconds; %d idle GPUs",
|
|
|
|
cuda_work_fetch.req_secs, cuda_work_fetch.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
|
|
|
|
2004-09-26 04:16:52 +00:00
|
|
|
http_op.set_proxy(&gstate.proxy_info);
|
2009-02-10 19:30:59 +00:00
|
|
|
cur_proj = p;
|
2005-06-01 05:49:51 +00:00
|
|
|
retval = http_op.init_post(scheduler_url, request_file, reply_file);
|
|
|
|
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) {
|
2007-10-15 22:08:24 +00:00
|
|
|
msg_printf(p, MSG_INFO, "[sched_op_debug] Fetching master file");
|
2006-06-22 19:40:30 +00:00
|
|
|
}
|
2004-09-26 04:16:52 +00:00
|
|
|
http_op.set_proxy(&gstate.proxy_info);
|
2009-02-14 00:05:02 +00:00
|
|
|
cur_proj = p;
|
2005-06-01 21:51:32 +00:00
|
|
|
retval = http_op.init_get(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,
|
|
|
|
"[sched_op_debug] 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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,
|
|
|
|
"[sched_op_debug] 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);
|
|
|
|
|
|
|
|
// 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
|
|
|
}
|
2009-02-09 22:00:31 +00:00
|
|
|
cur_proj->sched_rpc_pending = 0;
|
|
|
|
// 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
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-07 20:39:24 +00:00
|
|
|
SCHEDULER_REPLY::SCHEDULER_REPLY() {
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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) {
|
2005-01-31 22:19:03 +00:00
|
|
|
char buf[256], msg_buf[1024], pri_buf[256];
|
2005-08-17 22:08:35 +00:00
|
|
|
int retval;
|
2004-06-12 04:45:36 +00:00
|
|
|
MIOFILE mf;
|
2005-03-09 23:28:37 +00:00
|
|
|
std::string delete_file_name;
|
2004-06-12 04:45:36 +00:00
|
|
|
mf.init_file(in);
|
2004-10-15 19:19:03 +00:00
|
|
|
bool found_start_tag = false;
|
2007-09-03 23:00:22 +00:00
|
|
|
double cpid_time = 0;
|
2002-08-15 21:21:08 +00:00
|
|
|
|
2003-02-18 23:07:48 +00:00
|
|
|
hostid = 0;
|
|
|
|
request_delay = 0;
|
2006-05-23 06:46:19 +00:00
|
|
|
next_rpc_delay = 0;
|
2002-09-29 00:32:11 +00:00
|
|
|
global_prefs_xml = 0;
|
|
|
|
project_prefs_xml = 0;
|
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.
|
2006-03-07 21:58:14 +00:00
|
|
|
strcpy(master_url, "");
|
2002-07-07 20:39:24 +00:00
|
|
|
code_sign_key = 0;
|
|
|
|
code_sign_key_signature = 0;
|
2004-07-06 04:01:15 +00:00
|
|
|
message_ack = false;
|
2004-06-22 22:56:50 +00:00
|
|
|
project_is_down = false;
|
2004-07-06 18:31:56 +00:00
|
|
|
send_file_list = false;
|
2007-04-13 22:55:18 +00:00
|
|
|
send_time_stats_log = 0;
|
|
|
|
send_job_log = 0;
|
2005-01-31 22:19:03 +00:00
|
|
|
messages.clear();
|
2006-07-28 16:09:10 +00:00
|
|
|
scheduler_version = 0;
|
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
|
|
|
//
|
2002-06-21 06:52:47 +00:00
|
|
|
while (fgets(buf, 256, in)) {
|
2004-10-15 19:19:03 +00:00
|
|
|
if (!found_start_tag) {
|
|
|
|
if (match_tag(buf, "<scheduler_reply")) {
|
|
|
|
found_start_tag = true;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2005-02-18 23:43:28 +00:00
|
|
|
if (match_tag(buf, "</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()) {
|
2005-08-11 04:45:16 +00:00
|
|
|
|
2006-05-17 01:48:39 +00:00
|
|
|
// delete old stats
|
|
|
|
while (!project->statistics.empty()) {
|
|
|
|
DAILY_STATS& ds = project->statistics[0];
|
2006-05-21 21:11:28 +00:00
|
|
|
if (dday() - ds.day > config.save_stats_days*86400) {
|
2006-05-17 01:48:39 +00:00
|
|
|
project->statistics.erase(project->statistics.begin());
|
|
|
|
} else {
|
|
|
|
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
|
|
|
}
|
2006-03-07 23:21:30 +00:00
|
|
|
else if (parse_str(buf, "<project_name>", project->project_name, sizeof(project->project_name))) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-03-07 21:58:14 +00:00
|
|
|
else if (parse_str(buf, "<master_url>", master_url, sizeof(master_url))) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-05-22 09:54:31 +00:00
|
|
|
else if (parse_str(buf, "<symstore>", project->symstore, sizeof(project->symstore))) continue;
|
2005-04-13 23:28:47 +00:00
|
|
|
else if (parse_str(buf, "<user_name>", project->user_name, sizeof(project->user_name))) continue;
|
2004-09-23 22:27:41 +00:00
|
|
|
else if (parse_double(buf, "<user_total_credit>", project->user_total_credit)) continue;
|
|
|
|
else if (parse_double(buf, "<user_expavg_credit>", project->user_expavg_credit)) continue;
|
2005-02-08 20:12:43 +00:00
|
|
|
else if (parse_double(buf, "<user_create_time>", project->user_create_time)) continue;
|
2007-09-03 23:00:22 +00:00
|
|
|
else if (parse_double(buf, "<cpid_time>", cpid_time)) continue;
|
2005-04-13 23:28:47 +00:00
|
|
|
else if (parse_str(buf, "<team_name>", project->team_name, sizeof(project->team_name))) continue;
|
2004-10-01 08:15:58 +00:00
|
|
|
else if (parse_int(buf, "<hostid>", hostid)) continue;
|
2004-09-23 22:27:41 +00:00
|
|
|
else if (parse_double(buf, "<host_total_credit>", project->host_total_credit)) continue;
|
|
|
|
else if (parse_double(buf, "<host_expavg_credit>", project->host_expavg_credit)) continue;
|
2003-03-06 00:42:18 +00:00
|
|
|
else if (parse_str(buf, "<host_venue>", host_venue, sizeof(host_venue))) continue;
|
2005-02-08 20:12:43 +00:00
|
|
|
else if (parse_double(buf, "<host_create_time>", project->host_create_time)) continue;
|
2004-10-25 20:16:30 +00:00
|
|
|
else if (parse_double(buf, "<request_delay>", request_delay)) continue;
|
2006-05-23 06:46:19 +00:00
|
|
|
else if (parse_double(buf, "<next_rpc_delay>", next_rpc_delay)) continue;
|
2003-02-14 18:28:24 +00:00
|
|
|
else if (match_tag(buf, "<global_preferences>")) {
|
2003-02-11 19:41:08 +00:00
|
|
|
retval = dup_element_contents(
|
2003-02-11 00:52:44 +00:00
|
|
|
in,
|
|
|
|
"</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;
|
|
|
|
}
|
2002-09-29 00:32:11 +00:00
|
|
|
} else if (match_tag(buf, "<project_preferences>")) {
|
2003-02-11 19:41:08 +00:00
|
|
|
retval = dup_element_contents(
|
2003-02-11 00:52:44 +00:00
|
|
|
in,
|
|
|
|
"</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;
|
|
|
|
}
|
2004-09-27 19:44:40 +00:00
|
|
|
} else if (match_tag(buf, "<gui_urls>")) {
|
|
|
|
std::string foo;
|
|
|
|
retval = copy_element_contents(in, "</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";
|
2004-09-27 19:44:40 +00:00
|
|
|
continue;
|
2002-07-07 20:39:24 +00:00
|
|
|
} else if (match_tag(buf, "<code_sign_key>")) {
|
2003-02-11 19:41:08 +00:00
|
|
|
retval = dup_element_contents(
|
2003-02-11 00:52:44 +00:00
|
|
|
in,
|
|
|
|
"</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
|
|
|
}
|
2002-07-07 20:39:24 +00:00
|
|
|
} else if (match_tag(buf, "<code_sign_key_signature>")) {
|
2003-02-11 19:41:08 +00:00
|
|
|
retval = dup_element_contents(
|
2003-02-11 00:52:44 +00:00
|
|
|
in,
|
|
|
|
"</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;
|
|
|
|
}
|
2002-06-21 06:52:47 +00:00
|
|
|
} else if (match_tag(buf, "<app>")) {
|
|
|
|
APP app;
|
2004-08-12 12:44:55 +00:00
|
|
|
retval = app.parse(mf);
|
|
|
|
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);
|
|
|
|
}
|
2002-06-21 06:52:47 +00:00
|
|
|
} else if (match_tag(buf, "<file_info>")) {
|
|
|
|
FILE_INFO file_info;
|
2004-08-12 12:44:55 +00:00
|
|
|
retval = file_info.parse(mf, true);
|
|
|
|
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);
|
|
|
|
}
|
2002-06-21 06:52:47 +00:00
|
|
|
} else if (match_tag(buf, "<app_version>")) {
|
|
|
|
APP_VERSION av;
|
2004-08-12 12:44:55 +00:00
|
|
|
retval = av.parse(mf);
|
|
|
|
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
|
|
|
);
|
2008-04-01 20:46:41 +00:00
|
|
|
av.coprocs.delete_coprocs();
|
2004-08-12 12:44:55 +00:00
|
|
|
} else {
|
|
|
|
app_versions.push_back(av);
|
|
|
|
}
|
2002-06-21 06:52:47 +00:00
|
|
|
} else if (match_tag(buf, "<workunit>")) {
|
|
|
|
WORKUNIT wu;
|
2004-08-12 12:44:55 +00:00
|
|
|
retval = wu.parse(mf);
|
|
|
|
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);
|
|
|
|
}
|
2002-06-21 06:52:47 +00:00
|
|
|
} else if (match_tag(buf, "<result>")) {
|
|
|
|
RESULT result; // make sure this is here so constructor
|
|
|
|
// gets called each time
|
2004-08-12 12:44:55 +00:00
|
|
|
retval = result.parse_server(mf);
|
|
|
|
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);
|
|
|
|
}
|
2002-06-21 06:52:47 +00:00
|
|
|
} else if (match_tag(buf, "<result_ack>")) {
|
|
|
|
RESULT result;
|
2006-05-25 20:10:08 +00:00
|
|
|
retval = result.parse_name(in, "</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);
|
|
|
|
}
|
2006-05-25 20:10:08 +00:00
|
|
|
} else if (match_tag(buf, "<result_abort>")) {
|
|
|
|
RESULT result;
|
|
|
|
retval = result.parse_name(in, "</result_abort>");
|
|
|
|
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);
|
|
|
|
}
|
2007-03-22 02:38:45 +00:00
|
|
|
} else if (match_tag(buf, "<result_abort_if_not_started>")) {
|
2006-05-25 20:10:08 +00:00
|
|
|
RESULT result;
|
2007-03-22 02:38:45 +00:00
|
|
|
retval = result.parse_name(in, "</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
|
|
|
}
|
2005-03-09 23:28:37 +00:00
|
|
|
} else if (parse_str(buf, "<delete_file_info>", delete_file_name)) {
|
|
|
|
file_deletes.push_back(delete_file_name);
|
2005-01-31 22:19:03 +00:00
|
|
|
} else if (parse_str(buf, "<message", msg_buf, sizeof(msg_buf))) {
|
|
|
|
parse_attr(buf, "priority", pri_buf, sizeof(pri_buf));
|
|
|
|
USER_MESSAGE um(msg_buf, pri_buf);
|
|
|
|
messages.push_back(um);
|
2002-06-21 06:52:47 +00:00
|
|
|
continue;
|
2004-07-06 04:01:15 +00:00
|
|
|
} else if (match_tag(buf, "<message_ack/>")) {
|
|
|
|
message_ack = true;
|
2004-06-22 22:56:50 +00:00
|
|
|
} else if (match_tag(buf, "<project_is_down/>")) {
|
|
|
|
project_is_down = true;
|
2004-04-19 20:56:57 +00:00
|
|
|
} else if (parse_str(buf, "<email_hash>", project->email_hash, sizeof(project->email_hash))) {
|
|
|
|
continue;
|
|
|
|
} else if (parse_str(buf, "<cross_project_id>", project->cross_project_id, sizeof(project->cross_project_id))) {
|
|
|
|
continue;
|
2004-05-12 21:21:09 +00:00
|
|
|
} else if (match_tag(buf, "<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;
|
2005-08-17 21:05:26 +00:00
|
|
|
} else if (parse_bool(buf, "non_cpu_intensive", project->non_cpu_intensive)) {
|
2004-05-18 18:33:01 +00:00
|
|
|
continue;
|
2007-05-24 16:07:21 +00:00
|
|
|
} else if (parse_bool(buf, "ended", project->ended)) {
|
|
|
|
continue;
|
2006-06-20 17:36:28 +00:00
|
|
|
} else if (parse_bool(buf, "verify_files_on_app_start", project->verify_files_on_app_start)) {
|
|
|
|
continue;
|
2004-11-22 22:58:41 +00:00
|
|
|
} else if (match_tag(buf, "<request_file_list/>")) {
|
|
|
|
send_file_list = true;
|
2007-04-13 22:55:18 +00:00
|
|
|
} else if (parse_int(buf, "<send_time_stats_log>", send_time_stats_log)){
|
|
|
|
continue;
|
|
|
|
} else if (parse_int(buf, "<send_job_log>", send_job_log)) {
|
|
|
|
continue;
|
2006-06-23 20:05:12 +00:00
|
|
|
} else if (parse_int(buf, "<scheduler_version>", scheduler_version)) {
|
|
|
|
continue;
|
2006-06-26 22:58:24 +00:00
|
|
|
} else if (match_tag(buf, "<project_files>")) {
|
2006-10-09 18:58:52 +00:00
|
|
|
retval = project->parse_project_files(mf, true);
|
2006-12-17 03:34:31 +00:00
|
|
|
#ifdef ENABLE_AUTO_UPDATE
|
2006-12-11 23:42:54 +00:00
|
|
|
} else if (match_tag(buf, "<auto_update>")) {
|
2006-12-12 23:32:25 +00:00
|
|
|
retval = auto_update.parse(mf);
|
2006-12-21 16:56:33 +00:00
|
|
|
if (!retval) auto_update.present = true;
|
2006-12-19 17:41:30 +00:00
|
|
|
#endif
|
2008-05-20 00:11:28 +00:00
|
|
|
} else if (match_tag(buf, "<!--")) {
|
|
|
|
continue;
|
2004-11-22 22:58:41 +00:00
|
|
|
} else if (strlen(buf)>1){
|
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,
|
2006-09-07 20:39:25 +00:00
|
|
|
"[unparsed_xml] SCHEDULER_REPLY::parse(): unrecognized %s\n", buf
|
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;
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_11c806525b = "$Id$";
|