From f1eceb86055bc735b4a3069d7578027efb0af19f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 2 Sep 2003 21:16:55 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=2220 --- Makefile.incl | 1 + api/Makefile.in | 1 + apps/Makefile.in | 1 + checkin_notes | 16 +++++++ client/Makefile.in | 1 + lib/Makefile.in | 1 + py/Makefile.in | 1 + sched/Makefile.am | 2 +- sched/Makefile.in | 16 ++++--- sched/assimilator.C | 4 +- sched/db_dump.C | 4 +- sched/feeder.C | 7 ++- sched/file_deleter.C | 4 +- sched/file_upload_handler.C | 4 +- sched/main.C | 4 +- sched/main.h | 2 +- sched/make_work.C | 74 ++++++++++++++-------------- sched/{config.C => sched_config.C} | 17 ++++--- sched/sched_config.h | 9 ++-- sched/sched_messages.C | 6 +-- sched/show_shmem.C | 4 +- sched/start_servers.C | 2 +- sched/transitioner.C | 4 +- sched/update_stats.C | 4 +- sched/validate.C | 4 +- sched/validate_trivial.C | 31 ++++++------ sched/validate_util.C | 2 +- test/Makefile.in | 1 + tools/Makefile.am | 50 +++++++++---------- tools/Makefile.in | 77 ++++++++++++++++++++---------- tools/add.C | 15 +++++- tools/{add => add.py} | 0 tools/create_work.C | 48 +++++++++++++------ 33 files changed, 252 insertions(+), 165 deletions(-) rename sched/{config.C => sched_config.C} (85%) rename tools/{add => add.py} (100%) diff --git a/Makefile.incl b/Makefile.incl index 78e0394f31..77a2d5a39c 100644 --- a/Makefile.incl +++ b/Makefile.incl @@ -20,6 +20,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/RSAEuro/source \ -I$(top_srcdir)/client \ -I$(top_srcdir)/tools \ + -I$(top_srcdir)/sched \ $(MYSQL_CFLAGS) \ -include $(top_builddir)/config.h diff --git a/api/Makefile.in b/api/Makefile.in index f080cf4b12..a1c2935cbb 100644 --- a/api/Makefile.in +++ b/api/Makefile.in @@ -158,6 +158,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/RSAEuro/source \ -I$(top_srcdir)/client \ -I$(top_srcdir)/tools \ + -I$(top_srcdir)/sched \ $(MYSQL_CFLAGS) \ -include $(top_builddir)/config.h diff --git a/apps/Makefile.in b/apps/Makefile.in index 1a7e966070..405898c6c1 100644 --- a/apps/Makefile.in +++ b/apps/Makefile.in @@ -158,6 +158,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/RSAEuro/source \ -I$(top_srcdir)/client \ -I$(top_srcdir)/tools \ + -I$(top_srcdir)/sched \ $(MYSQL_CFLAGS) \ -include $(top_builddir)/config.h diff --git a/checkin_notes b/checkin_notes index 06e4952590..a03ba9bbd4 100755 --- a/checkin_notes +++ b/checkin_notes @@ -5981,3 +5981,19 @@ David Sept 1 2003 client_state.C doc/ client.php + +David Sept 2 2003 + - changed tools (create_work, add) to use config.xml if it's present + (reduces number of command-line args) + - renamed config.h to sched_config.h + - renamed tools/add to add.py (to avoid confusion with binary) + + sched/ + Makefile.am + sched_config.h (renamed from config.h) + *.C + tools/ + Makefile.am + add.py (renamed from add) + add.C + create_work.C diff --git a/client/Makefile.in b/client/Makefile.in index 854073f995..6714c367cf 100644 --- a/client/Makefile.in +++ b/client/Makefile.in @@ -160,6 +160,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/RSAEuro/source \ -I$(top_srcdir)/client \ -I$(top_srcdir)/tools \ + -I$(top_srcdir)/sched \ $(MYSQL_CFLAGS) \ -include $(top_builddir)/config.h diff --git a/lib/Makefile.in b/lib/Makefile.in index a4d8165953..34e15e56c5 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -158,6 +158,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/RSAEuro/source \ -I$(top_srcdir)/client \ -I$(top_srcdir)/tools \ + -I$(top_srcdir)/sched \ $(MYSQL_CFLAGS) \ -include $(top_builddir)/config.h diff --git a/py/Makefile.in b/py/Makefile.in index d4f5303bf5..db5a089c07 100644 --- a/py/Makefile.in +++ b/py/Makefile.in @@ -158,6 +158,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/RSAEuro/source \ -I$(top_srcdir)/client \ -I$(top_srcdir)/tools \ + -I$(top_srcdir)/sched \ $(MYSQL_CFLAGS) \ -include $(top_builddir)/config.h diff --git a/sched/Makefile.am b/sched/Makefile.am index 0a84d4e2ac..714d8e0458 100644 --- a/sched/Makefile.am +++ b/sched/Makefile.am @@ -22,7 +22,7 @@ LIB_SCHED = libsched.a libsched_a_SOURCES = \ sched_shmem.C \ sched_util.C \ - config.C \ + sched_config.C \ sched_messages.C \ ../db/boinc_db.C \ ../db/db_base.C \ diff --git a/sched/Makefile.in b/sched/Makefile.in index 54eefb040c..84d12c8584 100644 --- a/sched/Makefile.in +++ b/sched/Makefile.in @@ -158,6 +158,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/RSAEuro/source \ -I$(top_srcdir)/client \ -I$(top_srcdir)/tools \ + -I$(top_srcdir)/sched \ $(MYSQL_CFLAGS) \ -include $(top_builddir)/config.h @@ -187,7 +188,7 @@ LIB_SCHED = libsched.a libsched_a_SOURCES = \ sched_shmem.C \ sched_util.C \ - config.C \ + sched_config.C \ sched_messages.C \ ../db/boinc_db.C \ ../db/db_base.C \ @@ -272,9 +273,9 @@ LIBRARIES = $(noinst_LIBRARIES) libsched_a_AR = $(AR) cru libsched_a_LIBADD = am_libsched_a_OBJECTS = sched_shmem.$(OBJEXT) sched_util.$(OBJEXT) \ - config.$(OBJEXT) sched_messages.$(OBJEXT) boinc_db.$(OBJEXT) \ - db_base.$(OBJEXT) util.$(OBJEXT) crypt.$(OBJEXT) \ - parse.$(OBJEXT) shmem.$(OBJEXT) md5.$(OBJEXT) \ + sched_config.$(OBJEXT) sched_messages.$(OBJEXT) \ + boinc_db.$(OBJEXT) db_base.$(OBJEXT) util.$(OBJEXT) \ + crypt.$(OBJEXT) parse.$(OBJEXT) shmem.$(OBJEXT) md5.$(OBJEXT) \ md5_file.$(OBJEXT) messages.$(OBJEXT) \ process_result_template.$(OBJEXT) backend_lib.$(OBJEXT) libsched_a_OBJECTS = $(am_libsched_a_OBJECTS) @@ -349,8 +350,8 @@ am__depfiles_maybe = depfiles @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/assimilate_handler.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/assimilator.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/backend_lib.Po ./$(DEPDIR)/boinc_db.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/config.Po ./$(DEPDIR)/crypt.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/db_base.Po ./$(DEPDIR)/db_dump.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/crypt.Po ./$(DEPDIR)/db_base.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/db_dump.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/fcgi-handle_request.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/fcgi-main.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/fcgi-server_types.Po \ @@ -361,6 +362,7 @@ am__depfiles_maybe = depfiles @AMDEP_TRUE@ ./$(DEPDIR)/md5_file.Po ./$(DEPDIR)/messages.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/parse.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/process_result_template.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/sched_config.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/sched_messages.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/sched_shmem.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/sched_util.Po \ @@ -496,7 +498,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assimilator.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/backend_lib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_db.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/config.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/db_base.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/db_dump.Po@am__quote@ @@ -514,6 +515,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/messages.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/process_result_template.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sched_config.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sched_messages.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sched_shmem.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sched_util.Po@am__quote@ diff --git a/sched/assimilator.C b/sched/assimilator.C index d4b65a24d2..6512fb64fc 100644 --- a/sched/assimilator.C +++ b/sched/assimilator.C @@ -33,7 +33,7 @@ #define LOCKFILE "assimilator.out" #define PIDFILE "assimilator.pid" -CONFIG config; +SCHED_CONFIG config; // assimilate all WUs that need it // return nonzero if did anything @@ -94,7 +94,7 @@ int main(int argc, char** argv) { } } - retval = config.parse_file(); + retval = config.parse_file(".."); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "Can't parse config file\n"); exit(1); diff --git a/sched/db_dump.C b/sched/db_dump.C index b14a694555..455616cfdc 100644 --- a/sched/db_dump.C +++ b/sched/db_dump.C @@ -455,7 +455,7 @@ int tables_file() { } int main(int argc, char** argv) { - CONFIG config; + SCHED_CONFIG config; int retval, i; char dir[256]; @@ -493,7 +493,7 @@ int main(int argc, char** argv) { } log_messages.printf(SchedMessages::NORMAL, "Starting\n"); - retval = config.parse_file(); + retval = config.parse_file(".."); if (retval) { log_messages.printf(SchedMessages::NORMAL, "Can't parse config file\n"); exit(1); diff --git a/sched/feeder.C b/sched/feeder.C index c726de468e..c07e315254 100644 --- a/sched/feeder.C +++ b/sched/feeder.C @@ -64,12 +64,11 @@ #define LOCKFILE "feeder.out" #define PIDFILE "feeder.pid" -CONFIG config; +SCHED_CONFIG config; SCHED_SHMEM* ssp; -void cleanup_shmem() -{ +void cleanup_shmem() { detach_shmem((void*)ssp); destroy_shmem(config.shmem_key); } @@ -222,7 +221,7 @@ int main(int argc, char** argv) { unlink(REREAD_DB_FILENAME); - retval = config.parse_file(); + retval = config.parse_file(".."); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "can't parse config file\n"); exit(1); diff --git a/sched/file_deleter.C b/sched/file_deleter.C index efb6f0b21d..542c49d7d7 100644 --- a/sched/file_deleter.C +++ b/sched/file_deleter.C @@ -34,7 +34,7 @@ #define LOCKFILE "file_deleter.out" #define PIDFILE "file_deleter.pid" -CONFIG config; +SCHED_CONFIG config; int wu_delete_files(WORKUNIT& wu) { char* p; @@ -143,7 +143,7 @@ int main(int argc, char** argv) { } } - retval = config.parse_file(); + retval = config.parse_file(".."); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "Can't parse config file\n"); exit(1); diff --git a/sched/file_upload_handler.C b/sched/file_upload_handler.C index f3636a9d77..23525145d0 100644 --- a/sched/file_upload_handler.C +++ b/sched/file_upload_handler.C @@ -35,7 +35,7 @@ #include "sched_util.h" #include "crypt.h" -CONFIG config; +SCHED_CONFIG config; #define ERR_TRANSIENT true #define ERR_PERMANENT false @@ -340,7 +340,7 @@ int main() { log_messages.set_debug_level(DEBUG_LEVEL); - retval = config.parse_file(); + retval = config.parse_file(".."); if (retval) { return_error(ERR_TRANSIENT, "can't read config file"); exit(1); diff --git a/sched/main.C b/sched/main.C index b01dfc8e5d..272c5f80de 100644 --- a/sched/main.C +++ b/sched/main.C @@ -51,7 +51,7 @@ static const char* STDERR_FILENAME = "../log/cgi.log"; bool use_files = false; // use disk files for req/reply msgs (for debugging) DB_PROJECT gproject; -CONFIG config; +SCHED_CONFIG config; int main() { FILE* fin, *fout; @@ -70,7 +70,7 @@ int main() { log_messages.set_debug_level(DEBUG_LEVEL); - retval = config.parse_file(); + retval = config.parse_file(".."); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "Can't parse config file\n"); exit(1); diff --git a/sched/main.h b/sched/main.h index d002bf5780..91fcb1fb82 100644 --- a/sched/main.h +++ b/sched/main.h @@ -21,4 +21,4 @@ #include "sched_config.h" extern DB_PROJECT gproject; -extern CONFIG config; +extern SCHED_CONFIG config; diff --git a/sched/make_work.C b/sched/make_work.C index ba0276d832..4c47958cbc 100644 --- a/sched/make_work.C +++ b/sched/make_work.C @@ -20,8 +20,13 @@ // make_work // -wu_name name // -result_template filename -// [ -cushion n ] -// [ -max_wus n ] +// [ -cushion n ] // make work if fewer than this many unsent results +// [ -max_wus n ] // don't make work if more than this many WUs +// [ -min_quorum n ] +// [ -target_nresults n ] +// [ -max_error_results n ] +// [ -max_total_results n ] +// [ -max_success_results n ] // // Create WU and result records as needed to maintain a pool of work (for // testing purposes). @@ -46,12 +51,12 @@ #define PIDFILE "make_work.pid" int max_wus = 0; -int cushion = 30; -// int min_quorum = 0; -// int target_nresults = 0; -// int max_error_results = 0; -// int max_total_results = 0; -// int max_success_results = 0; +int cushion = 300; +int min_quorum = 2; +int target_nresults = 5; +int max_error_results = 10; +int max_total_results = 20; +int max_success_results = 10; char wu_name[256], result_template_file[256]; @@ -97,8 +102,7 @@ inline const char* get_query_unsent_results() return query_unsent_results; } -inline int count_results(const char* query="") -{ +inline int count_results(const char* query="") { int n; DB_RESULT result; int retval = result.count(n, const_cast(query)); @@ -109,8 +113,7 @@ inline int count_results(const char* query="") return n; } -inline int count_workunits(const char* query="") -{ +inline int count_workunits(const char* query="") { int n; DB_WORKUNIT workunit; int retval = workunit.count(n, const_cast(query)); @@ -122,7 +125,7 @@ inline int count_workunits(const char* query="") } void make_work() { - CONFIG config; + SCHED_CONFIG config; char * p; int retval, start_time=time(0); char keypath[256], result_template[MAX_BLOB_SIZE]; @@ -133,7 +136,7 @@ void make_work() { DB_WORKUNIT wu; int seqno = 0; - retval = config.parse_file(); + retval = config.parse_file(".."); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "can't read config file\n"); exit(1); @@ -213,11 +216,11 @@ void make_work() { sprintf(wu.name, "wu_%d_%d", start_time, seqno++); wu.id = 0; wu.create_time = time(0); - // wu.min_quorum = min_quorum; - // wu.target_nresults = target_nresults; - // wu.max_error_results = max_error_results; - // wu.max_total_results = max_total_results; - // wu.max_success_results = max_success_results; + wu.min_quorum = min_quorum; + wu.target_nresults = target_nresults; + wu.max_error_results = max_error_results; + wu.max_total_results = max_total_results; + wu.max_success_results = max_success_results; strcpy(wu.result_template, result_template); process_result_template_upload_url_only(wu.result_template, config.upload_url); wu.transition_time = time(0); @@ -245,16 +248,16 @@ int main(int argc, char** argv) { strcpy(wu_name, argv[++i]); } else if (!strcmp(argv[i], "-max_wus")) { max_wus = atoi(argv[++i]); - // } else if (!strcmp(argv[i], "-min_quorum")) { - // min_quorum = atoi(argv[++i]); - // } else if (!strcmp(argv[i], "-target_nresults")) { - // target_nresults = atoi(argv[++i]); - // } else if (!strcmp(argv[i], "-max_error_results")) { - // max_error_results = atoi(argv[++i]); - // } else if (!strcmp(argv[i], "-max_total_results")) { - // max_total_results = atoi(argv[++i]); - // } else if (!strcmp(argv[i], "-max_success_results")) { - // max_success_results = atoi(argv[++i]); + } else if (!strcmp(argv[i], "-min_quorum")) { + min_quorum = atoi(argv[++i]); + } else if (!strcmp(argv[i], "-target_nresults")) { + target_nresults = atoi(argv[++i]); + } else if (!strcmp(argv[i], "-max_error_results")) { + max_error_results = atoi(argv[++i]); + } else if (!strcmp(argv[i], "-max_total_results")) { + max_total_results = atoi(argv[++i]); + } else if (!strcmp(argv[i], "-max_success_results")) { + max_success_results = atoi(argv[++i]); } } @@ -262,11 +265,6 @@ int main(int argc, char** argv) { #define CHKARG_STR(v,m) CHKARG(strlen(v),m) CHKARG_STR(result_template_file , "need -result_template_file"); CHKARG_STR(wu_name , "need -wu_name"); - // CHKARG(min_quorum, "need -min_quorum"); - // CHKARG(target_nresults, "need -target_nresults"); - // CHKARG(max_error_results, "need -max_error_results"); - // CHKARG(max_total_results, "need -max_total_results"); - // CHKARG(max_success_results, "need -max_success_results"); #undef CHKARG #undef CHKARG_STR @@ -282,9 +280,11 @@ int main(int argc, char** argv) { // exit(1); // } // write_pid_file(PIDFILE); - // log_messages.printf(SchedMessages::NORMAL, "Starting: min_quorum=%d target_nresults=%d max_error_results=%d max_total_results=%d max_success_results=%d\n", - // min_quorum, target_nresults, max_error_results, max_total_results, max_success_results); - log_messages.printf(SchedMessages::NORMAL, "Starting"); + log_messages.printf( + SchedMessages::NORMAL, + "Starting: min_quorum=%d target_nresults=%d max_error_results=%d max_total_results=%d max_success_results=%d\n", + min_quorum, target_nresults, max_error_results, max_total_results, max_success_results + ); install_sigint_handler(); srand48(getpid() + time(0)); diff --git a/sched/config.C b/sched/sched_config.C similarity index 85% rename from sched/config.C rename to sched/sched_config.C index 8ef52ff631..6a37923c45 100644 --- a/sched/config.C +++ b/sched/sched_config.C @@ -27,12 +27,12 @@ #include "sched_config.h" -const char* CONFIG_FILE = "../config.xml"; +const char* CONFIG_FILE = "config.xml"; -int CONFIG::parse(FILE* in) { +int SCHED_CONFIG::parse(FILE* in) { char buf[256]; - memset(this, 0, sizeof(CONFIG)); + memset(this, 0, sizeof(SCHED_CONFIG)); while (fgets(buf, 256, in)) { if (match_tag(buf, "")) return 0; else if (parse_str(buf, "", db_name, sizeof(db_name))) continue; @@ -48,10 +48,15 @@ int CONFIG::parse(FILE* in) { return ERR_XML_PARSE; } -int CONFIG::parse_file() { +int SCHED_CONFIG::parse_file(char* dir) { FILE* f; + char path[256]; + int retval; - f = fopen(CONFIG_FILE, "r"); + sprintf(path, "%s/%s", dir, CONFIG_FILE); + f = fopen(path, "r"); if (!f) return ERR_FOPEN; - return parse(f); + retval = parse(f); + fclose(f); + return retval; } diff --git a/sched/sched_config.h b/sched/sched_config.h index 851aaf0d09..0d868c1935 100644 --- a/sched/sched_config.h +++ b/sched/sched_config.h @@ -17,12 +17,12 @@ // Contributor(s): // -#ifndef _CONFIG_ -#define _CONFIG_ +#ifndef _SCHED_CONFIG_ +#define _SCHED_CONFIG_ // parsed version of server configuration file // -class CONFIG { +class SCHED_CONFIG { public: char db_name[256]; char db_passwd[256]; @@ -33,10 +33,9 @@ public: char upload_url[256]; char upload_dir[256]; char user_name[256]; - // char* start_commands[20]; int parse(FILE*); - int parse_file(); + int parse_file(char* dir="."); }; #endif diff --git a/sched/sched_messages.C b/sched/sched_messages.C index 16ff8b674b..2bc1009e40 100644 --- a/sched/sched_messages.C +++ b/sched/sched_messages.C @@ -22,8 +22,7 @@ SchedMessages log_messages; -const char* SchedMessages::v_format_kind(int kind) const -{ +const char* SchedMessages::v_format_kind(int kind) const { switch(kind) { case CRITICAL: return "CRITICAL"; case NORMAL: return "normal "; @@ -32,7 +31,6 @@ const char* SchedMessages::v_format_kind(int kind) const } } -bool SchedMessages::v_message_wanted(int kind) const -{ +bool SchedMessages::v_message_wanted(int kind) const { return ( kind <= debug_level ); } diff --git a/sched/show_shmem.C b/sched/show_shmem.C index c2b9f412bd..ef35fcaaf2 100644 --- a/sched/show_shmem.C +++ b/sched/show_shmem.C @@ -31,9 +31,9 @@ int main() { SCHED_SHMEM* ssp; int retval, i; void* p; - CONFIG config; + SCHED_CONFIG config; - retval = config.parse_file(); + retval = config.parse_file(".."); if (retval) { printf("can't parse config\n"); exit(1); diff --git a/sched/start_servers.C b/sched/start_servers.C index 3ff7511b36..6e548ff4b4 100644 --- a/sched/start_servers.C +++ b/sched/start_servers.C @@ -26,7 +26,7 @@ #include "sched_util.h" int main() { - CONFIG config; + SCHED_CONFIG config; int i, retval; char* p; diff --git a/sched/transitioner.C b/sched/transitioner.C index 491973dae2..bdecab4e75 100644 --- a/sched/transitioner.C +++ b/sched/transitioner.C @@ -44,7 +44,7 @@ using namespace std; #define PIDFILE "transitioner.pid" int startup_time; -CONFIG config; +SCHED_CONFIG config; R_RSA_PRIVATE_KEY key; void handle_wu(DB_WORKUNIT& wu) { @@ -333,7 +333,7 @@ int main(int argc, char** argv) { } } - retval = config.parse_file(); + retval = config.parse_file(".."); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "can't read config file\n"); exit(1); diff --git a/sched/update_stats.C b/sched/update_stats.C index 2496fdc18d..b46afd9447 100644 --- a/sched/update_stats.C +++ b/sched/update_stats.C @@ -117,7 +117,7 @@ int update_teams() { } int main(int argc, char** argv) { - CONFIG config; + SCHED_CONFIG config; int retval, i; bool do_update_teams = false, do_update_users = false; bool do_update_hosts = false, asynch = false; @@ -155,7 +155,7 @@ int main(int argc, char** argv) { log_messages.printf(SchedMessages::NORMAL, "Starting\n"); - retval = config.parse_file(); + retval = config.parse_file(".."); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "Can't parse config file\n"); exit(1); diff --git a/sched/validate.C b/sched/validate.C index ac3db82ff8..249e55bcb7 100644 --- a/sched/validate.C +++ b/sched/validate.C @@ -56,7 +56,7 @@ using namespace std; extern int check_set(vector&, int& canonical, double& credit); extern int check_pair(RESULT const&, RESULT const&, bool&); -CONFIG config; +SCHED_CONFIG config; char app_name[256]; // here when a result has been validated; @@ -371,7 +371,7 @@ int main(int argc, char** argv) { } } - retval = config.parse_file(); + retval = config.parse_file(".."); if (retval) { log_messages.printf(SchedMessages::CRITICAL, "Can't parse config file\n"); exit(1); diff --git a/sched/validate_trivial.C b/sched/validate_trivial.C index 1dd8074387..b8903dc245 100644 --- a/sched/validate_trivial.C +++ b/sched/validate_trivial.C @@ -22,36 +22,35 @@ // TODO: use md5 hash // read file into memory -int init_result_trivial(RESULT const& result, void*& data) -{ +int init_result_trivial(RESULT const& result, void*& data) { return 0; } -int check_pair_initialized_trivial(RESULT const& /*r1*/, void* /*data1*/, - RESULT const& /*r2*/, void* /*data2*/, - bool& match) -{ +int check_pair_initialized_trivial( + RESULT const& /*r1*/, void* /*data1*/, + RESULT const& /*r2*/, void* /*data2*/, + bool& match +) { match = true; return 0; } -int cleanup_result_trivial(RESULT const& /*result*/, void* /*data*/) -{ +int cleanup_result_trivial(RESULT const& /*result*/, void* /*data*/) { return 0; } // Always grant credit to everybody // -int check_set(vector& results, int& canonicalid, double& credit) -{ - return generic_check_set_majority(results, canonicalid, credit, - init_result_trivial, - check_pair_initialized_trivial, - cleanup_result_trivial); +int check_set(vector& results, int& canonicalid, double& credit) { + return generic_check_set_majority( + results, canonicalid, credit, + init_result_trivial, + check_pair_initialized_trivial, + cleanup_result_trivial + ); } -int check_pair(RESULT const& r1, RESULT const& r2, bool& match) -{ +int check_pair(RESULT const& r1, RESULT const& r2, bool& match) { // return generic_check_pair(r1, r2, match, // init_result_trivial, // check_pair_initialized_trivial, diff --git a/sched/validate_util.C b/sched/validate_util.C index c9e420e3d8..76c0ad51ad 100644 --- a/sched/validate_util.C +++ b/sched/validate_util.C @@ -23,7 +23,7 @@ #include "parse.h" #include -extern CONFIG config; +extern SCHED_CONFIG config; // get the name of a result's (first) output file // diff --git a/test/Makefile.in b/test/Makefile.in index 7508d835db..bc6592ceff 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -158,6 +158,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/RSAEuro/source \ -I$(top_srcdir)/client \ -I$(top_srcdir)/tools \ + -I$(top_srcdir)/sched \ $(MYSQL_CFLAGS) \ -include $(top_builddir)/config.h diff --git a/tools/Makefile.am b/tools/Makefile.am index cb6a507ba2..d6e873de70 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -8,34 +8,36 @@ EXTRA_DIST = make_project # TODO: use libboinc for these: -create_work_SOURCES = \ - create_work.C \ - backend_lib.C \ - process_result_template.C \ - ../lib/md5_file.C \ - ../lib/md5.c \ - ../lib/parse.C \ - ../lib/util.C \ - ../db/boinc_db.C \ - ../db/db_base.C \ - ../lib/crypt.C \ - backend_lib.h +create_work_SOURCES = \ + create_work.C \ + backend_lib.C \ + process_result_template.C \ + ../lib/md5_file.C \ + ../lib/md5.c \ + ../lib/parse.C \ + ../lib/util.C \ + ../db/boinc_db.C \ + ../db/db_base.C \ + ../lib/crypt.C \ + ../sched/sched_config.C \ + backend_lib.h create_work_DEPENDENCIES = $(LIBRSA) create_work_LDADD = $(RSA_LIBS) $(MYSQL_LIBS) -add_SOURCES = \ - add.C \ - backend_lib.C \ - process_result_template.C \ - ../lib/md5_file.C \ - ../lib/md5.c \ - ../lib/parse.C \ - ../lib/util.C \ - ../db/boinc_db.C \ - ../db/db_base.C \ - ../lib/crypt.C \ - backend_lib.h +add_SOURCES = \ + add.C \ + backend_lib.C \ + process_result_template.C \ + ../lib/md5_file.C \ + ../lib/md5.c \ + ../lib/parse.C \ + ../lib/util.C \ + ../db/boinc_db.C \ + ../db/db_base.C \ + ../lib/crypt.C \ + ../sched/sched_config.C \ + backend_lib.h add_DEPENDENCIES = $(LIBRSA) add_LDADD = $(RSA_LIBS) $(MYSQL_LIBS) diff --git a/tools/Makefile.in b/tools/Makefile.in index 6172bc2289..a01d62e148 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -158,6 +158,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/RSAEuro/source \ -I$(top_srcdir)/client \ -I$(top_srcdir)/tools \ + -I$(top_srcdir)/sched \ $(MYSQL_CFLAGS) \ -include $(top_builddir)/config.h @@ -173,34 +174,36 @@ EXTRA_DIST = make_project # TODO: use libboinc for these: create_work_SOURCES = \ - create_work.C \ - backend_lib.C \ - process_result_template.C \ - ../lib/md5_file.C \ - ../lib/md5.c \ - ../lib/parse.C \ - ../lib/util.C \ - ../db/boinc_db.C \ - ../db/db_base.C \ - ../lib/crypt.C \ - backend_lib.h + create_work.C \ + backend_lib.C \ + process_result_template.C \ + ../lib/md5_file.C \ + ../lib/md5.c \ + ../lib/parse.C \ + ../lib/util.C \ + ../db/boinc_db.C \ + ../db/db_base.C \ + ../lib/crypt.C \ + ../sched/sched_config.C \ + backend_lib.h create_work_DEPENDENCIES = $(LIBRSA) create_work_LDADD = $(RSA_LIBS) $(MYSQL_LIBS) add_SOURCES = \ - add.C \ - backend_lib.C \ - process_result_template.C \ - ../lib/md5_file.C \ - ../lib/md5.c \ - ../lib/parse.C \ - ../lib/util.C \ - ../db/boinc_db.C \ - ../db/db_base.C \ - ../lib/crypt.C \ - backend_lib.h + add.C \ + backend_lib.C \ + process_result_template.C \ + ../lib/md5_file.C \ + ../lib/md5.c \ + ../lib/parse.C \ + ../lib/util.C \ + ../db/boinc_db.C \ + ../db/db_base.C \ + ../lib/crypt.C \ + ../sched/sched_config.C \ + backend_lib.h add_DEPENDENCIES = $(LIBRSA) @@ -217,7 +220,7 @@ PROGRAMS = $(bin_PROGRAMS) am_add_OBJECTS = add.$(OBJEXT) backend_lib.$(OBJEXT) \ process_result_template.$(OBJEXT) md5_file.$(OBJEXT) \ md5.$(OBJEXT) parse.$(OBJEXT) util.$(OBJEXT) boinc_db.$(OBJEXT) \ - db_base.$(OBJEXT) crypt.$(OBJEXT) + db_base.$(OBJEXT) crypt.$(OBJEXT) sched_config.$(OBJEXT) add_OBJECTS = $(am_add_OBJECTS) add_LDFLAGS = am_country_select_OBJECTS = country_select.$(OBJEXT) countries.$(OBJEXT) @@ -228,7 +231,7 @@ country_select_LDFLAGS = am_create_work_OBJECTS = create_work.$(OBJEXT) backend_lib.$(OBJEXT) \ process_result_template.$(OBJEXT) md5_file.$(OBJEXT) \ md5.$(OBJEXT) parse.$(OBJEXT) util.$(OBJEXT) boinc_db.$(OBJEXT) \ - db_base.$(OBJEXT) crypt.$(OBJEXT) + db_base.$(OBJEXT) crypt.$(OBJEXT) sched_config.$(OBJEXT) create_work_OBJECTS = $(am_create_work_OBJECTS) create_work_LDFLAGS = @@ -242,7 +245,7 @@ am__depfiles_maybe = depfiles @AMDEP_TRUE@ ./$(DEPDIR)/db_base.Po ./$(DEPDIR)/md5.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/md5_file.Po ./$(DEPDIR)/parse.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/process_result_template.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/util.Po +@AMDEP_TRUE@ ./$(DEPDIR)/sched_config.Po ./$(DEPDIR)/util.Po CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) @@ -297,6 +300,7 @@ util.$(OBJEXT): ../lib/util.C boinc_db.$(OBJEXT): ../db/boinc_db.C db_base.$(OBJEXT): ../db/db_base.C crypt.$(OBJEXT): ../lib/crypt.C +sched_config.$(OBJEXT): ../sched/sched_config.C add$(EXEEXT): $(add_OBJECTS) $(add_DEPENDENCIES) @rm -f add$(EXEEXT) $(CXXLINK) $(add_LDFLAGS) $(add_OBJECTS) $(add_LDADD) $(LIBS) @@ -326,6 +330,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5_file.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/process_result_template.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sched_config.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@ distclean-depend: @@ -485,6 +490,28 @@ crypt.obj: ../lib/crypt.C @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o crypt.obj `if test -f '../lib/crypt.C'; then $(CYGPATH_W) '../lib/crypt.C'; else $(CYGPATH_W) '$(srcdir)/../lib/crypt.C'` +sched_config.o: ../sched/sched_config.C +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sched_config.o -MD -MP -MF "$(DEPDIR)/sched_config.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o sched_config.o `test -f '../sched/sched_config.C' || echo '$(srcdir)/'`../sched/sched_config.C; \ +@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/sched_config.Tpo" "$(DEPDIR)/sched_config.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/sched_config.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../sched/sched_config.C' object='sched_config.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/sched_config.Po' tmpdepfile='$(DEPDIR)/sched_config.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sched_config.o `test -f '../sched/sched_config.C' || echo '$(srcdir)/'`../sched/sched_config.C + +sched_config.obj: ../sched/sched_config.C +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sched_config.obj -MD -MP -MF "$(DEPDIR)/sched_config.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o sched_config.obj `if test -f '../sched/sched_config.C'; then $(CYGPATH_W) '../sched/sched_config.C'; else $(CYGPATH_W) '$(srcdir)/../sched/sched_config.C'`; \ +@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/sched_config.Tpo" "$(DEPDIR)/sched_config.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/sched_config.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../sched/sched_config.C' object='sched_config.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/sched_config.Po' tmpdepfile='$(DEPDIR)/sched_config.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sched_config.obj `if test -f '../sched/sched_config.C'; then $(CYGPATH_W) '../sched/sched_config.C'; else $(CYGPATH_W) '$(srcdir)/../sched/sched_config.C'` + countries.o: ../lib/countries.C @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT countries.o -MD -MP -MF "$(DEPDIR)/countries.Tpo" \ @am__fastdepCXX_TRUE@ -c -o countries.o `test -f '../lib/countries.C' || echo '$(srcdir)/'`../lib/countries.C; \ diff --git a/tools/add.C b/tools/add.C index 490b7fab28..7dcb95b4ac 100644 --- a/tools/add.C +++ b/tools/add.C @@ -49,6 +49,7 @@ #include #include "boinc_db.h" +#include "sched_config.h" #include "backend_lib.h" #include "md5_file.h" #include "crypt.h" @@ -338,6 +339,18 @@ void add_user() { int main(int argc, char** argv) { int i, retval; + SCHED_CONFIG config; + + retval = config.parse_file(); + if (retval) { + printf("no config file found\n"); + } else { + strcpy(db_name, config.db_name); + strcpy(db_passwd, config.db_passwd); + strcpy(download_url, config.download_url); + strcpy(download_dir, config.download_dir); + sprintf(code_sign_keyfile, "%s/code_sign_private", config.key_dir); + } for (i=2; i