From 65dbd70e64cb6e745aa226697ca374ba7524ac77 Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Wed, 11 Jun 2003 23:36:40 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=1397 --- sched/assimilator.C | 12 ++++---- sched/db_dump.C | 2 ++ sched/feeder.C | 32 +++++++++++---------- sched/file_deleter.C | 12 ++++---- sched/handle_request.C | 64 ++++++++++++++++++++---------------------- sched/main.C | 29 +++++++++++-------- sched/main.h | 1 - sched/make_work.C | 26 +++++++++-------- sched/sched_util.C | 11 ++++++-- sched/sched_util.h | 7 ++++- sched/server_types.C | 13 +++++---- sched/update_stats.C | 4 ++- sched/validate.C | 38 +++++++++++++------------ 13 files changed, 140 insertions(+), 111 deletions(-) diff --git a/sched/assimilator.C b/sched/assimilator.C index fdd089447c..4ab002c033 100644 --- a/sched/assimilator.C +++ b/sched/assimilator.C @@ -55,7 +55,7 @@ bool do_pass(APP& app) { "Assimilating WU %s, assim state %d\n", wu.name, wu.assimilate_state ); - write_log(buf); + write_log(buf, MSG_DEBUG); sprintf(buf, "where workunitid=%d", wu.id); while (!result.enumerate(buf)) { @@ -125,17 +125,19 @@ int main(int argc, char** argv) { asynch = true; } else if (!strcmp(argv[i], "-one_pass")) { one_pass = true; + } else if (!strcmp(argv[i], "-d")) { + set_debug_level(atoi(argv[++i])); } else if (!strcmp(argv[i], "-app")) { strcpy(app.name, argv[++i]); } else { sprintf(buf, "Unrecognized arg: %s\n", argv[i]); - write_log(buf); + write_log(buf, MSG_CRITICAL); } } retval = config.parse_file(); if (retval) { - write_log("Can't parse config file\n"); + write_log("Can't parse config file\n", MSG_CRITICAL); exit(1); } @@ -153,13 +155,13 @@ int main(int argc, char** argv) { retval = boinc_db_open(config.db_name, config.db_passwd); if (retval) { - write_log("Can't open DB\n"); + write_log("Can't open DB\n", MSG_CRITICAL); exit(1); } sprintf(buf, "where name='%s'", app.name); retval = app.lookup(buf); if (retval) { - write_log("Can't find app\n"); + write_log("Can't find app\n", MSG_CRITICAL); exit(1); } if (one_pass) { diff --git a/sched/db_dump.C b/sched/db_dump.C index e72b148692..cc50d950ef 100644 --- a/sched/db_dump.C +++ b/sched/db_dump.C @@ -548,6 +548,8 @@ int main(int argc, char** argv) { for (i=1; iwu_results[i].result = result; @@ -187,18 +187,18 @@ try_again: } ssp->ready = true; if (nadditions == 0) { - write_log("no results added\n"); + write_log("no results added\n", MSG_DEBUG); sleep(1); } else { sprintf(buf, "added %d results to array\n", nadditions); - write_log(buf); + write_log(buf, MSG_DEBUG); } if (no_wus) { - write_log("feeder: no results available\n"); + write_log("feeder: no results available\n", MSG_DEBUG); sleep(5); } if (ncollisions) { - write_log("feeder: some results already in array - sleeping\n"); + write_log("feeder: some results already in array - sleeping\n", MSG_DEBUG); sleep(5); } fflush(stdout); @@ -217,13 +217,15 @@ int main(int argc, char** argv) { retval = config.parse_file(); if (retval) { - write_log("can't parse config file\n"); + write_log("can't parse config file\n", MSG_CRITICAL); exit(1); } for (i=1; iscan_tables(); diff --git a/sched/file_deleter.C b/sched/file_deleter.C index efbc37296e..5b94e2fe2b 100644 --- a/sched/file_deleter.C +++ b/sched/file_deleter.C @@ -55,7 +55,7 @@ int wu_delete_files(WORKUNIT& wu) { if (!no_delete) { sprintf(pathname, "%s/%s", config.download_dir, filename); sprintf(logbuf, "deleting %s\n", pathname); - write_log(logbuf); + write_log(logbuf, MSG_NORMAL); unlink(pathname); } } @@ -82,7 +82,7 @@ int result_delete_files(RESULT& result) { if (!no_delete) { sprintf(pathname, "%s/%s", config.upload_dir, filename); sprintf(logbuf, "deleting %s\n", pathname); - write_log(logbuf); + write_log(logbuf, MSG_NORMAL); unlink(pathname); } } @@ -131,15 +131,17 @@ int main(int argc, char** argv) { asynch = true; } else if (!strcmp(argv[i], "-one_pass")) { one_pass = true; + } else if (!strcmp(argv[i], "-d")) { + set_debug_level(atoi(argv[++i])); } else { sprintf(buf, "Unrecognized arg: %s\n", argv[i]); - write_log(buf); + write_log(buf, MSG_CRITICAL); } } retval = config.parse_file(); if (retval) { - write_log("Can't parse config file\n"); + write_log("Can't parse config file\n", MSG_CRITICAL); exit(1); } @@ -157,7 +159,7 @@ int main(int argc, char** argv) { retval = boinc_db_open(config.db_name, config.db_passwd); if (retval) { - write_log("can't open DB\n"); + write_log("can't open DB\n", MSG_CRITICAL); exit(1); } if (one_pass) { diff --git a/sched/handle_request.C b/sched/handle_request.C index 2ccfdb27ec..3bc6750c5b 100644 --- a/sched/handle_request.C +++ b/sched/handle_request.C @@ -36,6 +36,7 @@ using namespace std; #include "parse.h" #include "util.h" #include "server_types.h" +#include "sched_util.h" #include "main.h" #include "handle_request.h" @@ -52,14 +53,14 @@ bool wu_is_feasible(WORKUNIT& wu, HOST& host) { sprintf(buf, "WU %d needs %f disk; host %d has %f\n", wu.id, wu.rsc_disk, host.id, host.d_free ); - write_log(buf); + write_log(buf, MSG_DEBUG); return false; } if (host.m_nbytes && wu.rsc_memory > host.m_nbytes) { sprintf(buf, "WU %d needs %f mem; host %d has %f\n", wu.id, wu.rsc_memory, host.id, host.m_nbytes ); - write_log(buf); + write_log(buf, MSG_DEBUG); return false; } return true; @@ -83,13 +84,13 @@ int insert_after(char* buffer, char* after, char* text) { char temp[MAX_BLOB_SIZE]; if (strlen(buffer) + strlen(text) > MAX_BLOB_SIZE-1) { - write_log("insert_after: overflow\n"); + write_log("insert_after: overflow\n", MSG_NORMAL); return -1; } p = strstr(buffer, after); if (!p) { sprintf(temp, "insert_after: %s not found in %s\n", after, buffer); - write_log(temp); + write_log(temp, MSG_CRITICAL); return -1; } p += strlen(after); @@ -201,7 +202,7 @@ int add_wu_to_reply( app = ss.lookup_app(wu.appid); if (!app) { sprintf(buf, "Can't find app w/ ID %d\n", wu.appid); - write_log(buf); + write_log(buf, MSG_CRITICAL); return -1; } avp = ss.lookup_app_version(app->id, platform.id, app->min_version); @@ -211,7 +212,7 @@ int add_wu_to_reply( app->id, platform.id, app->min_version ); - write_log(buf); + write_log(buf, MSG_CRITICAL); return -1; } @@ -227,7 +228,7 @@ int add_wu_to_reply( app_version = *avp; retval = insert_app_file_tags(app_version, reply.user); if (retval) { - write_log("insert_app_file_tags failed\n"); + write_log("insert_app_file_tags failed\n", MSG_NORMAL); return retval; } @@ -238,7 +239,7 @@ int add_wu_to_reply( wu2 = wu; // make copy since we're going to modify its XML field retval = insert_wu_tags(wu2, *app); if (retval) { - write_log("insert_wu_tags failed\n"); + write_log("insert_wu_tags failed\n", MSG_NORMAL); return retval; } reply.insert_workunit_unique(wu2); @@ -262,7 +263,7 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { strcpy(reply.message, "Can't find host record"); strcpy(reply.message_priority, "low"); sprintf(buf, "can't find host %d\n", sreq.hostid); - write_log(buf); + write_log(buf, MSG_NORMAL); sreq.hostid = 0; goto new_host; } @@ -275,7 +276,7 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { reply.request_delay = 120; reply.nucleus_only = true; sprintf(buf, "can't find user %d\n", reply.host.userid); - write_log(buf); + write_log(buf, MSG_NORMAL); return -1; } reply.user = user; @@ -288,7 +289,7 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { reply.request_delay = 120; reply.nucleus_only = true; sprintf(buf, "Bad authenticator [%s]\n", sreq.authenticator); - write_log(buf); + write_log(buf, MSG_CRITICAL); return -1; } @@ -318,7 +319,7 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { strcpy(reply.message_priority, "low"); reply.request_delay = 120; sprintf(buf, "Bad authenticator [%s]\n", sreq.authenticator); - write_log(buf); + write_log(buf, MSG_CRITICAL); return -1; } reply.user = user; @@ -337,7 +338,7 @@ new_host: strcpy(reply.message, "server database error"); strcpy(reply.message_priority, "low"); boinc_db_print_error("host.insert()"); - write_log("host.insert() failed\n"); + write_log("host.insert() failed\n", MSG_CRITICAL); return -1; } host.id = boinc_db_insert_id(); @@ -404,7 +405,7 @@ int update_host_record(SCHEDULER_REQUEST& sreq, HOST& xhost) { retval = host.update(); if (retval) { sprintf(buf, "host.update() failed: %d\n", retval); - write_log(buf); + write_log(buf, MSG_CRITICAL); } return 0; } @@ -467,14 +468,14 @@ int handle_results( reply.result_acks.push_back(*rp); sprintf(buf, "got result %s\n", rp->name); - write_log(buf); + write_log(buf, MSG_DEBUG); strncpy(result.name, rp->name, sizeof(result.name)); sprintf(buf, "where name='%s'", result.name); retval = result.lookup(buf); if (retval) { sprintf(buf, "can't find result %s\n", rp->name); - write_log(buf); + write_log(buf, MSG_DEBUG); continue; } @@ -483,7 +484,7 @@ int handle_results( "got unexpected result for %s: server state is %d\n", rp->name, result.server_state ); - write_log(buf); + write_log(buf, MSG_NORMAL); continue; } if (result.server_state == RESULT_SERVER_STATE_OVER) { @@ -498,7 +499,7 @@ int handle_results( "got result from wrong host: %d %d\n", result.hostid, sreq.hostid ); - write_log(buf); + write_log(buf, MSG_NORMAL); continue; } @@ -516,12 +517,12 @@ int handle_results( "can't find WU %d for result %d\n", result.workunitid, result.id ); - write_log(buf); + write_log(buf, MSG_NORMAL); } else { wu.need_validate = 1; retval = wu.update(); if (retval) { - write_log("Can't update WU\n"); + write_log("Can't update WU\n", MSG_CRITICAL); } } } else { @@ -537,7 +538,7 @@ int handle_results( "can't update result %d: %s\n", result.id, boinc_db_error_string() ); - write_log(buf); + write_log(buf, MSG_NORMAL); } } @@ -569,7 +570,7 @@ int send_work( if (sreq.work_req_seconds <= 0) return 0; sprintf(buf, "got request for %d seconds of work\n", sreq.work_req_seconds); - write_log(buf); + write_log(buf, MSG_DEBUG); seconds_to_fill = sreq.work_req_seconds; if (seconds_to_fill > MAX_SECONDS_TO_SEND) { @@ -588,7 +589,7 @@ int send_work( } if (!wu_is_feasible(ss.wu_results[i].workunit, reply.host)) { sprintf(buf, "WU %s is infeasible\n", ss.wu_results[i].workunit.name); - write_log(buf); + write_log(buf, MSG_DEBUG); continue; } @@ -601,14 +602,11 @@ int send_work( ); if (retval) continue; -#if 1 - char buf[256]; sprintf(buf, "sending result name %s, id %d\n", result.name, result.id ); - write_log(buf); -#endif + write_log(buf, MSG_DEBUG); // copy the result so we don't overwrite its XML fields // @@ -616,7 +614,7 @@ int send_work( retval = insert_name_tags(result_copy, wu); if (retval) { - write_log("send_work: can't insert name tags\n"); + write_log("send_work: can't insert name tags\n", MSG_NORMAL); } reply.insert_result(result_copy); @@ -633,7 +631,7 @@ int send_work( } sprintf(buf, "sending %d results\n", nresults); - write_log(buf); + write_log(buf, MSG_DEBUG); if (nresults == 0) { strcpy(reply.message, "no work available"); @@ -656,7 +654,7 @@ void send_code_sign_key( if (strlen(sreq.code_sign_key)) { if (strcmp(sreq.code_sign_key, code_sign_key)) { - write_log("received old code sign key\n"); + write_log("received old code sign key\n", MSG_NORMAL); // look for a signature file // @@ -708,7 +706,7 @@ bool wrong_major_version(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { sprintf(buf, "Wrong major version: wanted %d, got %d\n", MAJOR_VERSION, sreq.core_client_major_version ); - write_log(buf); + write_log(buf, MSG_NORMAL); return true; } return false; @@ -738,7 +736,7 @@ void process_request( sprintf(buf, "platform [%s] not found\n", sreq.platform_name); strcpy(reply.message, buf); strcpy(reply.message_priority, "low"); - write_log(buf); + write_log(buf, MSG_NORMAL); return; } @@ -757,7 +755,7 @@ void handle_request( SCHEDULER_REQUEST sreq; SCHEDULER_REPLY sreply; - write_log("Handling request\n"); + write_log("Handling request\n", MSG_DEBUG); memset(&sreq, 0, sizeof(sreq)); sreq.parse(fin); process_request(sreq, sreply, ss, code_sign_key); diff --git a/sched/main.C b/sched/main.C index 071e1d4752..7bd7bde8ef 100644 --- a/sched/main.C +++ b/sched/main.C @@ -39,6 +39,9 @@ using namespace std; #include "server_types.h" #include "handle_request.h" #include "main.h" +#include "sched_util.h" + +#define DEBUG_LEVEL 1 #define STDERR_FILENAME "cgi_out" #define REQ_FILE_PREFIX "boinc_req_" @@ -63,9 +66,11 @@ int main() { exit(1); } + set_debug_level(DEBUG_LEVEL); + retval = config.parse_file(); if (retval) { - write_log("Can't parse config file\n"); + write_log("Can't parse config file\n", MSG_CRITICAL); exit(1); } @@ -73,35 +78,35 @@ int main() { retval = read_file_malloc(path, code_sign_key); if (retval) { sprintf(buf, "Can't read code sign key file (%s)\n", path); - write_log(buf); + write_log(buf, MSG_CRITICAL); exit(1); } retval = attach_shmem(config.shmem_key, &p); if (retval) { - write_log("Can't attach shmem\n"); + write_log("Can't attach shmem\n", MSG_CRITICAL); exit(1); } ssp = (SCHED_SHMEM*)p; retval = ssp->verify(); if (retval) { - write_log("shmem has wrong struct sizes - recompile\n"); + write_log("shmem has wrong struct sizes - recompile\n", MSG_CRITICAL); exit(1); } for (i=0; i<10; i++) { if (ssp->ready) break; - write_log("waiting for ready flag\n"); + write_log("waiting for ready flag\n", MSG_DEBUG); sleep(1); } if (!ssp->ready) { - write_log("feeder doesn't seem to be running\n"); + write_log("feeder doesn't seem to be running\n", MSG_CRITICAL); exit(1); } retval = boinc_db_open(config.db_name, config.db_passwd); if (retval) { - write_log("can't open database\n"); + write_log("can't open database\n", MSG_CRITICAL); exit(1); } @@ -110,7 +115,7 @@ int main() { found = true; } if (!found) { - write_log("can't find project\n"); + write_log("can't find project\n", MSG_CRITICAL); exit(1); } @@ -131,19 +136,19 @@ int main() { sprintf(reply_path, "%s%d_%u", REPLY_FILE_PREFIX, pid, counter); fout = fopen(req_path, "w"); if (!fout) { - write_log("can't write request file\n"); + write_log("can't write request file\n", MSG_CRITICAL); exit(1); } copy_stream(stdin, fout); fclose(fout); fin = fopen(req_path, "r"); if (!fin) { - write_log("can't read request file\n"); + write_log("can't read request file\n", MSG_CRITICAL); exit(1); } fout = fopen(reply_path, "w"); if (!fout) { - write_log("can't write reply file\n"); + write_log("can't write reply file\n", MSG_CRITICAL); exit(1); } handle_request(fin, fout, *ssp, code_sign_key); @@ -151,7 +156,7 @@ int main() { fclose(fout); fin = fopen(reply_path, "r"); if (!fin) { - write_log("can't read reply file\n"); + write_log("can't read reply file\n", MSG_CRITICAL); exit(1); } copy_stream(fin, stdout); diff --git a/sched/main.h b/sched/main.h index 950ffe74aa..2da3634e54 100644 --- a/sched/main.h +++ b/sched/main.h @@ -22,4 +22,3 @@ extern DB_PROJECT gproject; extern CONFIG config; -extern void write_log(char*); diff --git a/sched/make_work.C b/sched/make_work.C index 5a4d6f6120..cf5df83906 100644 --- a/sched/make_work.C +++ b/sched/make_work.C @@ -96,13 +96,13 @@ void make_work() { retval = config.parse_file(); if (retval) { - write_log("can't read config file\n"); + write_log("can't read config file\n", MSG_CRITICAL); exit(1); } retval = boinc_db_open(config.db_name, config.db_passwd); if (retval) { - write_log("can't open db\n"); + write_log("can't open db\n", MSG_CRITICAL); exit(1); } @@ -110,7 +110,7 @@ void make_work() { retval = wu.lookup(buf); if (retval) { sprintf(buf, "can't find wu %s\n", wu_name); - write_log(buf); + write_log(buf, MSG_CRITICAL); exit(1); } @@ -119,13 +119,13 @@ void make_work() { sprintf(keypath, "%s/upload_private", config.key_dir); retval = read_key_file(keypath, key); if (retval) { - write_log("can't read key\n"); + write_log("can't read key\n", MSG_CRITICAL); exit(1); } retval = read_filename(result_template_file, result_template); if (retval) { - write_log("can't open result template\n"); + write_log("can't open result template\n", MSG_CRITICAL); exit(1); } nresults_left = 0; @@ -133,7 +133,7 @@ void make_work() { sprintf(buf, "where server_state=%d", RESULT_SERVER_STATE_UNSENT); retval = result.count(n, buf); if (retval) { - write_log("can't count results\n"); + write_log("can't count results\n", MSG_CRITICAL); exit(1); } if (n > cushion) { @@ -162,12 +162,12 @@ void make_work() { ); sprintf(command,"cp %s %s", pathname, new_pathname); if (system(command)) { - write_log("system() error\n"); + write_log("system() error\n", MSG_CRITICAL); perror(command); exit(1); } sprintf(buf, "%s\n", command); - write_log(buf); + write_log(buf, MSG_NORMAL); strcpy(new_buf, starting_xml); replace_file_name( new_buf, file_name, new_file_name, config.download_url @@ -183,7 +183,7 @@ void make_work() { retval = wu.insert(); wu.id = boinc_db_insert_id(); sprintf(buf, "Created new WU: %s\n", wu.name); - write_log(buf); + write_log(buf, MSG_DEBUG); } sprintf(suffix, "%d_%d", start_time, seqno++); create_result( @@ -191,7 +191,7 @@ void make_work() { config.upload_url, config.download_url ); sprintf(buf, "added result: %s_%s\n", wu.name, suffix); - write_log(buf); + write_log(buf, MSG_DEBUG); nresults_left--; check_stop_trigger(); } @@ -211,17 +211,19 @@ int main(int argc, char** argv) { redundancy = atoi(argv[++i]); } else if (!strcmp(argv[i], "-result_template")) { strcpy(result_template_file, argv[++i]); + } else if (!strcmp(argv[i], "-d")) { + set_debug_level(atoi(argv[++i])); } else if (!strcmp(argv[i], "-wu_name")) { strcpy(wu_name, argv[++i]); } } if (!strlen(result_template_file)) { - write_log("missing -result_template\n"); + write_log("missing -result_template\n", MSG_CRITICAL); exit(1); } if (!strlen(wu_name)) { - write_log("missing -wu_name\n"); + write_log("missing -wu_name\n", MSG_CRITICAL); exit(1); } diff --git a/sched/sched_util.C b/sched/sched_util.C index 7cd5d082bb..be6fa434df 100644 --- a/sched/sched_util.C +++ b/sched/sched_util.C @@ -27,8 +27,15 @@ using namespace std; #include "sched_util.h" #include "server_types.h" -void write_log(char* p) { - fprintf(stderr, "%s: %s", timestamp(), p); +int debug_level = 0; + +void write_log(char* p, int msg_level) { + if (msg_level <= debug_level) + fprintf(stderr, "%s: %s", timestamp(), p); +} + +void set_debug_level(int new_level) { + debug_level = new_level; } void check_stop_trigger() { diff --git a/sched/sched_util.h b/sched/sched_util.h index 53287a20ae..7a05e43b40 100644 --- a/sched/sched_util.h +++ b/sched/sched_util.h @@ -39,7 +39,12 @@ #define STOP_TRIGGER_FILENAME "stop_server" -extern void write_log(char*); +#define MSG_CRITICAL 0 +#define MSG_NORMAL 1 +#define MSG_DEBUG 2 + +extern void write_log(char*, int); +extern void set_debug_level(int); extern void check_stop_trigger(); extern void update_average(double, double, double&, double&); diff --git a/sched/server_types.C b/sched/server_types.C index 1372dafe66..86be71c335 100644 --- a/sched/server_types.C +++ b/sched/server_types.C @@ -29,6 +29,7 @@ using namespace std; #include "util.h" #include "main.h" #include "server_types.h" +#include "sched_util.h" SCHEDULER_REQUEST::SCHEDULER_REQUEST() { } @@ -87,7 +88,7 @@ int SCHEDULER_REQUEST::parse(FILE* fin) { } else { sprintf(ebuf, "SCHEDULER_REQUEST::parse(): unrecognized: %s\n", buf); - write_log(ebuf); + write_log(ebuf, MSG_NORMAL); } } return 1; @@ -295,7 +296,7 @@ int RESULT::parse_from_client(FILE* fin) { continue; } else { sprintf(ebuf, "RESULT::parse_from_client(): unrecognized: %s\n", buf); - write_log(ebuf); + write_log(ebuf, MSG_NORMAL); } } return 1; @@ -328,7 +329,7 @@ int HOST::parse(FILE* fin) { else if (parse_double(buf, "", n_bwdown)) continue; else { sprintf(ebuf, "HOST::parse(): unrecognized: %s\n", buf); - write_log(ebuf); + write_log(ebuf, MSG_NORMAL); } } return 1; @@ -345,7 +346,7 @@ int HOST::parse_time_stats(FILE* fin) { else if (parse_double(buf, "", active_frac)) continue; else { sprintf(ebuf, "HOST::parse_time_stats(): unrecognized: %s\n", buf); - write_log(ebuf); + write_log(ebuf, MSG_NORMAL); } } return 1; @@ -360,7 +361,7 @@ int HOST::parse_net_stats(FILE* fin) { else if (parse_double(buf, "", n_bwdown)) continue; else { sprintf(ebuf, "HOST::parse_net_stats(): unrecognized: %s\n", buf); - write_log(ebuf); + write_log(ebuf, MSG_NORMAL); } } return 1; @@ -375,7 +376,7 @@ int APP_FILE::parse(char*& in) { else if (parse_str(buf, "", open_name, sizeof(open_name))) continue; else { sprintf(ebuf, "APP_FILE::parse(): unrecognized %s\n", buf); - write_log(ebuf); + write_log(ebuf, MSG_NORMAL); } } return 1; diff --git a/sched/update_stats.C b/sched/update_stats.C index 1c888581c4..7861608a98 100644 --- a/sched/update_stats.C +++ b/sched/update_stats.C @@ -122,11 +122,13 @@ int main(int argc, char** argv) { do_update_users = true; } else if (!strcmp(argv[i], "-update_hosts")) { do_update_hosts = true; + } else if (!strcmp(argv[i], "-d")) { + set_debug_level(atoi(argv[++i])); } else if (!strcmp(argv[i], "-asynch")) { asynch = true; } else { sprintf(buf, "Unrecognized arg: %s\n", argv[i]); - write_log(buf); + write_log(buf, MSG_CRITICAL); } } diff --git a/sched/validate.C b/sched/validate.C index d0600d307a..9b08171140 100644 --- a/sched/validate.C +++ b/sched/validate.C @@ -97,14 +97,14 @@ void handle_wu(DB_WORKUNIT& wu) { sprintf(buf, "validating WU %s; already have canonical result\n", wu.name ); - write_log(buf); + write_log(buf, MSG_NORMAL); // Here if WU already has a canonical result. // Get unchecked results and see if they match the canonical result // retval = canonical_result.lookup_id(wu.canonical_resultid); if (retval) { - write_log("can't read canonical result\n"); + write_log("can't read canonical result\n", MSG_NORMAL); // Mark this WU as validated, otherwise we'll keep checking it goto mark_validated; } @@ -123,7 +123,7 @@ void handle_wu(DB_WORKUNIT& wu) { "validate: pair_check failed for result %d\n", result.id ); - write_log(buf); + write_log(buf, MSG_DEBUG); continue; } else { if (match) { @@ -137,12 +137,12 @@ void handle_wu(DB_WORKUNIT& wu) { } retval = result.update(); if (retval) { - write_log("Can't update result\n"); + write_log("Can't update result\n", MSG_CRITICAL); continue; } retval = grant_credit(result, result.granted_credit); if (retval) { - write_log("Can't grant credit\n"); + write_log("Can't grant credit\n", MSG_NORMAL); continue; } } @@ -154,7 +154,7 @@ void handle_wu(DB_WORKUNIT& wu) { // Try to get one sprintf(buf, "validating WU %s; no canonical result\n", wu.name); - write_log(buf); + write_log(buf, MSG_DEBUG); sprintf(buf, "where workunitid=%d", wu.id); while (!result.enumerate(buf)) { @@ -165,11 +165,11 @@ void handle_wu(DB_WORKUNIT& wu) { } } sprintf(buf, "found %d successful results\n", results.size()); - write_log(buf); + write_log(buf, MSG_DEBUG); if (results.size() >= (unsigned int)min_quorum) { retval = check_set(results, canonicalid, credit); if (!retval && canonicalid) { - write_log("found a canonical result\n"); + write_log("found a canonical result\n", MSG_DEBUG); wu.canonical_resultid = canonicalid; wu.canonical_credit = credit; wu.assimilate_state = ASSIMILATE_READY; @@ -186,14 +186,14 @@ void handle_wu(DB_WORKUNIT& wu) { sprintf(buf, "validate: grant_credit %d\n", retval ); - write_log(buf); + write_log(buf, MSG_DEBUG); } result.granted_credit = credit; sprintf(buf, "updating result %d to %d; credit %f\n", result.id, result.validate_state, credit ); - write_log(buf); + write_log(buf, MSG_NORMAL); } // don't send any unsent results @@ -210,7 +210,7 @@ void handle_wu(DB_WORKUNIT& wu) { sprintf(buf, "validate: boinc_db_result_update %d\n", retval ); - write_log(buf); + write_log(buf, MSG_CRITICAL); } } } @@ -225,7 +225,7 @@ void handle_wu(DB_WORKUNIT& wu) { retval = wu.update(); if (retval) { sprintf(buf, "db_workunit_update: %d\n", retval); - write_log(buf); + write_log(buf, MSG_CRITICAL); } } @@ -254,7 +254,7 @@ int main_loop(bool one_pass) { retval = boinc_db_open(config.db_name, config.db_passwd); if (retval) { sprintf(buf, "boinc_db_open: %d\n", retval); - write_log(buf); + write_log(buf, MSG_CRITICAL); exit(1); } @@ -262,7 +262,7 @@ int main_loop(bool one_pass) { retval = app.lookup(buf); if (retval) { sprintf(buf, "can't find app %s\n", app.name); - write_log(buf); + write_log(buf, MSG_CRITICAL); exit(1); } @@ -292,26 +292,28 @@ int main(int argc, char** argv) { one_pass = true; } else if (!strcmp(argv[i], "-app")) { strcpy(app_name, argv[++i]); + } else if (!strcmp(argv[i], "-d")) { + set_debug_level(atoi(argv[++i])); } else if (!strcmp(argv[i], "-quorum")) { min_quorum = atoi(argv[++i]); } else { sprintf(buf, "unrecognized arg: %s\n", argv[i]); - write_log(buf); + write_log(buf, MSG_CRITICAL); } } if (min_quorum < 1 || min_quorum > 10) { sprintf(buf, "bad min_quorum: %d\n", min_quorum); - write_log(buf); + write_log(buf, MSG_CRITICAL); exit(1); } sprintf(buf, "starting validator; min_quorum %d\n", min_quorum); - write_log(buf); + write_log(buf, MSG_NORMAL); retval = config.parse_file(); if (retval) { - write_log("Can't parse config file\n"); + write_log("Can't parse config file\n", MSG_CRITICAL); exit(1); }