From a87d039f49c80368a40837c579fbf371a21b812d Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 29 Jul 2015 17:32:57 -0700 Subject: [PATCH] server: more 64-bit ID fixes negative values are stored in app_version_id fields to represent anonymous platform versions. So need to use %ld rather than %lu for these fields. Also there were a couple of more changes of int do DB_ID_TYPE --- db/boinc_db.cpp | 17 ++++++++++------- db/boinc_db_types.h | 3 +++ sched/credit.cpp | 14 ++++++-------- sched/db_purge.cpp | 2 +- sched/sched_main.cpp | 8 +++++++- sched/sched_result.cpp | 14 +++++++------- sched/sched_send.cpp | 2 +- sched/sched_shmem.cpp | 6 +++--- sched/sched_shmem.h | 6 +++--- sched/sched_types.cpp | 2 +- sched/sched_types.h | 4 ++-- sched/transitioner.cpp | 4 ++-- 12 files changed, 46 insertions(+), 36 deletions(-) diff --git a/db/boinc_db.cpp b/db/boinc_db.cpp index f89c87eef1..923a55f63c 100644 --- a/db/boinc_db.cpp +++ b/db/boinc_db.cpp @@ -880,7 +880,7 @@ void DB_WORKUNIT::db_print(char* buf){ "priority=%d, " "rsc_bandwidth_bound=%.15e, " "fileset_id=%lu, " - "app_version_id=%lu, " + "app_version_id=%ld, " "transitioner_flags=%d, " "size_class=%d ", create_time, appid, @@ -923,7 +923,7 @@ void DB_WORKUNIT::db_print_values(char* buf) { "%d, NOW(), " "%f, " "%lu, " - "%lu, " + "%ld, " "%d, " "%d)", create_time, appid, @@ -1017,7 +1017,7 @@ void DB_RESULT::db_print(char* buf){ "claimed_credit=%.15e, granted_credit=%.15e, opaque=%.15e, random=%d, " "app_version_num=%d, appid=%lu, exit_status=%d, teamid=%lu, " "priority=%d, elapsed_time=%.15e, flops_estimate=%.15e, " - "app_version_id=%lu, runtime_outlier=%d, size_class=%d, " + "app_version_id=%ld, runtime_outlier=%d, size_class=%d, " "peak_working_set_size=%.0f, " "peak_swap_size=%.0f, " "peak_disk_usage=%.0f ", @@ -1081,7 +1081,7 @@ int DB_RESULT::mark_as_sent(int old_server_state, int report_grace_period) { int retval; sprintf(query, - "update result set server_state=%d, hostid=%lu, userid=%lu, sent_time=%d, report_deadline=%d, flops_estimate=%.15e, app_version_id=%lu where id=%lu and server_state=%d", + "update result set server_state=%d, hostid=%lu, userid=%lu, sent_time=%d, report_deadline=%d, flops_estimate=%.15e, app_version_id=%ld where id=%lu and server_state=%d", server_state, hostid, userid, @@ -1322,7 +1322,10 @@ int DB_HOST_APP_VERSION::update_scheduler(DB_HOST_APP_VERSION& orig) { max_jobs_per_day, n_jobs_today ); - sprintf(clause, "host_id=%lu and app_version_id=%lu", host_id, app_version_id); + sprintf(clause, + "host_id=%lu and app_version_id=%ld", + host_id, app_version_id + ); return update_fields_noid(query, clause); } @@ -1371,7 +1374,7 @@ int DB_HOST_APP_VERSION::update_validator(DB_HOST_APP_VERSION& orig) { max_jobs_per_day ); sprintf(clause, - "host_id=%lu and app_version_id=%lu ", + "host_id=%lu and app_version_id=%ld ", host_id, app_version_id ); return update_fields_noid(query, clause); @@ -1380,7 +1383,7 @@ int DB_HOST_APP_VERSION::update_validator(DB_HOST_APP_VERSION& orig) { void DB_HOST_APP_VERSION::db_print(char* buf) { sprintf(buf, "host_id=%lu, " - "app_version_id=%lu, " + "app_version_id=%ld, " "pfc_n=%.15e, " "pfc_avg=%.15e, " "et_n=%.15e, " diff --git a/db/boinc_db_types.h b/db/boinc_db_types.h index d287be0e81..2a62b4a655 100644 --- a/db/boinc_db_types.h +++ b/db/boinc_db_types.h @@ -39,6 +39,9 @@ struct BEST_APP_VERSION; typedef long DB_ID_TYPE; + // in principle should be unsigned long, + // but we put negative values in app_version_id to represent + // anonymous platform versions // A compilation target, i.e. a architecture/OS combination. // Client will be sent applications only for platforms they support. diff --git a/sched/credit.cpp b/sched/credit.cpp index bab5adcd69..f41b74eea6 100644 --- a/sched/credit.cpp +++ b/sched/credit.cpp @@ -391,7 +391,7 @@ int hav_lookup( ) { int retval; char buf[256]; - sprintf(buf, "where host_id=%lu and app_version_id=%lu", hostid, gen_avid); + sprintf(buf, "where host_id=%lu and app_version_id=%ld", hostid, gen_avid); retval = hav.lookup(buf); if (retval != ERR_DB_NOT_FOUND) return retval; @@ -441,9 +441,9 @@ int hav_lookup( if (found) { hav = best_hav; char query[256], where_clause[256]; - sprintf(query, "app_version_id=%lu", gen_avid); + sprintf(query, "app_version_id=%ld", gen_avid); sprintf(where_clause, - "host_id=%lu and app_version_id=%lu", + "host_id=%lu and app_version_id=%ld", hostid, best_av.id ); retval = hav.update_fields_noid(query, where_clause); @@ -530,7 +530,7 @@ int get_pfc( if (r.app_version_id == 0 || r.app_version_id == 1) { if (config.debug_credit) { log_messages.printf(MSG_NORMAL, - "[credit] [RESULT#%lu] missing app_version_id (%lu): returning WU default %.2f\n", + "[credit] [RESULT#%lu] missing app_version_id (%ld): returning WU default %.2f\n", r.id, r.app_version_id, wu_estimated_credit(wu, app) ); } @@ -545,7 +545,7 @@ int get_pfc( if (strstr(r.stderr_out, "Device Emulation (CPU)")) { if (config.debug_credit) { log_messages.printf(MSG_NORMAL, - "[credit] [RESULT#%lu][AV#%lu] CUDA app fell back to CPU; returning WU default %.2f\n", + "[credit] [RESULT#%lu][AV#%ld] CUDA app fell back to CPU; returning WU default %.2f\n", r.id, r.app_version_id, wu.rsc_fpops_est*COBBLESTONE_SCALE ); } @@ -554,8 +554,6 @@ int get_pfc( return 0; } - //int gavid = generalized_app_version_id(r.app_version_id, r.appid); - // transition case: there's no host_app_version record // if (!hav.host_id) { @@ -732,7 +730,7 @@ int get_pfc( avp = av_lookup(r.app_version_id, app_versions); if (!avp) { log_messages.printf(MSG_CRITICAL, - "get_pfc() [RESULT#%lu]: No AVP %lu!!\n", r.id, r.app_version_id + "get_pfc() [RESULT#%lu]: No AVP %ld!!\n", r.id, r.app_version_id ); return ERR_NOT_FOUND; } diff --git a/sched/db_purge.cpp b/sched/db_purge.cpp index 9a7c8918db..ed745b91c2 100644 --- a/sched/db_purge.cpp +++ b/sched/db_purge.cpp @@ -311,7 +311,7 @@ int archive_result(DB_RESULT& result) { " %f\n" " %d\n" " %d\n" - " %lu\n" + " %ld\n" " %lu\n" " %d\n" " %lu\n" diff --git a/sched/sched_main.cpp b/sched/sched_main.cpp index 0f88f67cc4..0f8f8af664 100644 --- a/sched/sched_main.cpp +++ b/sched/sched_main.cpp @@ -15,8 +15,14 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . -// The BOINC scheduling server. +// The BOINC scheduler. +// Normally runs as a CGI or fast CGI program. +// You can also run it: +// - manually for debugging, with a single request +// - for simulation or performance testing, with a stream of requests +// (using --batch) +// TODO: what does the following mean? // Also, You can call debug_sched() for whatever situation is of // interest to you. It won't do anything unless you create // (touch) the file 'debug_sched' in the project root directory. diff --git a/sched/sched_result.cpp b/sched/sched_result.cpp index 4dc3149f33..7c4dace6bf 100644 --- a/sched/sched_result.cpp +++ b/sched/sched_result.cpp @@ -32,12 +32,12 @@ // got a SUCCESS result. Doesn't mean it's valid! // static inline void got_good_result(SCHED_RESULT_ITEM& sri) { - int gavid = generalized_app_version_id(sri.app_version_id, sri.appid); + DB_ID_TYPE gavid = generalized_app_version_id(sri.app_version_id, sri.appid); DB_HOST_APP_VERSION* havp = gavid_to_havp(gavid); if (!havp) { if (config.debug_handle_results) { log_messages.printf(MSG_NORMAL, - "[handle] No app version for %d\n", gavid + "[handle] No app version for %ld\n", gavid ); } return; @@ -49,7 +49,7 @@ static inline void got_good_result(SCHED_RESULT_ITEM& sri) { } if (config.debug_quota) { log_messages.printf(MSG_NORMAL, - "[quota] increasing max_jobs_per_day for %d: %d->%d\n", + "[quota] increasing max_jobs_per_day for %ld: %d->%d\n", gavid, havp->max_jobs_per_day, n ); } @@ -63,12 +63,12 @@ static inline void got_good_result(SCHED_RESULT_ITEM& sri) { // - mechanism that categorizes hosts as "reliable" // static inline void got_bad_result(SCHED_RESULT_ITEM& sri) { - int gavid = generalized_app_version_id(sri.app_version_id, sri.appid); + DB_ID_TYPE gavid = generalized_app_version_id(sri.app_version_id, sri.appid); DB_HOST_APP_VERSION* havp = gavid_to_havp(gavid); if (!havp) { if (config.debug_handle_results) { log_messages.printf(MSG_NORMAL, - "[handle] No app version for %d\n", gavid + "[handle] No app version for %ld\n", gavid ); } return; @@ -84,7 +84,7 @@ static inline void got_bad_result(SCHED_RESULT_ITEM& sri) { } if (config.debug_quota) { log_messages.printf(MSG_NORMAL, - "[quota] decreasing max_jobs_per_day for %d: %d->%d\n", + "[quota] decreasing max_jobs_per_day for %ld: %d->%d\n", gavid, havp->max_jobs_per_day, n ); } @@ -313,7 +313,7 @@ int handle_results() { // if it's a single-thread app, set ET = CPU // if (srip->elapsed_time < srip->cpu_time) { - int avid = srip->app_version_id; + DB_ID_TYPE avid = srip->app_version_id; if (avid > 0) { APP_VERSION* avp = ssp->lookup_app_version(avid); if (avp && !avp->is_multithread()) { diff --git a/sched/sched_send.cpp b/sched/sched_send.cpp index 8e85cd7ceb..82c55b5b74 100644 --- a/sched/sched_send.cpp +++ b/sched/sched_send.cpp @@ -890,7 +890,7 @@ bool work_needed(bool locality_sched) { // return the app version ID, or -2/-3/-4 if anonymous platform // -inline static int get_app_version_id(BEST_APP_VERSION* bavp) { +inline static DB_ID_TYPE get_app_version_id(BEST_APP_VERSION* bavp) { if (bavp->avp) { return bavp->avp->id; } else { diff --git a/sched/sched_shmem.cpp b/sched/sched_shmem.cpp index 1d72649ccf..04f8b3178a 100644 --- a/sched/sched_shmem.cpp +++ b/sched/sched_shmem.cpp @@ -264,14 +264,14 @@ PLATFORM* SCHED_SHMEM::lookup_platform(char* name) { return NULL; } -PLATFORM* SCHED_SHMEM::lookup_platform_id(int id) { +PLATFORM* SCHED_SHMEM::lookup_platform_id(DB_ID_TYPE id) { for (int i=0; ihost_app_versions_orig = g_wreq->host_app_versions; } -DB_HOST_APP_VERSION* gavid_to_havp(int gavid) { +DB_HOST_APP_VERSION* gavid_to_havp(DB_ID_TYPE gavid) { for (unsigned int i=0; ihost_app_versions.size(); i++) { DB_HOST_APP_VERSION& hav = g_wreq->host_app_versions[i]; if (hav.app_version_id == gavid) return &hav; diff --git a/sched/sched_types.h b/sched/sched_types.h index 01c5530ca7..52ab5e6e8d 100644 --- a/sched/sched_types.h +++ b/sched/sched_types.h @@ -550,10 +550,10 @@ static inline void add_no_work_message(const char* m) { extern void get_weak_auth(USER&, char*); extern void get_rss_auth(USER&, char*); extern void read_host_app_versions(); -extern DB_HOST_APP_VERSION* get_host_app_version(int gavid); +extern DB_HOST_APP_VERSION* get_host_app_version(DB_ID_TYPE gavid); extern void write_host_app_versions(); -extern DB_HOST_APP_VERSION* gavid_to_havp(int gavid); +extern DB_HOST_APP_VERSION* gavid_to_havp(DB_ID_TYPE gavid); extern DB_HOST_APP_VERSION* quota_exceeded_version(); inline bool is_64b_platform(const char* name) { diff --git a/sched/transitioner.cpp b/sched/transitioner.cpp index 6df42fc2a9..6a0f98ef01 100644 --- a/sched/transitioner.cpp +++ b/sched/transitioner.cpp @@ -88,7 +88,7 @@ static int result_timed_out( DB_HOST_APP_VERSION hav; char query[512], clause[512]; - int gavid = generalized_app_version_id( + DB_ID_TYPE gavid = generalized_app_version_id( res_item.res_app_version_id, wu_item.appid ); int retval = hav_lookup(hav, res_item.res_hostid, gavid); @@ -115,7 +115,7 @@ static int result_timed_out( } if (config.debug_quota) { log_messages.printf(MSG_NORMAL, - "[quota] max_jobs_per_day for %d; %d->%d\n", + "[quota] max_jobs_per_day for %ld; %d->%d\n", gavid, hav.max_jobs_per_day, n ); }