From cffbef137293e4eebf9df5952e569a4bd96386ef Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 18 Sep 2009 17:11:15 +0000 Subject: [PATCH] - client: in choosing coproc jobs to run (FIFO) give priority to whether job is already running. This addresses a bug where several jobs are returned by sched RPC, and one with a lexicographically greater name happens to finish downloading first. svn path=/trunk/boinc/; revision=19092 --- checkin_notes | 10 ++++++++++ client/cpu_sched.cpp | 12 +++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/checkin_notes b/checkin_notes index 8deff08a96..1deef26b58 100644 --- a/checkin_notes +++ b/checkin_notes @@ -7856,3 +7856,13 @@ David 18 Sept 2009 sysmon_win.cpp lib/ proxy_info.cpp,h + +David 18 Sept 2009 + - client: in choosing coproc jobs to run (FIFO) give priority + to whether job is already running. + This addresses a bug where several jobs are returned by sched RPC, + and one with a lexicographically greater name + happens to finish downloading first. + + client/ + cpu_sched.cpp diff --git a/client/cpu_sched.cpp b/client/cpu_sched.cpp index 2972aeba71..9095652c46 100644 --- a/client/cpu_sched.cpp +++ b/client/cpu_sched.cpp @@ -306,7 +306,11 @@ RESULT* CLIENT_STATE::largest_debt_project_best_result() { return rp; } -// return coproc jobs in FIFO order +// Return coproc jobs in FIFO order +// Give priority to already-started jobs because of the following scenario: +// - client gets several jobs in a sched reply and starts download files +// - a job with a later name happens to finish downloading first, and starts +// - a job with an earlier name finishes downloading and preempts // RESULT* first_coproc_result() { unsigned int i; @@ -321,10 +325,12 @@ RESULT* first_coproc_result() { best = rp; continue; } - if (rp->received_time < best->received_time) { + if (!rp->not_started() && best->not_started()) { + best = rp; + } else if (rp->received_time < best->received_time) { best = rp; } else if (rp->received_time == best->received_time) { - // make it deterministic + // make it deterministic by looking at name // if (strcmp(rp->name, best->name)) { best = rp;