From e393203ff70ce023bf9c83fcf74584a9a2945e8c Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 29 Dec 2012 11:47:53 -0800 Subject: [PATCH] - API: improve log messages when detect dead client --- api/boinc_api.cpp | 29 +++++++++++++++++++++-------- checkin_notes | 6 ++++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/api/boinc_api.cpp b/api/boinc_api.cpp index a42743ce91..b48ef5dbcf 100644 --- a/api/boinc_api.cpp +++ b/api/boinc_api.cpp @@ -379,28 +379,44 @@ static void handle_heartbeat_msg() { } static bool client_dead() { + bool dead; if (aid.client_pid) { // check every 10 sec // if (interrupt_count%(TIMERS_PER_SEC*10)) return false; #ifdef _WIN32 - // Windows doesn't have waitpid() :-( + // Windows lacks an easy way to check for process existence :-( // DWORD pids[4096], nb; BOOL r = EnumProcesses(pids, sizeof(pids), &nb); if (!r) return false; int n = nb/sizeof(DWORD); + dead = true; for (int i=0; i heartbeat_giveup_count); + dead = (interrupt_count > heartbeat_giveup_count); } + if (dead) { + char buf[256]; + boinc_msg_prefix(buf, sizeof(buf)); + fputs(buf, stderr); // don't use fprintf() here + if (aid.client_pid) { + fputs(" BOINC client no longer exists - exiting\n", stderr); + } else { + fputs(" No heartbeat from client for 30 sec - exiting\n", stderr); + } + return true; + } + return false; } #ifndef _WIN32 @@ -1207,9 +1223,6 @@ static void timer_handler() { // if (in_critical_section==0 && options.check_heartbeat) { if (client_dead()) { - boinc_msg_prefix(buf, sizeof(buf)); - fputs(buf, stderr); // don't use fprintf() here - fputs(" No heartbeat from client for 30 sec - exiting\n", stderr); if (options.direct_process_action) { exit_from_timer_thread(0); } else { diff --git a/checkin_notes b/checkin_notes index 4e9e5e6820..df8cdc5d30 100644 --- a/checkin_notes +++ b/checkin_notes @@ -7966,3 +7966,9 @@ Rom 28 Dec 2012 samples\vboxwrapper\ vbox.cpp + +David 29 Dec 2012 + - API: improve log messages when detect dead client + + api/ + boinc_api.cpp