From b85eea0ff9cc857484da703a54021707f2e3ce19 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Tue, 10 Aug 2004 21:51:13 +0000 Subject: [PATCH] workaround issue seen on occasion w/ 2003 server in vmware. for reasons unknown, the process perf object sometimes comes back with the counter titles but no instances. this would crash the agent. --- src/os/win32/win32_sigar.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index f75dc9aa..3c9e9fe9 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -443,8 +443,6 @@ SIGAR_DECLARE(int) sigar_proc_list_get(sigar_t *sigar, return err; } - sigar_proc_list_create(proclist); - /* * note we assume here: * block->NumObjectTypes == 1 @@ -466,6 +464,15 @@ SIGAR_DECLARE(int) sigar_proc_list_get(sigar_t *sigar, } } + /* XXX dont know why this happens, have only + * seen it using 2003 server within vmware. + */ + if (object->NumInstances < 1) { + return ENOENT; + } + + sigar_proc_list_create(proclist); + for (i=0, inst = PdhFirstInstance(object); iNumInstances; i++, inst = PdhNextInstance(inst)) @@ -675,9 +682,6 @@ static int get_proc_info(sigar_t *sigar, sigar_pid_t pid) } } - pinfo->pid = pid; - pinfo->mtime = timenow; - memset(&perf_offsets, 0, sizeof(perf_offsets)); object = get_process_object(sigar, &err); @@ -686,6 +690,16 @@ static int get_proc_info(sigar_t *sigar, sigar_pid_t pid) return err; } + /* XXX dont know why this happens, have only + * seen it using 2003 server within vmware. + */ + if (object->NumInstances < 1) { + return ENOENT; + } + + pinfo->pid = pid; + pinfo->mtime = timenow; + /* * note we assume here: * block->NumObjectTypes == 1