2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2003-07-02 02:02:18 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This 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 2.1 of the License, or (at your option) any later version.
|
2003-07-02 02:02:18 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// 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
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
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
|
|
|
);
|
2005-06-01 21:51:32 +00:00
|
|
|
if (p->tentative) {
|
2005-09-28 11:59:34 +00:00
|
|
|
p->attach_failed(ERR_ATTACH_FAIL_PARSE);
|
2005-05-16 06:49:07 +00:00
|
|
|
} else {
|
2005-06-01 21:51:32 +00:00
|
|
|
p->master_fetch_failures++;
|
2006-12-21 16:56:33 +00:00
|
|
|
backoff(p, "scheduler list fetch failed\n");
|
2003-05-13 18:55:07 +00:00
|
|
|
}
|
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-07 21:21:35 +00:00
|
|
|
// Try to get work from eligible project with biggest long term debt
|
2004-09-22 22:09:54 +00:00
|
|
|
// PRECONDITION: compute_work_requests() has been called
|
|
|
|
// to fill in PROJECT::work_request
|
2005-06-07 21:21:35 +00:00
|
|
|
// and CLIENT_STATE::overall_work_fetch_urgency
|
2002-07-15 05:34:32 +00:00
|
|
|
//
|
2005-06-07 21:21:35 +00:00
|
|
|
int SCHEDULER_OP::init_get_work() {
|
2005-05-14 19:45:24 +00:00
|
|
|
int retval;
|
2004-05-05 21:15:34 +00:00
|
|
|
|
2005-06-07 21:21:35 +00:00
|
|
|
PROJECT* p = gstate.next_project_need_work();
|
2005-06-01 21:51:32 +00:00
|
|
|
if (p) {
|
2006-09-01 22:21:20 +00:00
|
|
|
retval = init_op_project(p, RPC_REASON_NEED_WORK);
|
2003-01-02 23:12:05 +00:00
|
|
|
if (retval) {
|
2002-11-19 22:57:05 +00:00
|
|
|
return retval;
|
|
|
|
}
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
2005-05-14 19:45:24 +00:00
|
|
|
return 0;
|
2002-07-15 05:34:32 +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) {
|
|
|
|
msg_printf(0, MSG_INFO,
|
2006-09-07 20:39:25 +00:00
|
|
|
"[sched_op_debug] SCHEDULER_OP::init_op_project(): starting op for %s\n",
|
2006-06-22 19:40:30 +00:00
|
|
|
p->master_url
|
|
|
|
);
|
|
|
|
}
|
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) {
|
|
|
|
p->work_request = 1;
|
|
|
|
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
|
|
|
//
|
2005-10-19 21:22:10 +00:00
|
|
|
// Master-file fetch errors for tentative (new) projects
|
|
|
|
// are handled elsewhere; no need to detach from projects here.
|
|
|
|
//
|
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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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;
|
2004-09-22 22:09:54 +00:00
|
|
|
char request_file[1024], reply_file[1024];
|
2002-06-21 06:52:47 +00:00
|
|
|
|
2007-04-04 19:34:01 +00:00
|
|
|
// if requesting work, round up to 1 sec
|
|
|
|
//
|
|
|
|
if (p->work_request>0 && p->work_request<1) {
|
|
|
|
p->work_request = 1;
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
"Sending scheduler request: %s",
|
|
|
|
rpc_reason_string(reason)
|
|
|
|
);
|
2007-04-04 19:34:01 +00:00
|
|
|
if (p->work_request>0 && p->nresults_returned != 0) {
|
2005-09-07 05:44:47 +00:00
|
|
|
msg_printf(
|
|
|
|
p, MSG_INFO,
|
2007-04-04 19:34:01 +00:00
|
|
|
"Requesting %.0f seconds of new work, and reporting %d completed tasks",
|
2005-09-07 05:44:47 +00:00
|
|
|
p->work_request, p->nresults_returned
|
|
|
|
);
|
|
|
|
} else if (p->work_request != 0) {
|
|
|
|
msg_printf(
|
|
|
|
p, MSG_INFO,
|
2007-04-04 19:34:01 +00:00
|
|
|
"Requesting %.0f seconds of new work",
|
2005-09-07 05:44:47 +00:00
|
|
|
p->work_request
|
|
|
|
);
|
|
|
|
} else if (p->nresults_returned != 0) {
|
2007-04-04 19:34:01 +00:00
|
|
|
msg_printf(p, MSG_INFO,
|
|
|
|
"Reporting %d tasks\n", p->nresults_returned
|
2005-09-07 05:44:47 +00:00
|
|
|
);
|
|
|
|
} else {
|
2007-04-04 19:34:01 +00:00
|
|
|
msg_printf( p, MSG_INFO,
|
2006-01-17 22:48:09 +00:00
|
|
|
"(not requesting new work or reporting completed tasks)"
|
2005-09-07 05:44:47 +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);
|
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,
|
|
|
|
"Scheduler request failed: %s", boincerror(retval)
|
|
|
|
);
|
|
|
|
}
|
2005-06-01 05:49:51 +00:00
|
|
|
return retval;
|
|
|
|
}
|
2002-07-15 05:34:32 +00:00
|
|
|
retval = http_ops->insert(&http_op);
|
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,
|
|
|
|
"Scheduler request failed: %s", boincerror(retval)
|
|
|
|
);
|
|
|
|
}
|
2005-06-01 05:49:51 +00:00
|
|
|
return retval;
|
|
|
|
}
|
2005-06-01 21:51:32 +00:00
|
|
|
p->rpc_seqno++;
|
|
|
|
cur_proj = p; // remember what project we're talking to
|
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) {
|
|
|
|
msg_printf(0, MSG_INFO,
|
2006-09-07 20:39:25 +00:00
|
|
|
"[sched_op_debug] SCHEDULER_OP::init_master_fetch(): Fetching master file for %s\n",
|
2006-06-22 19:40:30 +00:00
|
|
|
p->master_url
|
|
|
|
);
|
|
|
|
}
|
2004-09-26 04:16:52 +00:00
|
|
|
http_op.set_proxy(&gstate.proxy_info);
|
2005-06-01 21:51:32 +00:00
|
|
|
retval = http_op.init_get(p->master_url, master_filename, true);
|
2002-07-15 05:34:32 +00:00
|
|
|
if (retval) return retval;
|
|
|
|
retval = http_ops->insert(&http_op);
|
|
|
|
if (retval) return retval;
|
2005-06-01 21:51:32 +00:00
|
|
|
cur_proj = p;
|
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)) {
|
2005-03-10 00:43:22 +00:00
|
|
|
strip_whitespace(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-04-03 19:35:33 +00:00
|
|
|
char* q = strchr(buf2, '\"');
|
|
|
|
if (q) *q = 0;
|
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) {
|
|
|
|
msg_printf(0, MSG_INFO,
|
2006-09-07 20:39:25 +00:00
|
|
|
"[sched_op_debug] SCHEDULER_OP::parse_master_file(): got %d scheduler URLs\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) {
|
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() {
|
2003-01-02 23:12:05 +00:00
|
|
|
int retval, nresults;
|
2005-03-09 23:28:37 +00:00
|
|
|
vector<std::string> urls;
|
2003-01-02 23:12:05 +00:00
|
|
|
bool changed, scheduler_op_done;
|
2005-06-01 21:51:32 +00:00
|
|
|
bool err = false;
|
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);
|
2005-06-01 21:51:32 +00:00
|
|
|
gstate.set_client_state_dirty("master URL fetch done");
|
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) {
|
|
|
|
msg_printf(0, MSG_INFO,
|
2006-09-07 20:39:25 +00:00
|
|
|
"[sched_op_debug] SCHEDULER_OP::poll(): Got master file from %s; parsing",
|
2006-06-22 19:40:30 +00:00
|
|
|
cur_proj->master_url
|
|
|
|
);
|
|
|
|
}
|
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.
|
|
|
|
//
|
2005-06-01 21:51:32 +00:00
|
|
|
if (cur_proj->tentative) {
|
|
|
|
PROJECT* project_temp = cur_proj;
|
|
|
|
cur_proj = 0; // keep detach(0) from removing HTTP OP
|
2005-08-13 03:19:22 +00:00
|
|
|
project_temp->attach_failed(ERR_ATTACH_FAIL_PARSE);
|
2003-06-06 22:08:46 +00:00
|
|
|
err = true;
|
2003-05-21 17:59:10 +00:00
|
|
|
} else {
|
2005-06-01 21:51:32 +00:00
|
|
|
cur_proj->master_fetch_failures++;
|
2005-12-06 07:23:12 +00:00
|
|
|
backoff(cur_proj, "Couldn't parse scheduler list");
|
2003-05-21 17:59:10 +00:00
|
|
|
}
|
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
|
|
|
//
|
2005-06-01 21:51:32 +00:00
|
|
|
if (cur_proj->tentative) {
|
2005-06-11 00:30:11 +00:00
|
|
|
PROJECT* project_temp = cur_proj;
|
|
|
|
cur_proj = 0;
|
2005-08-13 03:19:22 +00:00
|
|
|
project_temp->attach_failed(ERR_ATTACH_FAIL_DOWNLOAD);
|
2003-05-13 18:55:07 +00:00
|
|
|
} else {
|
2005-12-06 07:23:12 +00:00
|
|
|
char buf[256];
|
|
|
|
sprintf(buf, "Scheduler list fetch failed: %s",
|
|
|
|
boincerror(http_op.http_op_retval)
|
|
|
|
);
|
2005-06-01 21:51:32 +00:00
|
|
|
cur_proj->master_fetch_failures++;
|
2005-12-06 07:23:12 +00:00
|
|
|
backoff(cur_proj, buf);
|
2003-05-13 18:55:07 +00:00
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
}
|
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
|
|
|
//
|
|
|
|
scheduler_op_done = false;
|
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()) {
|
2006-12-21 16:56:33 +00:00
|
|
|
backoff(cur_proj, "scheduler request failed");
|
2005-06-01 21:51:32 +00:00
|
|
|
scheduler_op_done = true;
|
2006-03-07 21:46:49 +00:00
|
|
|
|
|
|
|
// if project suspended, don't retry failed RPC
|
|
|
|
//
|
|
|
|
if (cur_proj->suspended_via_gui) {
|
2006-08-24 20:33:46 +00:00
|
|
|
cur_proj->sched_rpc_pending = 0;
|
2006-03-07 21:46:49 +00:00
|
|
|
}
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
|
|
|
} else {
|
2005-06-01 21:51:32 +00:00
|
|
|
retval = gstate.handle_scheduler_reply(cur_proj, scheduler_url, nresults);
|
|
|
|
if (cur_proj->tentative) {
|
2007-01-08 22:15:21 +00:00
|
|
|
cur_proj->tentative = false;
|
|
|
|
retval = cur_proj->write_account_file();
|
2006-12-26 00:59:18 +00:00
|
|
|
if (retval) {
|
|
|
|
cur_proj->attach_failed(ERR_ATTACH_FAIL_FILE_WRITE);
|
2004-05-13 04:43:42 +00:00
|
|
|
} else {
|
2006-12-26 00:59:18 +00:00
|
|
|
gstate.project_attach.error_num = 0;
|
|
|
|
msg_printf(cur_proj, MSG_INFO,
|
|
|
|
"Successfully attached to %s",
|
|
|
|
cur_proj->get_project_name()
|
|
|
|
);
|
2003-05-13 18:55:07 +00:00
|
|
|
}
|
2003-01-02 23:12:05 +00:00
|
|
|
} else {
|
2004-06-22 22:56:50 +00:00
|
|
|
switch (retval) {
|
|
|
|
case 0:
|
2004-05-13 04:43:42 +00:00
|
|
|
// if we asked for work and didn't get any,
|
|
|
|
// back off this project
|
|
|
|
//
|
2006-12-21 16:56:33 +00:00
|
|
|
if (cur_proj->work_request && nresults==0) {
|
2006-12-26 00:59:18 +00:00
|
|
|
backoff(cur_proj, "no work from project\n");
|
2004-05-13 04:43:42 +00:00
|
|
|
} else {
|
2005-06-01 21:51:32 +00:00
|
|
|
cur_proj->nrpc_failures = 0;
|
2004-05-13 04:43:42 +00:00
|
|
|
}
|
2004-06-22 22:56:50 +00:00
|
|
|
break;
|
|
|
|
case ERR_PROJECT_DOWN:
|
2006-12-21 16:56:33 +00:00
|
|
|
backoff(cur_proj, "project is down");
|
2004-06-22 22:56:50 +00:00
|
|
|
break;
|
|
|
|
default:
|
2006-12-21 16:56:33 +00:00
|
|
|
backoff(cur_proj, "can't parse scheduler reply");
|
2004-06-22 22:56:50 +00:00
|
|
|
break;
|
2003-05-13 18:55:07 +00:00
|
|
|
}
|
2006-12-21 16:56:33 +00:00
|
|
|
cur_proj->work_request = 0; // don't ask again right away
|
2003-01-02 23:12:05 +00:00
|
|
|
}
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
2005-06-01 21:51:32 +00:00
|
|
|
cur_proj = NULL;
|
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;
|
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;
|
2003-03-19 01:15:46 +00:00
|
|
|
strcpy(host_venue, "");
|
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
|
|
|
|
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;
|
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
|
|
|
);
|
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;
|
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
|
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) {
|
2007-01-25 23:39:06 +00:00
|
|
|
msg_printf(0, 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$";
|