From 12eb6057e5112e0628d1cc542bf156340c3c219f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 7 May 2009 13:54:51 +0000 Subject: [PATCH] - 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 --- checkin_notes | 27 +++++++++++++++++++ client/cpu_sched.cpp | 21 ++++++++++----- client/cs_benchmark.cpp | 13 +++++++++ lib/network.cpp | 3 ++- sched/assimilator.cpp | 4 +-- sched/census.cpp | 4 +-- sched/db_dump.cpp | 4 +-- sched/db_purge.cpp | 11 ++++---- sched/delete_file.cpp | 4 +-- sched/feeder.cpp | 16 +++++------ sched/file_deleter.cpp | 4 +-- sched/file_upload_handler.cpp | 7 ++--- sched/get_file.cpp | 4 +-- sched/main.cpp | 16 +++++------ sched/make_work.cpp | 5 ++-- sched/message_handler.cpp | 4 +-- sched/request_file_list.cpp | 4 +-- sched/sample_assimilator.cpp | 10 +++---- sched/sample_work_generator.cpp | 10 ++++--- sched/sched_assign.cpp | 7 ++--- sched/sched_config.cpp | 46 +++++++++++++++++++++++++------- sched/sched_config.h | 10 +++---- sched/sched_locality.cpp | 21 +++++++-------- sched/sched_timezone.cpp | 13 ++++----- sched/sched_util.cpp | 23 +++++++++------- sched/send_file.cpp | 4 +-- sched/server_types.cpp | 4 +-- sched/show_shmem.cpp | 5 ++-- sched/single_job_assimilator.cpp | 6 ++--- sched/time_stats_log.cpp | 13 +++++---- sched/transitioner.cpp | 10 +++---- sched/trickle_handler.cpp | 4 +-- sched/update_stats.cpp | 4 +-- sched/validator.cpp | 4 +-- tools/backend_lib.cpp | 8 +++--- tools/create_work.cpp | 4 +-- tools/dir_hier_path.cpp | 5 ++-- tools/kill_wu.cpp | 4 +-- tools/poll_wu.cpp | 4 +-- 39 files changed, 224 insertions(+), 146 deletions(-) diff --git a/checkin_notes b/checkin_notes index dc5a085cf9..f8337606d9 100644 --- a/checkin_notes +++ b/checkin_notes @@ -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 diff --git a/client/cpu_sched.cpp b/client/cpu_sched.cpp index 1d89af614b..9bc3e1582f 100644 --- a/client/cpu_sched.cpp +++ b/client/cpu_sched.cpp @@ -735,12 +735,21 @@ static inline bool more_important(RESULT* r0, RESULT* r1) { return (r0 < r1); } -static void print_job_list(vector& jobs) { +static void print_job_list(vector& jobs, bool details) { for (unsigned int i=0; iproject, 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(); diff --git a/client/cs_benchmark.cpp b/client/cs_benchmark.cpp index 50b99377ab..dc0390608e 100644 --- a/client/cs_benchmark.cpp +++ b/client/cs_benchmark.cpp @@ -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; } diff --git a/lib/network.cpp b/lib/network.cpp index 542f9eab30..688350a5c8 100644 --- a/lib/network.cpp +++ b/lib/network.cpp @@ -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 } diff --git a/sched/assimilator.cpp b/sched/assimilator.cpp index 86d9cdf6c7..6cc251dde7 100644 --- a/sched/assimilator.cpp +++ b/sched/assimilator.cpp @@ -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); } diff --git a/sched/census.cpp b/sched/census.cpp index 322fc56def..f8e5b33cf6 100644 --- a/sched/census.cpp +++ b/sched/census.cpp @@ -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); } diff --git a/sched/db_dump.cpp b/sched/db_dump.cpp index 68b2c04050..edeb204fae 100644 --- a/sched/db_dump.cpp +++ b/sched/db_dump.cpp @@ -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); } diff --git a/sched/db_purge.cpp b/sched/db_purge.cpp index 38113c6880..54a766240f 100644 --- a/sched/db_purge.cpp +++ b/sched/db_purge.cpp @@ -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 diff --git a/sched/delete_file.cpp b/sched/delete_file.cpp index d61592a4b0..0a0938b421 100644 --- a/sched/delete_file.cpp +++ b/sched/delete_file.cpp @@ -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); } diff --git a/sched/feeder.cpp b/sched/feeder.cpp index 5d6917f0ba..7ee70f80ef 100644 --- a/sched/feeder.cpp +++ b/sched/feeder.cpp @@ -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); diff --git a/sched/file_deleter.cpp b/sched/file_deleter.cpp index bb1ba7aa4f..54f076a4c3 100644 --- a/sched/file_deleter.cpp +++ b/sched/file_deleter.cpp @@ -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); } diff --git a/sched/file_upload_handler.cpp b/sched/file_upload_handler.cpp index b7c374180b..d2de4e3f2d 100644 --- a/sched/file_upload_handler.cpp +++ b/sched/file_upload_handler.cpp @@ -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); } diff --git a/sched/get_file.cpp b/sched/get_file.cpp index bc04ad83c6..4097a5b95e 100644 --- a/sched/get_file.cpp +++ b/sched/get_file.cpp @@ -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); } diff --git a/sched/main.cpp b/sched/main.cpp index 83235f449f..6c647a6a7a 100644 --- a/sched/main.cpp +++ b/sched/main.cpp @@ -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 diff --git a/sched/make_work.cpp b/sched/make_work.cpp index bcf904822e..10671ac872 100644 --- a/sched/make_work.cpp +++ b/sched/make_work.cpp @@ -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 &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); } diff --git a/sched/message_handler.cpp b/sched/message_handler.cpp index 72bac8cc47..15f45de8f9 100644 --- a/sched/message_handler.cpp +++ b/sched/message_handler.cpp @@ -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); } diff --git a/sched/request_file_list.cpp b/sched/request_file_list.cpp index 5f75b57c19..56ba69221d 100644 --- a/sched/request_file_list.cpp +++ b/sched/request_file_list.cpp @@ -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); } diff --git a/sched/sample_assimilator.cpp b/sched/sample_assimilator.cpp index a46216d9a0..ebe551e4a3 100644 --- a/sched/sample_assimilator.cpp +++ b/sched/sample_assimilator.cpp @@ -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 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; iresults.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"); } } diff --git a/sched/sched_timezone.cpp b/sched/sched_timezone.cpp index 103e7640b3..e060ee8736 100644 --- a/sched/sched_timezone.cpp +++ b/sched/sched_timezone.cpp @@ -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; diff --git a/sched/sched_util.cpp b/sched/sched_util.cpp index 5165eb8357..1e7e3e983d 100644 --- a/sched/sched_util.cpp +++ b/sched/sched_util.cpp @@ -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); diff --git a/sched/send_file.cpp b/sched/send_file.cpp index a078e10e98..3c36d7f6f8 100644 --- a/sched/send_file.cpp +++ b/sched/send_file.cpp @@ -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); } diff --git a/sched/server_types.cpp b/sched/server_types.cpp index a4d94db649..f0311b6680 100644 --- a/sched/server_types.cpp +++ b/sched/server_types.cpp @@ -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$"; diff --git a/sched/show_shmem.cpp b/sched/show_shmem.cpp index 27eaf47085..39d5dc2b13 100644 --- a/sched/show_shmem.cpp +++ b/sched/show_shmem.cpp @@ -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); diff --git a/sched/single_job_assimilator.cpp b/sched/single_job_assimilator.cpp index bee4939ce5..e72465919f 100644 --- a/sched/single_job_assimilator.cpp +++ b/sched/single_job_assimilator.cpp @@ -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 // diff --git a/sched/time_stats_log.cpp b/sched/time_stats_log.cpp index 9fd13b769b..e54257d50f 100644 --- a/sched/time_stats_log.cpp +++ b/sched/time_stats_log.cpp @@ -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)); } diff --git a/sched/transitioner.cpp b/sched/transitioner.cpp index 9f80e36e8e..4810f608a7 100644 --- a/sched/transitioner.cpp +++ b/sched/transitioner.cpp @@ -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