From cc7d507789d34a33f82f9c6adeee66184f6cdbe6 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 4 Sep 2008 08:33:21 +0000 Subject: [PATCH] - DB interface: in update(), check that 1 row was updated - API: in APP_INIT_DATA, enclose project preferences in tags so that it's legal XML - scheduler: add option. Use this if your project runs on Condor or grids and (to use multicore machines) you're running multiple clients per host. This will skip the host lookup based on IP address. svn path=/trunk/boinc/; revision=15954 --- checkin_notes | 19 +++++++++++++++++++ db/db_base.C | 5 ++++- lib/app_ipc.C | 2 +- lib/parse.C | 25 ++++++++++++++++++++++++- lib/parse.h | 1 + sched/handle_request.C | 5 ++++- sched/sched_config.C | 1 + sched/sched_config.h | 1 + 8 files changed, 55 insertions(+), 4 deletions(-) diff --git a/checkin_notes b/checkin_notes index 3b8d999d72..809489082b 100644 --- a/checkin_notes +++ b/checkin_notes @@ -7151,3 +7151,22 @@ David 4 Sep 2008 html/user/ white.css + +David 4 Sep 2008 + - DB interface: in update(), check that 1 row was updated + - API: in APP_INIT_DATA, enclose project preferences in tags + so that it's legal XML + - scheduler: add option. + Use this if your project runs on Condor or grids + and (to use multicore machines) you're running + multiple clients per host. + This will skip the host lookup based on IP address. + + db/ + db_base.C + lib/ + app_ipc.C + parse.C,h + sched/ + handle_request.C + sched_config.C,h diff --git a/db/db_base.C b/db/db_base.C index 1b131a2717..18fc370906 100644 --- a/db/db_base.C +++ b/db/db_base.C @@ -156,7 +156,10 @@ int DB_BASE::update() { char vals[MAX_QUERY_LEN], query[MAX_QUERY_LEN]; db_print(vals); sprintf(query, "update %s set %s where id=%d", table_name, vals, get_id()); - return db->do_query(query); + int retval = db->do_query(query); + if (retval) return retval; + if (db->affected_rows() != 1) return ERR_DB_NOT_FOUND; + return 0; } // update one or more fields diff --git a/lib/app_ipc.C b/lib/app_ipc.C index d860a2fab0..812e7ad1d2 100644 --- a/lib/app_ipc.C +++ b/lib/app_ipc.C @@ -198,7 +198,7 @@ int parse_init_data_file(FILE* f, APP_INIT_DATA& ai) { } if (!strcmp(tag, "/app_init_data")) return 0; if (!strcmp(tag, "project_preferences")) { - retval = dup_element_contents(f, "", &ai.project_preferences); + retval = dup_element(f, "project_preferences", &ai.project_preferences); if (retval) return retval; continue; } diff --git a/lib/parse.C b/lib/parse.C index 27d57ce555..cc6801b696 100644 --- a/lib/parse.C +++ b/lib/parse.C @@ -146,7 +146,8 @@ int strcatdup(char*& p, char* buf) { return 0; } -// copy from a file to a malloc'd string until the end tag is reached +// Copy from a file to a malloc'd string until the end tag is reached +// Does NOT copy the start and end tags. // int dup_element_contents(FILE* in, const char* end_tag, char** pp) { char buf[256]; @@ -164,6 +165,28 @@ int dup_element_contents(FILE* in, const char* end_tag, char** pp) { return ERR_XML_PARSE; } +int dup_element(FILE* in, const char* tag_name, char** pp) { + char buf[256], end_tag[256]; + int retval; + + sprintf(buf, "<%s>\n", tag_name); + sprintf(end_tag, "", tag_name); + + char* p = strdup(buf); + while (fgets(buf, 256, in)) { + if (strstr(buf, end_tag)) { + sprintf(buf, "\n", tag_name); + retval = strcatdup(p, buf); + if (retval) return retval; + *pp = p; + return 0; + } + retval = strcatdup(p, buf); + if (retval) return retval; + } + return ERR_XML_PARSE; +} + // copy from a file to static buffer // int copy_element_contents(FILE* in, const char* end_tag, char* p, int len) { diff --git a/lib/parse.h b/lib/parse.h index 7af00c66c8..acdf246062 100644 --- a/lib/parse.h +++ b/lib/parse.h @@ -114,6 +114,7 @@ extern bool parse_bool(const char*, const char*, bool&); extern int copy_stream(FILE* in, FILE* out); extern int strcatdup(char*& p, char* buf); extern int dup_element_contents(FILE* in, const char* end_tag, char** pp); +extern int dup_element(FILE* in, const char* end_tag, char** pp); extern int copy_element_contents(FILE* in, const char* end_tag, char* p, int len); extern int copy_element_contents(FILE* in, const char* end_tag, std::string&); extern void replace_element_contents( diff --git a/sched/handle_request.C b/sched/handle_request.C index 72d0ee4c94..25e4e995ec 100644 --- a/sched/handle_request.C +++ b/sched/handle_request.C @@ -396,7 +396,10 @@ make_new_host: // If found, use the existing host record, // and mark in-progress results as over. // - if (find_host_by_other(user, sreq.host, host)) { + // NOTE: if the project allows multiple clients per host + // (e.g. those that run on grids), skip this. + // + if (!config.multiple_clients_per_host && find_host_by_other(user, sreq.host, host)) { log_messages.printf(MSG_NORMAL, "[HOST#%d] [USER#%d] Found similar existing host for this user - assigned.\n", host.id, host.userid diff --git a/sched/sched_config.C b/sched/sched_config.C index bc22a8775f..72326b6efe 100644 --- a/sched/sched_config.C +++ b/sched/sched_config.C @@ -189,6 +189,7 @@ int SCHED_CONFIG::parse(FILE* f) { if (xp.parse_int(tag, "mm_max_slots", mm_max_slots)) continue; if (xp.parse_bool(tag, "job_size_matching", job_size_matching)) continue; if (xp.parse_bool(tag, "use_credit_multiplier", use_credit_multiplier)) continue; + if (xp.parse_bool(tag, "multiple_clients_per_host", multiple_clients_per_host)) continue; if (xp.parse_bool(tag, "debug_version_select", debug_version_select)) continue; diff --git a/sched/sched_config.h b/sched/sched_config.h index 72fa90ad41..de291a84d0 100644 --- a/sched/sched_config.h +++ b/sched/sched_config.h @@ -125,6 +125,7 @@ public: int mm_max_slots; bool job_size_matching; bool use_credit_multiplier; + bool multiple_clients_per_host; // log flags //