From 6b39b0f3d108dfc0a89df88b8362d8ac14d94b96 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 4 Jul 2004 18:55:31 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=3782 --- checkin_notes | 15 ++++++++++++++- sched/handle_request.C | 32 +++++++++++++++++++++++++++----- sched/main.C | 6 ++++-- sched/sched_shmem.C | 10 ++++++++++ sched/sched_shmem.h | 1 + 5 files changed, 56 insertions(+), 8 deletions(-) diff --git a/checkin_notes b/checkin_notes index 5da28ec4be..cf51485911 100755 --- a/checkin_notes +++ b/checkin_notes @@ -14598,4 +14598,17 @@ Rom 3 July 2004 db/ boinc_db.C - \ No newline at end of file +David 4 July 2004 + - scheduler: if client is requesting work, + and client is not returning results, + and there's no work, + then send "No work available" message + and return without opening DB + - scheduler: if client has wrong major version, + and is not returning results, + return without opening DB + + sched/ + handle_request.C + main.C + sched_shmem.C,h diff --git a/sched/handle_request.C b/sched/handle_request.C index 1dca9c1e3b..13c5e110fd 100644 --- a/sched/handle_request.C +++ b/sched/handle_request.C @@ -624,13 +624,35 @@ void process_request( struct tm *rpc_time_tm; int last_rpc_dayofyear; int current_rpc_dayofyear; - bool ok_to_send = true; + bool ok_to_send_work = true; // if different major version of BOINC, just send a message // if (wrong_major_version(sreq, reply)) { - ok_to_send = false; + ok_to_send_work = false; + + // if no results, return without accessing DB + // + if (sreq.results.size() == 0) { + return; + } + } + + // if there's no work, and client isn't returning results, + // and client is requesting work, return without accessing DB + // + if ((sreq.work_req_seconds > 0) + && ss.no_work() + && (sreq.results.size() == 0) + ) { + strcat(reply.message, "No work available"); + strcpy(reply.message_priority, "low"); + reply.request_delay = 3600; + log_messages.printf( + SCHED_MSG_LOG::NORMAL, "No work - skipping DB access\n" + ); + return; } // now open the database @@ -694,11 +716,11 @@ void process_request( // if last RPC was within config.min_sendwork_interval, don't send work // - if (ok_to_send && sreq.work_req_seconds > 0) { + if (ok_to_send_work && sreq.work_req_seconds > 0) { if (config.min_sendwork_interval) { double diff = dtime() - last_rpc_time; if (diff < config.min_sendwork_interval) { - ok_to_send = false; + ok_to_send_work = false; log_messages.printf( SCHED_MSG_LOG::NORMAL, "Not sending work - last RPC too recent: %f\n", diff @@ -710,7 +732,7 @@ void process_request( reply.request_delay = config.min_sendwork_interval; } } - if (ok_to_send) { + if (ok_to_send_work) { send_work(sreq, reply, *platform, ss); } } diff --git a/sched/main.C b/sched/main.C index b60814b187..e867b87a23 100644 --- a/sched/main.C +++ b/sched/main.C @@ -80,9 +80,9 @@ void send_message(char* msg, int delay) { ); } +static bool db_opened=false; int open_database() { int retval; - static bool db_opened=false; if (db_opened) return 0; @@ -226,5 +226,7 @@ done: continue; } #endif - boinc_db.close(); + if (db_opened) { + boinc_db.close(); + } } diff --git a/sched/sched_shmem.C b/sched/sched_shmem.C index 74a92514b9..5e7cabb8f2 100644 --- a/sched/sched_shmem.C +++ b/sched/sched_shmem.C @@ -156,3 +156,13 @@ APP_VERSION* SCHED_SHMEM::lookup_app_version( return best_avp; } + +bool SCHED_SHMEM::no_work() { + int i; + + if (!ready) return false; + for (i=0; i