- client, Mac: don't do res_init(). It causes a crash.

- client (Unix): if client crashes while benchmark processes are going,
    make sure they detect this and exit.
- back-end programs: remove hardwired assumptions about
    what directory they run in, and hence where config.xml is.
    E.g., daemons look for it in "..", others expect it in current dir.
    New approach: all the programs look for the project dir as follows:
    1) the environment var BOINC_PROJECT_DIR, if defined
    2) the current dir, if config.xml is there.
    3) else ".."
    This means you can run programs in either proj/bin/ or proj/,
    or (using BOINC_PROJECT_DIR) you can keep executables
    outside of the project dir.


svn path=/trunk/boinc/; revision=18042
This commit is contained in:
David Anderson 2009-05-07 13:54:51 +00:00
parent 4aaab7f2ef
commit 12eb6057e5
39 changed files with 224 additions and 146 deletions

View File

@ -4356,3 +4356,30 @@ David 6 May 2009
feeder.cpp
handle_request.cpp
sched_send.cpp
David 7 May 2009
- client, Mac: don't do res_init(). It causes a crash.
- client (Unix): if client crashes while benchmark processes are going,
make sure they detect this and exit.
- back-end programs: remove hardwired assumptions about
what directory they run in, and hence where config.xml is.
E.g., daemons look for it in "..", others expect it in current dir.
New approach: all the programs look for the project dir as follows:
1) the environment var BOINC_PROJECT_DIR, if defined
2) the current dir, if config.xml is there.
3) else ".."
This means you can run programs in either proj/bin/ or proj/,
or (using BOINC_PROJECT_DIR) you can keep executables
outside of the project dir.
client/
cpu_sched.cpp
cs_benchmark.cpp
lib/
network.cpp
sched/
*.cpp
tools/
backend_lib.cpp
create_work.cpp
dir_hier_path.cpp

View File

@ -735,12 +735,21 @@ static inline bool more_important(RESULT* r0, RESULT* r1) {
return (r0 < r1);
}
static void print_job_list(vector<RESULT*>& jobs) {
static void print_job_list(vector<RESULT*>& jobs, bool details) {
for (unsigned int i=0; i<jobs.size(); i++) {
RESULT* rp = jobs[i];
msg_printf(rp->project, MSG_INFO,
"[cpu_sched_debug] %d: %s", i, rp->name
);
if (details) {
msg_printf(rp->project, MSG_INFO,
"[cpu_sched_debug] %d: %s", i, rp->name
);
} else {
msg_printf(rp->project, MSG_INFO,
"[cpu_sched_debug] %d: %s (MD: %s; UTS: %s)",
i, rp->name,
rp->rr_sim_misses_deadline?"yes":"no",
rp->unfinished_time_slice?"yes":"no"
);
}
}
}
@ -808,7 +817,7 @@ bool CLIENT_STATE::enforce_schedule() {
if (log_flags.cpu_sched_debug) {
msg_printf(0, MSG_INFO, "[cpu_sched_debug] enforce_schedule(): start");
msg_printf(0, MSG_INFO, "[cpu_sched_debug] preliminary job list:");
print_job_list(ordered_scheduled_results);
print_job_list(ordered_scheduled_results, false);
}
// Set next_scheduler_state to preempt for all tasks
@ -842,7 +851,7 @@ bool CLIENT_STATE::enforce_schedule() {
if (log_flags.cpu_sched_debug) {
msg_printf(0, MSG_INFO, "[cpu_sched_debug] final job list:");
print_job_list(runnable_jobs);
print_job_list(runnable_jobs, true);
}
double ram_left = available_ram();

View File

@ -135,6 +135,14 @@ void benchmark_wait_to_start(int which) {
if (boinc_file_exists(file_names[which])) {
break;
}
#ifndef _WIN32
// UNIX: check if client has died.
// Not needed on windows, where we run as thread in client process
//
if (getppid() == 1) {
exit(0);
}
#endif
boinc_sleep(0.1);
}
}
@ -143,6 +151,11 @@ bool benchmark_time_to_stop(int which) {
if (boinc_file_exists(file_names[which])) {
return false;
}
#ifndef _WIN32
if (getppid() == 1) {
exit(0);
}
#endif
return true;
}

View File

@ -203,7 +203,8 @@ int WinsockCleanup() {
#endif
void reset_dns() {
#ifndef _WIN32
#if !defined(_WIN32) && !defined(__APPLE__)
// Windows doesn't have this, and it crashes Macs
res_init();
#endif
}

View File

@ -251,10 +251,10 @@ int main(int argc, char** argv) {
);
}
retval = config.parse_file("..");
retval = config.parse_file();
if (retval) {
log_messages.printf(MSG_CRITICAL,
"Can't parse ../config.xml: %s\n", boincerror(retval)
"Can't parse config.xml: %s\n", boincerror(retval)
);
exit(1);
}

View File

@ -54,10 +54,10 @@ int main(int argc, char** argv) {
}
}
check_stop_daemons();
retval = config.parse_file("..");
retval = config.parse_file();
if (retval) {
log_messages.printf(MSG_CRITICAL,
"Can't parse ../config.xml: %s\n", boincerror(retval)
"Can't parse config.xml: %s\n", boincerror(retval)
);
exit(1);
}

View File

@ -803,10 +803,10 @@ int main(int argc, char** argv) {
}
log_messages.printf(MSG_NORMAL, "Starting\n");
retval = config.parse_file("..");
retval = config.parse_file();
if (retval) {
log_messages.printf(MSG_CRITICAL,
"Can't parse ../config.xml: %s\n", boincerror(retval)
"Can't parse config.xml: %s\n", boincerror(retval)
);
exit(1);
}

View File

@ -52,6 +52,7 @@
#include "sched_msgs.h"
#include "error_numbers.h"
#include "str_util.h"
#define WU_FILENAME_PREFIX "wu_archive"
#define RESULT_FILENAME_PREFIX "result_archive"
@ -107,7 +108,7 @@ void open_archive(const char* filename_prefix, FILE*& f){
char command[512];
// append appropriate suffix for file type
sprintf(path, "../archives/%s_%d.xml", filename_prefix, time_int);
strcpy(path, config.project_path("archives/%s_%d.xml", filename_prefix, time_int));
strcat(path, suffix[compression_type]);
// and construct appropriate command if needed
@ -172,7 +173,7 @@ void close_archive(const char *filename, FILE*& fp){
fp = NULL;
// append appropriate file type
sprintf(path, "../archives/%s_%d.xml", filename, time_int);
strcpy(path, config.project_path("archives/%s_%d.xml", filename, time_int));
strcat(path, suffix[compression_type]);
log_messages.printf(MSG_NORMAL,
@ -614,10 +615,10 @@ int main(int argc, char** argv) {
}
}
retval = config.parse_file("..");
retval = config.parse_file();
if (retval) {
log_messages.printf(MSG_CRITICAL,
"Can't parse config file\n"
"Can't parse config.xml: %s\n", boincerror(retval)
);
exit(1);
}
@ -632,7 +633,7 @@ int main(int argc, char** argv) {
exit(2);
}
install_stop_signal_handler();
boinc_mkdir("../archives");
boinc_mkdir(config.project_path("archives"));
// on exit, either via the check_stop_daemons signal handler, or
// through a regular call to exit, these functions will be called

View File

@ -92,9 +92,9 @@ int main(int argc, char** argv) {
usage(argv);
}
retval = config.parse_file(".");
retval = config.parse_file();
if (retval) {
fprintf(stderr, "Can't parse ../config.xml: %s\n", boincerror(retval));
fprintf(stderr, "Can't parse config.xml: %s\n", boincerror(retval));
exit(1);
}

View File

@ -122,7 +122,7 @@ using std::vector;
#define DEFAULT_SLEEP_INTERVAL 5
#define REREAD_DB_FILENAME "../reread_db"
#define REREAD_DB_FILENAME "reread_db"
#define ENUM_FIRST_PASS 0
#define ENUM_SECOND_PASS 1
@ -173,7 +173,7 @@ void cleanup_shmem() {
int check_reread_trigger() {
FILE* f;
f = fopen(REREAD_DB_FILENAME, "r");
f = fopen(config.project_path(REREAD_DB_FILENAME), "r");
if (f) {
fclose(f);
log_messages.printf(MSG_NORMAL,
@ -182,7 +182,7 @@ int check_reread_trigger() {
);
ssp->init(num_work_items);
ssp->scan_tables();
int retval = unlink(REREAD_DB_FILENAME);
int retval = unlink(config.project_path(REREAD_DB_FILENAME));
if (retval) {
// if we can't remove trigger file, exit to avoid infinite loop
//
@ -635,16 +635,16 @@ int main(int argc, char** argv) {
char path[256];
char* appids=NULL;
unlink(REREAD_DB_FILENAME);
retval = config.parse_file("..");
retval = config.parse_file();
if (retval) {
log_messages.printf(MSG_CRITICAL,
"Can't parse ../config.xml: %s\n", boincerror(retval)
"Can't parse config.xml: %s\n", boincerror(retval)
);
exit(1);
}
unlink(config.project_path(REREAD_DB_FILENAME));
if (argc == 2 && !strcmp(argv[1], "--version")) {
show_version();
exit(0);
@ -693,7 +693,7 @@ int main(int argc, char** argv) {
if (config.shmem_work_items) {
num_work_items = config.shmem_work_items;
}
get_project_dir(path, sizeof(path));
strncpy(path, config.project_dir, sizeof(path));
get_key(path, 'a', sema_key);
destroy_semaphore(sema_key);
create_semaphore(sema_key);

View File

@ -634,10 +634,10 @@ int main(int argc, char** argv) {
);
}
retval = config.parse_file("..");
retval = config.parse_file();
if (retval) {
log_messages.printf(MSG_CRITICAL,
"Can't parse ../config.xml: %s\n", boincerror(retval)
"Can't parse config.xml: %s\n", boincerror(retval)
);
exit(1);
}

View File

@ -40,6 +40,7 @@
#include "parse.h"
#include "util.h"
#include "error_numbers.h"
#include "str_util.h"
#include "filesys.h"
#include "sched_config.h"
@ -638,9 +639,9 @@ int main() {
}
#endif
retval = config.parse_file("..");
retval = config.parse_file();
if (retval) {
fprintf(stderr, "Can't parse config file\n");
fprintf(stderr, "Can't parse config.xml: %s\n", boincerror(retval));
return_error(ERR_TRANSIENT,
"can't parse config file", log_path, errno
);
@ -650,7 +651,7 @@ int main() {
log_messages.pid = getpid();
log_messages.set_debug_level(config.fuh_debug_level);
if (boinc_file_exists("../stop_upload")) {
if (boinc_file_exists(config.project_path("stop_upload"))) {
return_error(ERR_TRANSIENT, "Maintenance underway: file uploads are temporarily disabled.");
exit(1);
}

View File

@ -179,9 +179,9 @@ int main(int argc, char** argv) {
exit(1);
}
retval = config.parse_file(".");
retval = config.parse_file();
if (retval) {
fprintf(stderr, "Can't parse ../config.xml: %s\n", boincerror(retval));
fprintf(stderr, "Can't parse config.xml: %s\n", boincerror(retval));
exit(1);
}

View File

@ -68,8 +68,8 @@
#define DEBUG_LEVEL 999
#define MAX_FCGI_COUNT 20
#define REQ_FILE_PREFIX "../boinc_req/"
#define REPLY_FILE_PREFIX "../boinc_reply/"
#define REQ_FILE_PREFIX "boinc_req/"
#define REPLY_FILE_PREFIX "boinc_reply/"
bool use_files = false; // use disk files for req/reply msgs (for debugging)
GUI_URLS gui_urls;
@ -106,7 +106,7 @@ void debug_sched(const char *trigger) {
FCGI_FILE *fp;
#endif
if (!boinc_file_exists(trigger)) {
if (!boinc_file_exists(config.project_path("%s", trigger))) {
return;
}
@ -282,7 +282,7 @@ void set_core_dump_size_limit() {
void attach_to_feeder_shmem() {
char path[256];
get_project_dir(path, sizeof(path));
strncpy(path, config.project_dir, sizeof(path));
get_key(path, 'a', sema_key);
int i, retval;
void* p;
@ -423,10 +423,10 @@ int main(int argc, char** argv) {
set_core_dump_size_limit();
#endif
retval = config.parse_file("..");
retval = config.parse_file();
if (retval) {
log_messages.printf(MSG_CRITICAL,
"Can't parse ../config.xml: %s\n", boincerror(retval)
"Can't parse config.xml: %s\n", boincerror(retval)
);
send_message("Server can't parse configuration file", 3600);
exit(0);
@ -482,8 +482,8 @@ int main(int argc, char** argv) {
// NOTE: to use this, you must create group-writeable dirs
// boinc_req and boinc_reply in the project dir
//
sprintf(req_path, "%s%d_%u", REQ_FILE_PREFIX, g_pid, counter);
sprintf(reply_path, "%s%d_%u", REPLY_FILE_PREFIX, g_pid, counter);
sprintf(req_path, "%s%d_%u", config.project_path(REQ_FILE_PREFIX), g_pid, counter);
sprintf(reply_path, "%s%d_%u", config.project_path(REPLY_FILE_PREFIX), g_pid, counter);
#ifndef _USING_FCGI_
fout = fopen(req_path, "w");
#else

View File

@ -48,6 +48,7 @@ using std::string;
#include "parse.h"
#include "sched_util.h"
#include "sched_msgs.h"
#include "str_util.h"
#define LOCKFILE "make_work.out"
#define PIDFILE "make_work.pid"
@ -178,9 +179,9 @@ void make_work(vector<string> &wu_names) {
int i;
static int index=0;
retval = config.parse_file("..");
retval = config.parse_file();
if (retval) {
log_messages.printf(MSG_CRITICAL, "can't read config file\n");
log_messages.printf(MSG_CRITICAL, "Can't parse config.xml: %s\n", boincerror(retval));
exit(1);
}

View File

@ -147,10 +147,10 @@ int main(int argc, char** argv) {
}
}
retval = config.parse_file("..");
retval = config.parse_file();
if (retval) {
log_messages.printf(MSG_CRITICAL,
"Can't parse ../config.xml: %s\n", boincerror(retval)
"Can't parse config.xml: %s\n", boincerror(retval)
);
exit(1);
}

View File

@ -103,9 +103,9 @@ int main(int argc, char** argv) {
exit(1);
}
retval = config.parse_file(".");
retval = config.parse_file();
if (retval) {
fprintf(stderr, "Can't parse ../config.xml: %s\n", boincerror(retval));
fprintf(stderr, "Can't parse config.xml: %s\n", boincerror(retval));
exit(1);
}

View File

@ -36,7 +36,7 @@ using std::string;
int write_error(char* p) {
static FILE* f = 0;
if (!f) {
f = fopen("../sample_results/errors", "a");
f = fopen(config.project_path("sample_results/errors"), "a");
if (!f) return ERR_FOPEN;
}
fprintf(f, "%s", p);
@ -51,20 +51,20 @@ int assimilate_handler(
char buf[1024];
unsigned int i;
retval = boinc_mkdir("../sample_results");
retval = boinc_mkdir(config.project_path("sample_results"));
if (retval) return retval;
if (wu.canonical_resultid) {
vector<FILE_INFO> output_files;
char copy_path[256];
const char *copy_path;
get_output_file_infos(canonical_result, output_files);
unsigned int n = output_files.size();
for (i=0; i<n; i++) {
FILE_INFO& fi = output_files[i];
if (n==1) {
sprintf(copy_path, "../sample_results/%s", wu.name);
copy_path = config.project_path("sample_results/%s", wu.name);
} else {
sprintf(copy_path, "../sample_results/%s_%d", wu.name, i);
copy_path = config.project_path("sample_results/%s_%d", wu.name, i);
}
retval = boinc_copy(fi.path.c_str() , copy_path);
if (retval && !fi.optional) {

View File

@ -41,6 +41,7 @@
#include "sched_config.h"
#include "sched_util.h"
#include "sched_msgs.h"
#include "str_util.h"
#define CUSHION 100
// maintain at least this many unsent results
@ -98,7 +99,7 @@ int make_job() {
wu,
wu_template,
"templates/uc_result",
"../templates/uc_result",
config.project_path("templates/uc_result"),
infiles,
1,
config
@ -149,9 +150,10 @@ int main(int argc, char** argv) {
}
}
if (config.parse_file("..")) {
retval = config.parse_file();
if (retval) {
log_messages.printf(MSG_CRITICAL,
"can't read config file\n"
"Can't parse config.xml: %s\n", boincerror(retval)
);
exit(1);
}
@ -167,7 +169,7 @@ int main(int argc, char** argv) {
log_messages.printf(MSG_CRITICAL, "can't find app\n");
exit(1);
}
if (read_file_malloc("../templates/uc_wu", wu_template)) {
if (read_file_malloc(config.project_path("templates/uc_wu"), wu_template)) {
log_messages.printf(MSG_CRITICAL, "can't read WU template\n");
exit(1);
}

View File

@ -41,7 +41,8 @@
static int send_assigned_job(ASSIGNMENT& asg) {
int retval;
DB_WORKUNIT wu;
char rtfpath[256], suffix[256], path[256], buf[256];
char suffix[256], path[256], buf[256];
const char *rtfpath;
static bool first=true;
static int seqno=0;
static R_RSA_PRIVATE_KEY key;
@ -73,9 +74,9 @@ static int send_assigned_job(ASSIGNMENT& asg) {
return ERR_NOT_FOUND;
}
sprintf(rtfpath, "../%s", wu.result_template_file);
rtfpath = config.project_path("%s", wu.result_template_file);
sprintf(suffix, "%d_%d_%d", getpid(), (int)time(0), seqno++);
retval = create_result(wu, rtfpath, suffix, key, config, 0, 0);
retval = create_result(wu, (char *)rtfpath, suffix, key, config, 0, 0);
if (retval) {
log_messages.printf(MSG_CRITICAL,
"[WU#%d %s] create_result() %d\n", wu.id, wu.name, retval

View File

@ -27,6 +27,8 @@
#include "parse.h"
#include "error_numbers.h"
#include "filesys.h"
#include "str_util.h"
#include "sched_msgs.h"
#include "sched_util.h"
@ -84,6 +86,7 @@ int SCHED_CONFIG::parse(FILE* f) {
if (xp.parse_str(tag, "db_user", db_user, sizeof(db_user))) continue;
if (xp.parse_str(tag, "db_passwd", db_passwd, sizeof(db_passwd))) continue;
if (xp.parse_str(tag, "db_host", db_host, sizeof(db_host))) continue;
if (xp.parse_str(tag, "project_dir", project_dir, sizeof(project_dir))) continue;
if (xp.parse_int(tag, "shmem_key", shmem_key)) continue;
if (xp.parse_str(tag, "key_dir", key_dir, sizeof(key_dir))) continue;
if (xp.parse_str(tag, "download_url", download_url, sizeof(download_url))) continue;
@ -237,12 +240,11 @@ int SCHED_CONFIG::parse_file(const char* dir) {
char path[256];
int retval;
char* p = getenv("BOINC_CONFIG_XML");
if (p) {
strcpy(path, p);
} else {
sprintf(path, "%s/%s", dir, CONFIG_FILE);
}
if (dir && dir[0]) {
snprintf(path, sizeof(path), "%s/%s", dir, CONFIG_FILE);
} else {
strcpy(path, project_path(CONFIG_FILE));
}
#ifndef _USING_FCGI_
FILE* f = fopen(path, "r");
#else
@ -262,10 +264,34 @@ int SCHED_CONFIG::download_path(const char* filename, char* path) {
return ::dir_hier_path(filename, download_dir, uldl_dir_fanout, path, true);
}
void get_project_dir(char* p, int len) {
getcwd(p, len);
char* q = strrchr(p, '/');
if (q) *q = 0;
// 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) {
strlcpy(project_dir, p, sizeof(project_dir));
} else if (boinc_file_exists(CONFIG_FILE)) {
strcpy(project_dir, ".");
} else {
strcpy(project_dir, "..");
}
}
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;
}
const char *BOINC_RCSID_3704204cfd = "$Id$";

View File

@ -35,6 +35,7 @@ public:
char db_passwd[256];
char db_host[256];
int shmem_key;
char project_dir[256];
char key_dir[256];
char download_url[256];
char download_dir[256];
@ -148,17 +149,14 @@ public:
bool debug_array; // debug old-style array scheduling
int parse(FILE*);
int parse_file(const char* dir=".");
int parse_file(const char *dir = 0);
int upload_path(const char*, char*);
int download_path(const char*, char*);
const char *project_path(const char *, ...);
};
extern SCHED_CONFIG config;
// get the project's home directory
// (assumed to be the parent of the CWD)
//
void get_project_dir(char*, int);
#endif

View File

@ -43,6 +43,7 @@
#include "sched_send.h"
#include "sched_util.h"
#include "sched_version.h"
#include "sched_config.h"
#define VERBOSE_DEBUG
@ -306,9 +307,7 @@ static int possibly_send_result(DB_RESULT& result) {
// file, false if it can.
//
static bool work_generation_over(char *filename) {
char fullpath[512];
sprintf(fullpath, "../locality_scheduling/no_work_available/%s", filename);
return boinc_file_exists(fullpath);
return boinc_file_exists(config.project_path("locality_scheduling/no_work_available/%s", filename));
}
// Ask the WU generator to make more WUs for this file.
@ -317,7 +316,7 @@ static bool work_generation_over(char *filename) {
// (no way to be sure if it suceeded).
//
int make_more_work_for_file(char* filename) {
char fullpath[512];
const char *fullpath;
if (work_generation_over(filename)) {
// since we found this file, it means that no work remains for this WU.
@ -334,7 +333,7 @@ int make_more_work_for_file(char* filename) {
// directory as a way of indicating that we need work for this file.
// If this operation fails, don't worry or tarry!
//
sprintf(fullpath, "../locality_scheduling/need_work/%s", filename);
fullpath = config.project_path("locality_scheduling/need_work/%s", filename);
if (boinc_touch_file(fullpath)) {
log_messages.printf(MSG_CRITICAL, "unable to touch %s\n", fullpath);
return -1;
@ -362,14 +361,14 @@ static void build_working_set_namelist(bool slowhost) {
glob_t globbuf;
int retglob;
unsigned int i;
const char *pattern = "../locality_scheduling/work_available/*";
const char *pattern = config.project_path("locality_scheduling/work_available/*");
const char *errtype = "unrecognized error";
const char *hosttype = "fasthost";
#ifdef EINSTEIN_AT_HOME
if (slowhost) {
hosttype = "slowhost";
pattern = "../locality_scheduling/work_available/*_0[0-3]*";
pattern = config.project_path("locality_scheduling/work_available/*_0[0-3]*");
}
#endif
@ -469,9 +468,7 @@ static int get_working_set_filename(char *filename, bool slowhost) {
static void flag_for_possible_removal(char* filename) {
char path[256];
sprintf(path, "../locality_scheduling/working_set_removal/%s", filename);
boinc_touch_file(path);
boinc_touch_file(config.project_path("locality_scheduling/working_set_removal/%s", filename));
return;
}
@ -1203,9 +1200,9 @@ void send_file_deletes() {
}
if (g_reply->results.size()==0 && g_reply->hostid && g_request->work_req_seconds>1.0) {
debug_sched("../debug_sched");
debug_sched("debug_sched");
} else if (max_allowable_disk()<0 || (g_reply->wreq.disk.insufficient || g_reply->wreq.disk_available<0)) {
debug_sched("../debug_sched");
debug_sched("debug_sched");
}
}

View File

@ -108,16 +108,16 @@ URLTYPE* read_download_list() {
if (cached) return cached;
const char *download_servers = config.project_path("download_servers");
#ifndef _USING_FCGI_
FILE *fp=fopen("../download_servers", "r");
FILE *fp=fopen(download_servers, "r");
#else
FCGI_FILE *fp=FCGI::fopen("../download_servers", "r");
FCGI_FILE *fp=FCGI::fopen(download_servers, "r");
#endif
if (!fp) {
log_messages.printf(MSG_CRITICAL,
"File ../download_servers not found or unreadable!\n"
"File %s not found or unreadable!\n", download_servers
);
return NULL;
}
@ -145,9 +145,10 @@ URLTYPE* read_download_list() {
if (!count) {
log_messages.printf(MSG_CRITICAL,
"File ../download_servers contained no valid entries!\n"
"File %s contained no valid entries!\n"
"Format of this file is one or more lines containing:\n"
"TIMEZONE_OFFSET_IN_SEC http://some.url.path\n"
"TIMEZONE_OFFSET_IN_SEC http://some.url.path\n",
download_servers
);
free(cached);
return NULL;

View File

@ -31,15 +31,16 @@
#include "sched_msgs.h"
#include "sched_util.h"
#include "sched_config.h"
#include "util.h"
#ifdef _USING_FCGI_
#include "boinc_fcgi.h"
#endif
const char* STOP_DAEMONS_FILENAME = "../stop_daemons";
const char* STOP_DAEMONS_FILENAME = "stop_daemons";
// NOTE: this must be same as in the "start" script
const char* STOP_SCHED_FILENAME = "../stop_sched";
const char* STOP_SCHED_FILENAME = "stop_sched";
// NOTE: this must be same as in the "start" script
const int STOP_SIGNAL = SIGHUP;
// NOTE: this must be same as in the "start" script
@ -77,17 +78,18 @@ void check_stop_daemons() {
log_messages.printf(MSG_NORMAL, "Quitting due to SIGHUP\n");
exit(0);
}
if (boinc_file_exists(STOP_DAEMONS_FILENAME)) {
const char *stop_file = config.project_path(STOP_DAEMONS_FILENAME);
if (boinc_file_exists(stop_file)) {
log_messages.printf(MSG_NORMAL,
"Quitting because trigger file '%s' is present\n",
STOP_DAEMONS_FILENAME
stop_file
);
exit(0);
}
}
bool check_stop_sched() {
return boinc_file_exists(STOP_SCHED_FILENAME);
return boinc_file_exists(config.project_path(STOP_SCHED_FILENAME));
}
// try to open a file.
@ -133,11 +135,12 @@ int try_fopen(const char* path, FCGI_FILE*& f, const char *mode) {
void get_log_path(char* p, const char* filename) {
char host[256];
char dir[256];
const char *dir;
gethostname(host, 256);
char* q = strchr(host, '.');
if (q) *q=0;
sprintf(dir, "../log_%s", host);
dir = config.project_path("log_%s", host);
sprintf(p, "%s/%s", dir, filename);
mode_t old_mask = umask(0);
mkdir(dir, 01770);
@ -285,7 +288,7 @@ int count_unsent_results(int& n, int appid) {
void simulator_signal_handler(int signum){
FILE *fsim;
char currenttime[64];
fsim = fopen("../simulator/sim_time.txt","r");
fsim = fopen(config.project_path("simulator/sim_time.txt"),"r");
if(fsim){
fscanf(fsim,"%s", currenttime);
simtime = atof(currenttime);
@ -303,8 +306,8 @@ int itime() {
void continue_simulation(const char *daemonname){
char daemonfilelok[64];
char daemonfile[64];
sprintf(daemonfile, "../simulator/sim_%s.txt",daemonname);
sprintf(daemonfilelok, "../simulator/sim_%s.lok",daemonname);
sprintf(daemonfile, config.project_path("simulator/sim_%s.txt"),daemonname);
sprintf(daemonfilelok, config.project_path("simulator/sim_%s.lok"),daemonname);
FILE *fsimlok = fopen(daemonfilelok, "w");
if (fsimlok){
fclose(fsimlok);

View File

@ -194,9 +194,9 @@ int main(int argc, char** argv) {
);
exit(1);
}
retval = config.parse_file(".");
retval = config.parse_file();
if (retval) {
fprintf(stderr, "Can't parse ../config.xml: %s\n", boincerror(retval));
fprintf(stderr, "Can't parse config.xml: %s\n", boincerror(retval));
exit(1);
}

View File

@ -1168,7 +1168,7 @@ void GLOBAL_PREFS::defaults() {
void GUI_URLS::init() {
text = 0;
read_file_malloc("../gui_urls.xml", text);
read_file_malloc(config.project_path("gui_urls.xml"), text);
}
void GUI_URLS::get_gui_urls(USER& user, HOST& host, TEAM& team, char* buf) {
@ -1203,7 +1203,7 @@ void GUI_URLS::get_gui_urls(USER& user, HOST& host, TEAM& team, char* buf) {
void PROJECT_FILES::init() {
text = 0;
read_file_malloc("../project_files.xml", text);
read_file_malloc(config.project_path("project_files.xml"), text);
}
const char *BOINC_RCSID_ea659117b3 = "$Id$";

View File

@ -26,15 +26,16 @@
#include "shmem.h"
#include "sched_config.h"
#include "sched_shmem.h"
#include "str_util.h"
int main() {
SCHED_SHMEM* ssp;
int retval;
void* p;
retval = config.parse_file(".");
retval = config.parse_file();
if (retval) {
printf("can't parse config: %d\n", retval);
printf("Can't parse config.xml: %s\n", boincerror(retval));
exit(1);
}
retval = attach_shmem(config.shmem_key, &p);

View File

@ -45,10 +45,8 @@ int assimilate_handler(
// delete the template files
//
sprintf(buf, "../templates/sj_wu_template_%d", wu.id);
unlink(buf);
sprintf(buf, "../templates/sj_result_template_%d", wu.id);
unlink(buf);
unlink(config.project_path("templates/sj_wu_template_%d", wu.id));
unlink(config.project_path("templates/sj_result_template_%d", wu.id));
// read and delete the job directory file
//

View File

@ -22,6 +22,7 @@
#include "parse.h"
#include "sched_msgs.h"
#include "sched_config.h"
#include "time_stats_log.h"
@ -40,11 +41,12 @@ void handle_time_stats_log(FILE* fin) {
// Use a directory hierarchy since there may be many hosts
//
void write_time_stats_log() {
char dirname[256], filename[256];
char filename[256];
const char *dirname;
int hostid = g_reply->host.id;
int dirnum = hostid % 1000;
sprintf(dirname, "../time_stats_log/%d", dirnum);
dirname = config.project_path("time_stats_log/%d", dirnum);
if (!is_dir(dirname)) {
int retval = boinc_mkdir(dirname);
if (retval) {
@ -55,7 +57,7 @@ void write_time_stats_log() {
return;
}
}
sprintf(filename, "../time_stats_log/%d/%d", dirnum, hostid);
sprintf(filename, "%s/%d", dirname, hostid);
#ifndef _USING_FCGI_
FILE* f = fopen(filename, "w");
#else
@ -74,10 +76,7 @@ void write_time_stats_log() {
}
bool have_time_stats_log() {
char filename[256];
int hostid = g_reply->host.id;
int dirnum = hostid % 1000;
sprintf(filename, "../time_stats_log/%d/%d", dirnum, hostid);
return is_file(filename);
return is_file(config.project_path("time_stats_log/%d/%d", dirnum, hostid));
}

View File

@ -41,6 +41,7 @@
#include "backend_lib.h"
#include "common_defs.h"
#include "error_numbers.h"
#include "str_util.h"
#include "sched_config.h"
#include "sched_util.h"
@ -372,8 +373,7 @@ int handle_wu(
);
for (j=0; j<n; j++) {
sprintf(suffix, "%d", max_result_suffix+j+1);
char rtfpath[256];
sprintf(rtfpath, "../%s", wu_item.result_template_file);
const char *rtfpath = config.project_path("%s", wu_item.result_template_file);
int priority_increase = 0;
if (nover && config.reliable_priority_on_over) {
priority_increase += config.reliable_priority_on_over;
@ -381,7 +381,7 @@ int handle_wu(
priority_increase += config.reliable_priority_on_over_except_error;
}
retval = create_result_ti(
wu_item, rtfpath, suffix, key, config, value_buf, priority_increase
wu_item, (char *)rtfpath, suffix, key, config, value_buf, priority_increase
);
if (retval) {
log_messages.printf(MSG_CRITICAL,
@ -692,9 +692,9 @@ int main(int argc, char** argv) {
}
if (!one_pass) check_stop_daemons();
retval = config.parse_file("..");
retval = config.parse_file();
if (retval) {
log_messages.printf(MSG_CRITICAL, "can't read config file\n");
log_messages.printf(MSG_CRITICAL, "Can't parse config.xml: %s\n", boincerror(retval));
exit(1);
}

View File

@ -158,10 +158,10 @@ int main(int argc, char** argv) {
}
}
retval = config.parse_file("..");
retval = config.parse_file();
if (retval) {
log_messages.printf(MSG_CRITICAL,
"Can't parse ../config.xml: %s\n", boincerror(retval)
"Can't parse config.xml: %s\n", boincerror(retval)
);
exit(1);
}

View File

@ -202,10 +202,10 @@ int main(int argc, char** argv) {
log_messages.printf(MSG_NORMAL, "Starting\n");
retval = config.parse_file("..");
retval = config.parse_file();
if (retval) {
log_messages.printf(MSG_CRITICAL,
"Can't parse ../config.xml: %s\n", boincerror(retval)
"Can't parse config.xml: %s\n", boincerror(retval)
);
exit(1);
}

View File

@ -747,10 +747,10 @@ int main(int argc, char** argv) {
exit(1);
}
retval = config.parse_file("..");
retval = config.parse_file();
if (retval) {
log_messages.printf(MSG_CRITICAL,
"Can't parse ../config.xml: %s\n", boincerror(retval)
"Can't parse config.xml: %s\n", boincerror(retval)
);
exit(1);
}

View File

@ -504,14 +504,12 @@ int create_result(
// associated with this newly-created result
//
if (config_loc.locality_scheduling) {
char datafilename[512];
const char *datafilename;
char *last=strstr(result.name, "__");
if (result.name<last && last<(result.name+255)) {
sprintf(datafilename, "../locality_scheduling/working_set_removal/");
strncat(datafilename, result.name, last-result.name);
datafilename = config.project_path("locality_scheduling/working_set_removal/%s", result.name);
unlink(datafilename);
sprintf(datafilename, "../locality_scheduling/work_available/");
strncat(datafilename, result.name, last-result.name);
datafilename = config.project_path("locality_scheduling/work_available/%s", result.name);
boinc_touch_file(datafilename);
}
}

View File

@ -92,7 +92,7 @@ int main(int argc, const char** argv) {
strcpy(app.name, "");
strcpy(db_passwd, "");
strcpy(additional_xml, "");
const char* config_dir = ".";
const char* config_dir = 0;
i = 1;
ninfiles = 0;
wu.clear();
@ -213,7 +213,7 @@ int main(int argc, const char** argv) {
exit(1);
}
}
retval = config.parse_file(config_dir);
retval = config.parse_file();
if (retval) {
fprintf(stderr, "Can't parse config file: %d\n", retval);
exit(1);

View File

@ -27,6 +27,7 @@
#include "util.h"
#include "sched_config.h"
#include "sched_util.h"
#include "str_util.h"
const char *usage =
@ -44,9 +45,9 @@ int main(int argc, char** argv) {
exit(1);
}
retval = config.parse_file(".");
retval = config.parse_file();
if (retval) {
fprintf(stderr, "Can't find config.xml; run this in project root dir\n");
fprintf(stderr, "Can't parse config.xml: %s\n", boincerror(retval));
exit(1);
}

View File

@ -48,7 +48,7 @@ int main(int argc, char** argv){
int retval,final;
string wuname;
char buf[256];
string config_dir = ".";
string config_dir = "";
//parse the input
if (argc<2){
usage(0);
@ -66,7 +66,7 @@ int main(int argc, char** argv){
}
wuname = argv[argc-1];
final =0;
retval = config.parse_file((char *) config_dir.c_str());
retval = config.parse_file(config_dir.c_str());
if (retval) {
fprintf(stderr,"can't read config file\n");
return -1;

View File

@ -62,7 +62,7 @@ int main(int argc, char** argv){
char buf[256];
MYSQL_ROW row;
MYSQL_RES* rp;
string config_dir = ".";
string config_dir = "";
//parse the input
if (argc<2){
usage(0);
@ -80,7 +80,7 @@ int main(int argc, char** argv){
}
final=0;
wuname = argv[argc-1];
retval = config.parse_file((char *) config_dir.c_str());
retval = config.parse_file(config_dir.c_str());
if (retval) {
fprintf(stderr,"can't read config file\n");
return -1;