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-08 21:30:47 +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-08 21:30:47 +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-12-03 18:57:40 +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/>.
|
2002-12-03 18:57:40 +00:00
|
|
|
|
|
|
|
// Parse a server configuration file
|
|
|
|
|
2008-09-09 19:10:42 +00:00
|
|
|
#ifdef _USING_FCGI_
|
|
|
|
#include "boinc_fcgi.h"
|
|
|
|
#endif
|
|
|
|
|
2004-07-13 13:54:09 +00:00
|
|
|
#include <cstring>
|
2003-10-03 06:46:22 +00:00
|
|
|
#include <string>
|
2004-08-03 21:51:30 +00:00
|
|
|
#include <unistd.h>
|
2002-10-03 18:33:46 +00:00
|
|
|
|
|
|
|
#include "parse.h"
|
|
|
|
#include "error_numbers.h"
|
2009-05-07 13:54:51 +00:00
|
|
|
#include "filesys.h"
|
|
|
|
#include "str_util.h"
|
2009-06-16 20:54:44 +00:00
|
|
|
#include "str_replace.h"
|
2002-10-03 18:33:46 +00:00
|
|
|
|
2006-06-07 04:10:04 +00:00
|
|
|
#include "sched_msgs.h"
|
2007-04-18 20:49:58 +00:00
|
|
|
#include "sched_util.h"
|
2003-08-15 00:45:25 +00:00
|
|
|
#include "sched_config.h"
|
2002-10-03 18:33:46 +00:00
|
|
|
|
2003-09-02 21:16:55 +00:00
|
|
|
const char* CONFIG_FILE = "config.xml";
|
2010-06-03 04:59:27 +00:00
|
|
|
const char* CONFIG_FILE_AUX = "config_aux.xml";
|
2003-07-08 21:30:47 +00:00
|
|
|
|
2008-02-25 18:05:04 +00:00
|
|
|
SCHED_CONFIG config;
|
|
|
|
|
2010-06-21 21:14:34 +00:00
|
|
|
const int MAX_NCPUS = 64;
|
2009-06-01 22:15:14 +00:00
|
|
|
// max multiplier for daily_result_quota.
|
2008-02-21 20:10:10 +00:00
|
|
|
// need to change as multicore processors expand
|
|
|
|
|
2010-06-03 04:59:27 +00:00
|
|
|
int SCHED_CONFIG::parse_aux(FILE* f) {
|
|
|
|
MIOFILE mf;
|
|
|
|
XML_PARSER xp(&mf);
|
|
|
|
mf.init_file(f);
|
|
|
|
if (!xp.parse_start("config")) return ERR_XML_PARSE;
|
2011-08-10 17:11:08 +00:00
|
|
|
while (!xp.get_tag()) {
|
|
|
|
if (!xp.is_tag) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"SCHED_CONFIG::parse(): unexpected text %s\n",
|
|
|
|
xp.parsed_tag
|
|
|
|
);
|
2010-06-03 04:59:27 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.match_tag("/config")) {
|
2010-06-03 04:59:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.match_tag("max_jobs_in_progress")) {
|
2010-06-03 04:59:27 +00:00
|
|
|
max_jobs_in_progress.parse(xp, "/max_jobs_in_progress");
|
|
|
|
}
|
|
|
|
}
|
2010-06-04 16:57:33 +00:00
|
|
|
return ERR_XML_PARSE;
|
2010-06-03 04:59:27 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 05:22:10 +00:00
|
|
|
int SCHED_CONFIG::parse(FILE* f) {
|
2011-08-10 17:11:08 +00:00
|
|
|
char buf[256];
|
2006-08-22 21:52:44 +00:00
|
|
|
MIOFILE mf;
|
|
|
|
XML_PARSER xp(&mf);
|
2010-06-01 23:41:07 +00:00
|
|
|
int retval, itemp;
|
2008-02-25 18:05:04 +00:00
|
|
|
regex_t re;
|
2011-02-15 22:07:14 +00:00
|
|
|
double x;
|
2006-05-25 05:22:10 +00:00
|
|
|
|
2006-08-22 21:52:44 +00:00
|
|
|
mf.init_file(f);
|
- server code: at some point I made a global var "SCHED_CONFIG config",
mostly so that the parse function could assume
that everything was initially zero.
However, various back-end functions pass around SCHED_CONFIG&
as an argument (also named "config").
This creates a shadow, which is always bad.
Worse is the possibility that some projects have back-end programs
that have a SCHED_CONFIG variable that's automatic,
and therefore isn't zero initially,
and therefore isn't parsing correctly.
To fix this, I changed the 2 vectors in SCHED_CONFIG into pointers,
and have the parse routine zero the structure.
I was tempted to remove the SCHED_CONFIG& args to back-end functions,
but this would have broken some projects' code.
I did, however, change the name from config to config_loc
to avoid shadowing.
Also fixed various other compiler warnings.
svn path=/trunk/boinc/; revision=15541
2008-07-02 17:24:53 +00:00
|
|
|
|
|
|
|
memset(this, 0, sizeof(*this));
|
|
|
|
ban_os = new vector<regex_t>;
|
|
|
|
ban_cpu = new vector<regex_t>;
|
2009-03-03 00:25:41 +00:00
|
|
|
locality_scheduling_workunit_file = new vector<regex_t>;
|
|
|
|
locality_scheduling_sticky_file = new vector<regex_t>;
|
2006-05-25 05:22:10 +00:00
|
|
|
max_wus_to_send = 10;
|
|
|
|
default_disk_max_used_gb = 100.;
|
|
|
|
default_disk_max_used_pct = 50.;
|
|
|
|
default_disk_min_free_gb = .001;
|
2008-02-21 21:00:58 +00:00
|
|
|
sched_debug_level = MSG_NORMAL;
|
|
|
|
fuh_debug_level = MSG_NORMAL;
|
2007-06-27 20:09:18 +00:00
|
|
|
strcpy(httpd_user, "apache");
|
2008-02-21 20:10:10 +00:00
|
|
|
max_ncpus = MAX_NCPUS;
|
2012-02-27 12:40:43 +00:00
|
|
|
scheduler_log_buffer = 32768;
|
2012-02-22 19:51:09 +00:00
|
|
|
version_select_random_factor = .1;
|
2006-08-21 22:25:21 +00:00
|
|
|
|
|
|
|
if (!xp.parse_start("boinc")) return ERR_XML_PARSE;
|
|
|
|
if (!xp.parse_start("config")) return ERR_XML_PARSE;
|
2011-08-10 17:11:08 +00:00
|
|
|
while (!xp.get_tag()) {
|
|
|
|
if (!xp.is_tag) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"SCHED_CONFIG::parse(): unexpected text %s\n",
|
|
|
|
xp.parsed_tag
|
|
|
|
);
|
2006-08-21 22:25:21 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.match_tag("/config")) {
|
2006-05-25 05:22:10 +00:00
|
|
|
char hostname[256];
|
|
|
|
gethostname(hostname, 256);
|
|
|
|
if (!strcmp(hostname, db_host)) strcpy(db_host, "localhost");
|
2011-01-28 22:03:46 +00:00
|
|
|
if (!strlen(replica_db_host)) {
|
|
|
|
strcpy(replica_db_host, db_host);
|
|
|
|
}
|
|
|
|
if (!strlen(replica_db_name)) {
|
|
|
|
strcpy(replica_db_name, db_name);
|
|
|
|
}
|
|
|
|
if (!strlen(replica_db_user)) {
|
|
|
|
strcpy(replica_db_user, db_user);
|
|
|
|
}
|
|
|
|
if (!strlen(replica_db_passwd)) {
|
|
|
|
strcpy(replica_db_passwd, db_passwd);
|
|
|
|
}
|
2006-05-25 05:22:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_str("master_url", master_url, sizeof(master_url))) continue;
|
|
|
|
if (xp.parse_str("long_name", long_name, sizeof(long_name))) continue;
|
|
|
|
if (xp.parse_str("db_name", db_name, sizeof(db_name))) continue;
|
|
|
|
if (xp.parse_str("db_user", db_user, sizeof(db_user))) continue;
|
|
|
|
if (xp.parse_str("db_passwd", db_passwd, sizeof(db_passwd))) continue;
|
|
|
|
if (xp.parse_str("db_host", db_host, sizeof(db_host))) continue;
|
|
|
|
if (xp.parse_str("replica_db_name", replica_db_name, sizeof(replica_db_name))) continue;
|
|
|
|
if (xp.parse_str("replica_db_user", replica_db_user, sizeof(replica_db_user))) continue;
|
|
|
|
if (xp.parse_str("replica_db_passwd", replica_db_passwd, sizeof(replica_db_passwd))) continue;
|
|
|
|
if (xp.parse_str("replica_db_host", replica_db_host, sizeof(replica_db_host))) continue;
|
|
|
|
if (xp.parse_str("project_dir", project_dir, sizeof(project_dir))) continue;
|
|
|
|
if (xp.parse_int("shmem_key", shmem_key)) continue;
|
|
|
|
if (xp.parse_str("key_dir", key_dir, sizeof(key_dir))) continue;
|
|
|
|
if (xp.parse_str("download_url", download_url, sizeof(download_url))) continue;
|
|
|
|
if (xp.parse_str("download_dir", download_dir, sizeof(download_dir))) continue;
|
|
|
|
if (xp.parse_str("upload_url", upload_url, sizeof(upload_url))) continue;
|
|
|
|
if (xp.parse_str("upload_dir", upload_dir, sizeof(upload_dir))) continue;
|
|
|
|
if (xp.parse_bool("non_cpu_intensive", non_cpu_intensive)) continue;
|
|
|
|
if (xp.parse_bool("verify_files_on_app_start", verify_files_on_app_start)) continue;
|
|
|
|
if (xp.parse_int("homogeneous_redundancy", homogeneous_redundancy)) continue;
|
2012-03-15 19:50:10 +00:00
|
|
|
if (xp.parse_bool("hr_allocate_slots", hr_allocate_slots)) continue;
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_bool("msg_to_host", msg_to_host)) continue;
|
|
|
|
if (xp.parse_bool("ignore_upload_certificates", ignore_upload_certificates)) continue;
|
|
|
|
if (xp.parse_bool("dont_generate_upload_certificates", dont_generate_upload_certificates)) continue;
|
|
|
|
if (xp.parse_int("uldl_dir_fanout", uldl_dir_fanout)) continue;
|
|
|
|
if (xp.parse_bool("cache_md5_info", cache_md5_info)) continue;
|
|
|
|
if (xp.parse_double("fp_benchmark_weight", fp_benchmark_weight)) {
|
2010-06-01 03:45:49 +00:00
|
|
|
if (fp_benchmark_weight < 0 || fp_benchmark_weight > 1) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"CONFIG FILE ERROR: fp_benchmark_weight outside of 0..1"
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
use_benchmark_weights = true;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_int("fuh_debug_level", fuh_debug_level)) continue;
|
|
|
|
if (xp.parse_int("reliable_priority_on_over", reliable_priority_on_over)) continue;
|
|
|
|
if (xp.parse_int("reliable_priority_on_over_except_error", reliable_priority_on_over_except_error)) continue;
|
|
|
|
if (xp.parse_int("reliable_on_priority", reliable_on_priority)) continue;
|
|
|
|
if (xp.parse_double("grace_period_hours", x)) {
|
2011-02-23 21:22:45 +00:00
|
|
|
report_grace_period = (int)(x*3600);
|
2011-02-15 22:07:14 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_int("report_grace_period", report_grace_period)) continue;
|
|
|
|
if (xp.parse_double("delete_delay_hours", x)) {
|
2011-02-15 22:07:14 +00:00
|
|
|
delete_delay = x*3600;
|
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_bool("distinct_beta_apps", distinct_beta_apps)) continue;
|
|
|
|
if (xp.parse_bool("ended", ended)) continue;
|
|
|
|
if (xp.parse_int("shmem_work_items", shmem_work_items)) continue;
|
|
|
|
if (xp.parse_int("feeder_query_size", feeder_query_size)) continue;
|
|
|
|
if (xp.parse_str("httpd_user", httpd_user, sizeof(httpd_user))) continue;
|
2012-02-17 19:16:49 +00:00
|
|
|
if (xp.parse_bool("enable_vda", enable_vda)) continue;
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_bool("enable_assignment", enable_assignment)) continue;
|
2012-01-30 22:39:13 +00:00
|
|
|
if (xp.parse_bool("enable_assignment_multi", enable_assignment_multi)) continue;
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_bool("job_size_matching", job_size_matching)) continue;
|
|
|
|
if (xp.parse_bool("dont_send_jobs", dont_send_jobs)) continue;
|
2010-06-01 03:45:49 +00:00
|
|
|
|
|
|
|
//////////// STUFF RELEVANT ONLY TO SCHEDULER STARTS HERE ///////
|
|
|
|
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_str("ban_cpu", buf, sizeof(buf))) {
|
2010-06-01 03:45:49 +00:00
|
|
|
retval = regcomp(&re, buf, REG_EXTENDED|REG_NOSUB);
|
|
|
|
if (retval) {
|
|
|
|
log_messages.printf(MSG_CRITICAL, "BAD REGEXP: %s\n", buf);
|
|
|
|
} else {
|
|
|
|
ban_cpu->push_back(re);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_str("ban_os", buf, sizeof(buf))) {
|
2010-06-01 03:45:49 +00:00
|
|
|
retval = regcomp(&re, buf, REG_EXTENDED|REG_NOSUB);
|
|
|
|
if (retval) {
|
|
|
|
log_messages.printf(MSG_CRITICAL, "BAD REGEXP: %s\n", buf);
|
|
|
|
} else {
|
|
|
|
ban_os->push_back(re);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2012-02-27 12:26:46 +00:00
|
|
|
if (xp.parse_int("dont_search_host_for_user", retval)) {
|
2012-02-27 12:08:25 +00:00
|
|
|
dont_search_host_for_userid.push_back(retval);
|
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_int("daily_result_quota", daily_result_quota)) continue;
|
|
|
|
if (xp.parse_double("default_disk_max_used_gb", default_disk_max_used_gb)) continue;
|
|
|
|
if (xp.parse_double("default_disk_max_used_pct", default_disk_max_used_pct)) continue;
|
|
|
|
if (xp.parse_double("default_disk_min_free_gb", default_disk_min_free_gb)) continue;
|
|
|
|
if (xp.parse_bool("dont_store_success_stderr", dont_store_success_stderr)) continue;
|
|
|
|
if (xp.parse_int("file_deletion_strategy", file_deletion_strategy)) continue;
|
|
|
|
if (xp.parse_int("gpu_multiplier", gpu_multiplier)) continue;
|
|
|
|
if (xp.parse_bool("ignore_delay_bound", ignore_delay_bound)) continue;
|
|
|
|
if (xp.parse_bool("locality_scheduling", locality_scheduling)) continue;
|
|
|
|
if (xp.parse_double("locality_scheduler_fraction", locality_scheduler_fraction)) continue;
|
|
|
|
if (xp.parse_bool("locality_scheduling_sorted_order", locality_scheduling_sorted_order)) continue;
|
|
|
|
if (xp.parse_int("locality_scheduling_wait_period", locality_scheduling_wait_period)) continue;
|
|
|
|
if (xp.parse_int("locality_scheduling_send_timeout", locality_scheduling_send_timeout)) continue;
|
|
|
|
if (xp.parse_str("locality_scheduling_workunit_file", buf, sizeof(buf))) {
|
2009-03-03 00:25:41 +00:00
|
|
|
retval = regcomp(&re, buf, REG_EXTENDED|REG_NOSUB);
|
|
|
|
if (retval) {
|
|
|
|
log_messages.printf(MSG_CRITICAL, "BAD REGEXP: %s\n", buf);
|
|
|
|
} else {
|
|
|
|
locality_scheduling_workunit_file->push_back(re);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_str("locality_scheduling_sticky_file", buf, sizeof(buf))) {
|
2009-03-03 00:25:41 +00:00
|
|
|
retval = regcomp(&re, buf, REG_EXTENDED|REG_NOSUB);
|
|
|
|
if (retval) {
|
|
|
|
log_messages.printf(MSG_CRITICAL, "BAD REGEXP: %s\n", buf);
|
|
|
|
} else {
|
|
|
|
locality_scheduling_sticky_file->push_back(re);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_bool("matchmaker", matchmaker)) continue;
|
|
|
|
if (xp.parse_int("max_ncpus", max_ncpus)) continue;
|
|
|
|
if (xp.parse_int("max_wus_in_progress", itemp)) {
|
2010-06-01 23:41:07 +00:00
|
|
|
max_jobs_in_progress.project_limits.cpu.base_limit = itemp;
|
2011-04-04 22:15:04 +00:00
|
|
|
max_jobs_in_progress.project_limits.cpu.per_proc = true;
|
2010-06-01 23:41:07 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_int("max_wus_in_progress_gpu", itemp)) {
|
2010-06-01 23:41:07 +00:00
|
|
|
max_jobs_in_progress.project_limits.gpu.base_limit = itemp;
|
2011-04-04 22:15:04 +00:00
|
|
|
max_jobs_in_progress.project_limits.gpu.per_proc = true;
|
2010-06-01 23:41:07 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_int("max_wus_to_send", max_wus_to_send)) continue;
|
|
|
|
if (xp.parse_int("min_core_client_version", min_core_client_version)) {
|
2010-01-18 04:52:58 +00:00
|
|
|
if (min_core_client_version && min_core_client_version < 10000) {
|
|
|
|
log_messages.printf(MSG_CRITICAL,
|
|
|
|
"min_core_client_version too small; multiplying by 100\n"
|
|
|
|
);
|
|
|
|
min_core_client_version *= 100;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_int("min_core_client_version_announced", min_core_client_version_announced)) {
|
2010-01-18 04:52:58 +00:00
|
|
|
if (min_core_client_version_announced && min_core_client_version_announced < 10000) {
|
|
|
|
log_messages.printf(MSG_CRITICAL,
|
|
|
|
"min_core_client_version_announced too small; multiplying by 100\n"
|
|
|
|
);
|
|
|
|
min_core_client_version_announced *= 100;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_int("min_core_client_upgrade_deadline", min_core_client_upgrade_deadline)) continue;
|
|
|
|
if (xp.parse_int("min_sendwork_interval", min_sendwork_interval)) continue;
|
|
|
|
if (xp.parse_int("mm_min_slots", mm_min_slots)) continue;
|
|
|
|
if (xp.parse_int("mm_max_slots", mm_max_slots)) continue;
|
|
|
|
if (xp.parse_double("next_rpc_delay", next_rpc_delay)) continue;
|
|
|
|
if (xp.parse_bool("no_amd_k6", no_amd_k6)) {
|
2008-02-25 18:05:04 +00:00
|
|
|
if (no_amd_k6) {
|
|
|
|
regcomp(&re, ".*AMD.*\t.*Family 5 Model 8 Stepping 0.*", REG_EXTENDED|REG_NOSUB);
|
- server code: at some point I made a global var "SCHED_CONFIG config",
mostly so that the parse function could assume
that everything was initially zero.
However, various back-end functions pass around SCHED_CONFIG&
as an argument (also named "config").
This creates a shadow, which is always bad.
Worse is the possibility that some projects have back-end programs
that have a SCHED_CONFIG variable that's automatic,
and therefore isn't zero initially,
and therefore isn't parsing correctly.
To fix this, I changed the 2 vectors in SCHED_CONFIG into pointers,
and have the parse routine zero the structure.
I was tempted to remove the SCHED_CONFIG& args to back-end functions,
but this would have broken some projects' code.
I did, however, change the name from config to config_loc
to avoid shadowing.
Also fixed various other compiler warnings.
svn path=/trunk/boinc/; revision=15541
2008-07-02 17:24:53 +00:00
|
|
|
ban_cpu->push_back(re);
|
2008-02-25 18:05:04 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_bool("no_vista_sandbox", no_vista_sandbox)) continue;
|
|
|
|
if (xp.parse_bool("nowork_skip", nowork_skip)) continue;
|
|
|
|
if (xp.parse_bool("one_result_per_host_per_wu", one_result_per_host_per_wu)) continue;
|
|
|
|
if (xp.parse_bool("one_result_per_user_per_wu", one_result_per_user_per_wu)) continue;
|
|
|
|
if (xp.parse_int("reliable_max_avg_turnaround", reliable_max_avg_turnaround)) continue;
|
|
|
|
if (xp.parse_double("reliable_max_error_rate", reliable_max_error_rate)) continue;
|
|
|
|
if (xp.parse_double("reliable_reduced_delay_bound", reliable_reduced_delay_bound)) continue;
|
|
|
|
if (xp.parse_str("replace_download_url_by_timezone", replace_download_url_by_timezone, sizeof(replace_download_url_by_timezone))) continue;
|
|
|
|
if (xp.parse_int("max_download_urls_per_file", max_download_urls_per_file)) continue;
|
|
|
|
if (xp.parse_int("report_max", report_max)) continue;
|
|
|
|
if (xp.parse_bool("request_time_stats_log", request_time_stats_log)) continue;
|
|
|
|
if (xp.parse_bool("resend_lost_results", resend_lost_results)) continue;
|
|
|
|
if (xp.parse_int("sched_debug_level", sched_debug_level)) continue;
|
2012-02-27 12:40:43 +00:00
|
|
|
if (xp.parse_int("scheduler_log_buffer", scheduler_log_buffer)) continue;
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_str("sched_lockfile_dir", sched_lockfile_dir, sizeof(sched_lockfile_dir))) continue;
|
|
|
|
if (xp.parse_bool("send_result_abort", send_result_abort)) continue;
|
|
|
|
if (xp.parse_str("symstore", symstore, sizeof(symstore))) continue;
|
2008-05-23 16:13:30 +00:00
|
|
|
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_bool("user_filter", user_filter)) continue;
|
|
|
|
if (xp.parse_bool("workload_sim", workload_sim)) continue;
|
|
|
|
if (xp.parse_bool("prefer_primary_platform", prefer_primary_platform)) continue;
|
2012-02-22 19:51:09 +00:00
|
|
|
if (xp.parse_double("version_select_random_factor", version_select_random_factor)) continue;
|
2010-06-01 03:45:49 +00:00
|
|
|
|
|
|
|
//////////// SCHEDULER LOG FLAGS /////////
|
|
|
|
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_bool("debug_array", debug_array)) continue;
|
|
|
|
if (xp.parse_bool("debug_assignment", debug_assignment)) continue;
|
|
|
|
if (xp.parse_bool("debug_credit", debug_credit)) continue;
|
|
|
|
if (xp.parse_bool("debug_edf_sim_detail", debug_edf_sim_detail)) continue;
|
|
|
|
if (xp.parse_bool("debug_edf_sim_workload", debug_edf_sim_workload)) continue;
|
|
|
|
if (xp.parse_bool("debug_fcgi", debug_fcgi)) continue;
|
|
|
|
if (xp.parse_bool("debug_handle_results", debug_handle_results)) continue;
|
|
|
|
if (xp.parse_bool("debug_locality", debug_locality)) continue;
|
|
|
|
if (xp.parse_bool("debug_prefs", debug_prefs)) continue;
|
|
|
|
if (xp.parse_bool("debug_quota", debug_quota)) continue;
|
|
|
|
if (xp.parse_bool("debug_request_details", debug_request_details)) continue;
|
|
|
|
if (xp.parse_bool("debug_request_headers", debug_request_headers)) continue;
|
|
|
|
if (xp.parse_bool("debug_resend", debug_resend)) continue;
|
|
|
|
if (xp.parse_bool("debug_send", debug_send)) continue;
|
|
|
|
if (xp.parse_bool("debug_user_messages", debug_user_messages)) continue;
|
2012-02-28 06:57:28 +00:00
|
|
|
if (xp.parse_bool("debug_vda", debug_vda)) continue;
|
2011-08-10 17:11:08 +00:00
|
|
|
if (xp.parse_bool("debug_version_select", debug_version_select)) continue;
|
2007-06-27 20:09:18 +00:00
|
|
|
|
2012-02-27 13:12:24 +00:00
|
|
|
if (xp.parse_str("debug_req_reply_dir", debug_req_reply_dir, sizeof(debug_req_reply_dir))) continue;
|
|
|
|
|
2007-06-27 20:09:18 +00:00
|
|
|
// don't complain about unparsed XML;
|
|
|
|
// there are lots of tags the scheduler doesn't know about
|
|
|
|
|
2011-08-10 17:11:08 +00:00
|
|
|
xp.skip_unexpected(false, "SCHED_CONFIG::parse");
|
2006-05-25 05:22:10 +00:00
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
2005-02-16 23:17:43 +00:00
|
|
|
int SCHED_CONFIG::parse_file(const char* dir) {
|
2010-06-03 04:59:27 +00:00
|
|
|
char path[256], path_aux[256];
|
2004-04-30 23:18:56 +00:00
|
|
|
int retval;
|
2002-10-03 18:33:46 +00:00
|
|
|
|
2010-06-03 04:59:27 +00:00
|
|
|
if (dir && strlen(dir)) {
|
2009-05-07 13:54:51 +00:00
|
|
|
snprintf(path, sizeof(path), "%s/%s", dir, CONFIG_FILE);
|
2010-06-03 04:59:27 +00:00
|
|
|
snprintf(path_aux, sizeof(path_aux), "%s/%s", dir, CONFIG_FILE_AUX);
|
2009-05-07 13:54:51 +00:00
|
|
|
} else {
|
|
|
|
strcpy(path, project_path(CONFIG_FILE));
|
2010-06-03 04:59:27 +00:00
|
|
|
strcpy(path_aux, project_path(CONFIG_FILE_AUX));
|
2009-05-07 13:54:51 +00:00
|
|
|
}
|
2008-09-09 19:10:42 +00:00
|
|
|
#ifndef _USING_FCGI_
|
2006-05-25 05:22:10 +00:00
|
|
|
FILE* f = fopen(path, "r");
|
2008-09-09 19:10:42 +00:00
|
|
|
#else
|
|
|
|
FCGI_FILE *f = FCGI::fopen(path, "r");
|
|
|
|
#endif
|
2006-05-25 05:22:10 +00:00
|
|
|
if (!f) return ERR_FOPEN;
|
|
|
|
retval = parse(f);
|
|
|
|
fclose(f);
|
2010-06-03 04:59:27 +00:00
|
|
|
if (retval) return retval;
|
|
|
|
|
|
|
|
#ifndef _USING_FCGI_
|
|
|
|
FILE* f_aux = fopen(path_aux, "r");
|
|
|
|
#else
|
|
|
|
FCGI_FILE *f_aux = FCGI::fopen(path_aux, "r");
|
|
|
|
#endif
|
|
|
|
if (!f_aux) return 0;
|
|
|
|
retval = parse_aux(f_aux);
|
|
|
|
fclose(f_aux);
|
2006-05-25 05:22:10 +00:00
|
|
|
return retval;
|
2002-10-03 18:33:46 +00:00
|
|
|
}
|
2004-04-04 02:59:42 +00:00
|
|
|
|
2007-04-19 22:11:25 +00:00
|
|
|
int SCHED_CONFIG::upload_path(const char* filename, char* path) {
|
2009-06-10 17:42:18 +00:00
|
|
|
return dir_hier_path(filename, upload_dir, uldl_dir_fanout, path, true);
|
2007-04-19 03:12:13 +00:00
|
|
|
}
|
|
|
|
|
2007-04-19 22:11:25 +00:00
|
|
|
int SCHED_CONFIG::download_path(const char* filename, char* path) {
|
2009-06-10 17:42:18 +00:00
|
|
|
return dir_hier_path(filename, download_dir, uldl_dir_fanout, path, true);
|
2007-04-18 20:49:58 +00:00
|
|
|
}
|
|
|
|
|
2011-04-21 17:04:42 +00:00
|
|
|
static bool is_project_dir(const char* dir) {
|
|
|
|
char buf[1024];
|
|
|
|
sprintf(buf, "%s/%s", dir, CONFIG_FILE);
|
|
|
|
if (!is_file(buf)) return false;
|
|
|
|
sprintf(buf, "%s/cgi-bin", dir);
|
|
|
|
if (!is_dir(buf)) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-05-07 13:54:51 +00:00
|
|
|
// Does 2 things:
|
|
|
|
// - locate project directory. This is either
|
|
|
|
// a) env var BOINC_PROJECT_DIR, if defined
|
|
|
|
// b) current dir, if config.xml exists there
|
|
|
|
// c) parent dir, if config.xml exists there
|
|
|
|
// - returns a path relative to the project dir,
|
|
|
|
// specified by a format string + args
|
|
|
|
//
|
|
|
|
const char *SCHED_CONFIG::project_path(const char *fmt, ...) {
|
|
|
|
static char path[1024];
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
if (!strlen(project_dir)) {
|
|
|
|
char *p = getenv("BOINC_PROJECT_DIR");
|
|
|
|
if (p) {
|
2011-04-21 17:04:42 +00:00
|
|
|
if (!is_project_dir(p)) {
|
|
|
|
fprintf(stderr, "BOINC_PROJECT_DIR env var exists but is not a project dir\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2009-05-07 13:54:51 +00:00
|
|
|
strlcpy(project_dir, p, sizeof(project_dir));
|
2011-04-21 17:04:42 +00:00
|
|
|
} else if (is_project_dir(".")) {
|
2009-05-07 13:54:51 +00:00
|
|
|
strcpy(project_dir, ".");
|
2011-04-21 17:04:42 +00:00
|
|
|
} else if (is_project_dir("..")) {
|
2009-05-07 13:54:51 +00:00
|
|
|
strcpy(project_dir, "..");
|
2011-04-21 17:04:42 +00:00
|
|
|
} else {
|
|
|
|
fprintf(stderr, "Not in a project directory or subdirectory\n");
|
|
|
|
exit(1);
|
2009-05-07 13:54:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
snprintf(path, sizeof(path), "%s/", project_dir);
|
|
|
|
vsnprintf(path + strlen(path), sizeof(path) - strlen(path), fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
return (const char *)path;
|
2004-04-04 02:59:42 +00:00
|
|
|
}
|
2004-12-08 00:40:19 +00:00
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_3704204cfd = "$Id$";
|