From 24ebadef4c54d0e8e9b95a494a827f59c23a3126 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 7 Jun 2005 21:46:11 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=6299 --- checkin_notes | 16 ++++++++++++++++ client/client_types.C | 9 ++++++++- client/client_types.h | 3 +++ client/cs_apps.C | 37 ++++++++++++++++--------------------- client/cs_scheduler.C | 6 +----- client/scheduler_op.C | 6 ++++-- lib/msg_log.C | 8 ++++---- lib/network.C | 2 +- lib/network.h | 2 +- 9 files changed, 54 insertions(+), 35 deletions(-) diff --git a/checkin_notes b/checkin_notes index ba9f59eb21..f8d442bd82 100755 --- a/checkin_notes +++ b/checkin_notes @@ -7488,3 +7488,19 @@ David 7 June 2005 client_types.C,h cs_scheduler.C scheduler_op.C,h + +David 7 June 2005 + - code cleanup: use new functions (like RESULT::runnable() etc.) + instead of inspecting member variables (like suspended_via_gui) + - Added RESULT::runnable_soon(): true iff result is + downloading or runnable, not suspended, project not suspended + - fix bug in Rom's last checkin (Rom, please verify) + + client/ + client_types.C,h + cs_apps.C + cs_scheduler.C + scheduler_op.C + lib/ + msg_log.C + network.C,h diff --git a/client/client_types.C b/client/client_types.C index 45075bae00..168c19207d 100644 --- a/client/client_types.C +++ b/client/client_types.C @@ -418,7 +418,7 @@ bool PROJECT::downloading() { for (unsigned int i=0; iproject != this) continue; - if (rp->state = RESULT_FILES_DOWNLOADING) return true; + if (rp->state == RESULT_FILES_DOWNLOADING) return true; } return false; } @@ -1430,6 +1430,13 @@ bool RESULT::runnable() { return true; } +bool RESULT::runnable_soon() { + if (suspended_via_gui) return false; + if (project->suspended_via_gui) return false; + if (computing_done()) return false; + return true; +} + FILE_REF* RESULT::lookup_file(FILE_INFO* fip) { for (unsigned int i=0; iresult->suspended_via_gui) continue; - if (atp->result->already_selected) continue; - project = atp->wup->project; - if (project->suspended_via_gui) continue; + rp = atp->result; + if (rp->already_selected) continue; + if (!rp->runnable()) continue; + project = rp->project; if (!project->next_runnable_result) { - project->next_runnable_result = atp->result; + project->next_runnable_result = rp; continue; } @@ -283,15 +283,13 @@ void CLIENT_STATE::assign_results_to_projects() { // for (i=0; ialready_selected) continue; + if (lookup_active_task_by_result(rp)) continue; + if (!rp->runnable()) continue; project = rp->project; - if (project->suspended_via_gui) continue; if (project->next_runnable_result) continue; - if (rp->already_selected) continue; - if (rp->suspended_via_gui) continue; - if (rp->state != RESULT_FILES_DOWNLOADED) continue; - if (lookup_active_task_by_result(rp)) continue; project->next_runnable_result = rp; } @@ -360,18 +358,15 @@ bool CLIENT_STATE::schedule_earliest_deadline_result(double expected_pay_off) { unsigned int i; for (i=0; i < results.size(); ++i) { - RESULT *r = results[i]; - if (r->state != RESULT_FILES_DOWNLOADED) continue; - if (r->suspended_via_gui) continue; - if (r->project->suspended_via_gui) continue; - if (r->project->non_cpu_intensive) continue; - if (r->already_selected) continue; - if (r->suspended_via_gui) continue; - if (first || r->report_deadline < earliest_deadline) { + RESULT *rp = results[i]; + if (!rp->runnable()) continue; + if (rp->project->non_cpu_intensive) continue; + if (rp->already_selected) continue; + if (first || rp->report_deadline < earliest_deadline) { first = false; - best_project = r->project; - best_result = r; - earliest_deadline = r->report_deadline; + best_project = rp->project; + best_result = rp; + earliest_deadline = rp->report_deadline; } } if (!best_result) return false; diff --git a/client/cs_scheduler.C b/client/cs_scheduler.C index 21bd5b123f..0743a579bf 100644 --- a/client/cs_scheduler.C +++ b/client/cs_scheduler.C @@ -146,7 +146,6 @@ PROJECT* CLIENT_STATE::next_project_need_work() { PROJECT *p, *p_prospect = NULL; double work_on_prospect=0; unsigned int i; - bool cpu_idle = no_work_for_a_cpu(); for (i=0; iproject->non_cpu_intensive ) continue; - if (rp->computing_done()) continue; - if (rp->suspended_via_gui) continue; - if (rp->project->suspended_via_gui) continue; + if (!rp->runnable_soon()) continue; count++; } return ncpus > count; diff --git a/client/scheduler_op.C b/client/scheduler_op.C index 627cb7c82e..ba906dd2ed 100644 --- a/client/scheduler_op.C +++ b/client/scheduler_op.C @@ -451,11 +451,13 @@ bool SCHEDULER_OP::poll() { // while (1) { url_index++; - if (url_index == cur_proj->scheduler_urls.size()) break; + if (url_index == (int)cur_proj->scheduler_urls.size()) { + break; + } retval = start_rpc(cur_proj); if (!retval) return true; } - if (url_index == cur_proj->scheduler_urls.size()) { + if (url_index == (int) cur_proj->scheduler_urls.size()) { backoff(cur_proj, "No schedulers responded"); scheduler_op_done = true; } diff --git a/lib/msg_log.C b/lib/msg_log.C index 32f6b4fdec..6b329f8add 100644 --- a/lib/msg_log.C +++ b/lib/msg_log.C @@ -75,10 +75,10 @@ MSG_LOG::MSG_LOG(FILE* output_) { void MSG_LOG::enter_level(int diff) { assert (indent_level >= 0); - if (enter_level <= 0 ) enter_level = 0; - if ((enter_level + diff) <= 0) return; - if (enter_level >= 39 ) enter_level = 39; - if ((enter_level + diff) >= 39) return; + if (indent_level <= 0 ) indent_level = 0; + if ((indent_level + diff) <= 0) return; + if (indent_level >= 39 ) indent_level = 39; + if ((indent_level + diff) >= 39) return; spaces[indent_level] = ' '; indent_level += diff*2; diff --git a/lib/network.C b/lib/network.C index 56f8953c78..f194f0c281 100644 --- a/lib/network.C +++ b/lib/network.C @@ -34,7 +34,7 @@ #include "error_numbers.h" #include "network.h" -char* socket_error_str() { +const char* socket_error_str() { static char buf[80]; #ifdef _WIN32 int e = WSAGetLastError(); diff --git a/lib/network.h b/lib/network.h index 69b15bba06..e068c65cb7 100644 --- a/lib/network.h +++ b/lib/network.h @@ -24,7 +24,7 @@ extern int boinc_socket(int& sock); extern int boinc_socket_asynch(int sock, bool asynch); extern void boinc_close_socket(int sock); extern int get_socket_error(int fd); -extern char* socket_error_str(); +extern const char* socket_error_str(); #if defined(_WIN32) typedef int boinc_socklen_t;