From 0257e48e2f0e6b849b12740e2675211a5ecd2190 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 1 Nov 2006 22:40:30 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=11439 --- checkin_notes | 9 +++++++++ client/app.C | 11 ++++++++++- lib/procinfo_win.C | 17 +++++++++-------- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/checkin_notes b/checkin_notes index 82836e8494..559256d010 100755 --- a/checkin_notes +++ b/checkin_notes @@ -11964,3 +11964,12 @@ Rom 1 Nov 2006 lib/ gui_rpc_client_ops.C + +David 1 Nov 2006 + - core client: check error returns in Win code to + find app memory usage. + + client/ + app.C + lib/ + procinfo_win.C diff --git a/client/app.C b/client/app.C index 0bafd08f9c..053e39d0e9 100644 --- a/client/app.C +++ b/client/app.C @@ -196,13 +196,22 @@ void ACTIVE_TASK_SET::free_mem() { void ACTIVE_TASK_SET::get_memory_usage() { static double last_mem_time=0; unsigned int i; + int retval; double diff = gstate.now - last_mem_time; if (diff < 10) return; last_mem_time = gstate.now; vector piv; - procinfo_setup(piv); + retval = procinfo_setup(piv); + if (retval) { + if (log_flags.mem_usage_debug) { + msg_printf(0, MSG_ERROR, + "[mem_usage_debug] procinfo_setup() returned %d", retval + ); + } + return; + } for (i=0; itask_state == PROCESS_EXECUTING) { diff --git a/lib/procinfo_win.C b/lib/procinfo_win.C index 500f79c953..0cee0ed590 100644 --- a/lib/procinfo_win.C +++ b/lib/procinfo_win.C @@ -1,3 +1,4 @@ +#include "error_numbers.h" #include "diagnostics_win.h" #include "procinfo.h" @@ -12,7 +13,6 @@ typedef NTSTATUS (WINAPI *tNTQSI)( ); static int get_process_information(PVOID* ppBuffer, PULONG pcbBuffer) { - int retval = 0; NTSTATUS Status = STATUS_INFO_LENGTH_MISMATCH; HANDLE hHeap = GetProcessHeap(); HMODULE hNTDllLib = NULL; @@ -21,10 +21,10 @@ static int get_process_information(PVOID* ppBuffer, PULONG pcbBuffer) { hNTDllLib = GetModuleHandle("ntdll.dll"); pNTQSI = (tNTQSI)GetProcAddress(hNTDllLib, "NtQuerySystemInformation"); - do { + while (1) { *ppBuffer = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, *pcbBuffer); if (ppBuffer == NULL) { - retval = ERROR_NOT_ENOUGH_MEMORY; + return ERR_MALLOC; } Status = pNTQSI( @@ -39,11 +39,12 @@ static int get_process_information(PVOID* ppBuffer, PULONG pcbBuffer) { *pcbBuffer *= 2; } else if (!NT_SUCCESS(Status)) { HeapFree(hHeap, NULL, *ppBuffer); - retval = Status; - } - } while (Status == STATUS_INFO_LENGTH_MISMATCH); - - return retval; + return ERR_GETRUSAGE; + } else { + return 0; + } + } + return 0; // never reached } // Note: the following will work on both NT and XP,