From 1e106d6fd7189eede43690c4e554686c33e2e416 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 13 Jun 2013 20:50:21 -0700 Subject: [PATCH] client: fix bug that sometimes prevented work fetch when CPU throttling in use --- client/cs_scheduler.cpp | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/client/cs_scheduler.cpp b/client/cs_scheduler.cpp index ace76911fe..94caaf9b32 100644 --- a/client/cs_scheduler.cpp +++ b/client/cs_scheduler.cpp @@ -484,26 +484,32 @@ bool CLIENT_STATE::scheduler_rpc_poll() { return true; } - // check if we should fetch work. + // check if we should fetch work (do this last) // - if (!tasks_suspended - && !(config.fetch_minimal_work && had_or_requested_work) - ) { + switch (suspend_reason) { + case 0: + case SUSPEND_REASON_CPU_THROTTLE: + break; + default: + return false; + } + if (config.fetch_minimal_work && had_or_requested_work) { + return false; + } - p = work_fetch.choose_project(); - if (p) { - if (actively_uploading(p)) { - if (log_flags.work_fetch_debug) { - msg_printf(p, MSG_INFO, - "[work_fetch] deferring work fetch; upload active" - ); - } - return false; + p = work_fetch.choose_project(); + if (p) { + if (actively_uploading(p)) { + if (log_flags.work_fetch_debug) { + msg_printf(p, MSG_INFO, + "[work_fetch] deferring work fetch; upload active" + ); } - scheduler_op->init_op_project(p, RPC_REASON_NEED_WORK); - return true; + return false; } + scheduler_op->init_op_project(p, RPC_REASON_NEED_WORK); + return true; } return false; }