check return value of kstat_chain_update

This commit is contained in:
Doug MacEachern 2005-12-09 21:03:14 +00:00
parent 9c0467932e
commit 225e8e4da4
2 changed files with 27 additions and 7 deletions

View File

@ -14,6 +14,10 @@ int sigar_get_multi_kstats(sigar_t *sigar,
int dev; int dev;
kid_t id = sigar_kstat_update(sigar); kid_t id = sigar_kstat_update(sigar);
if (id == -1) {
return errno;
}
name += kl->nlen; /* e.g. "hme0" + 3 */ name += kl->nlen; /* e.g. "hme0" + 3 */
dev = atoi(name); dev = atoi(name);
@ -130,6 +134,7 @@ SIGAR_INLINE kid_t sigar_kstat_update(sigar_t *sigar)
sigar_strerror(sigar, errno)); sigar_strerror(sigar, errno));
break; break;
case 0: case 0:
/* up-to-date */
break; break;
default: default:
sigar_get_kstats(sigar); sigar_get_kstats(sigar);

View File

@ -169,7 +169,9 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
sigar_mem_calc_ram(sigar, mem); sigar_mem_calc_ram(sigar, mem);
sigar_kstat_update(sigar); if (sigar_kstat_update(sigar) == -1) {
return errno;
}
if ((ksp = sigar->ks.syspages) && kstat_read(kc, ksp, NULL) >= 0) { if ((ksp = sigar->ks.syspages) && kstat_read(kc, ksp, NULL) >= 0) {
sigar_koffsets_init_syspages(sigar, ksp); sigar_koffsets_init_syspages(sigar, ksp);
@ -200,7 +202,9 @@ int sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap)
kstat_t *ksp; kstat_t *ksp;
vminfo_t vminfo; vminfo_t vminfo;
sigar_kstat_update(sigar); if (sigar_kstat_update(sigar) == -1) {
return errno;
}
if ((ksp = sigar->ks.vminfo) && kstat_read(kc, ksp, &vminfo) >= 0) { if ((ksp = sigar->ks.vminfo) && kstat_read(kc, ksp, &vminfo) >= 0) {
/* XXX: need some adjustments here */ /* XXX: need some adjustments here */
@ -308,7 +312,10 @@ int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist)
kstat_t *ksp; kstat_t *ksp;
ulong cpuinfo[CPU_STATES]; ulong cpuinfo[CPU_STATES];
unsigned int i; unsigned int i;
sigar_kstat_update(sigar);
if (sigar_kstat_update(sigar) == -1) {
return errno;
}
if (cpulist == &sigar->cpulist) { if (cpulist == &sigar->cpulist) {
if (sigar->cpulist.size == 0) { if (sigar->cpulist.size == 0) {
@ -409,7 +416,9 @@ int sigar_loadavg_get(sigar_t *sigar,
kstat_t *ksp; kstat_t *ksp;
int i; int i;
sigar_kstat_update(sigar); if (sigar_kstat_update(sigar) == -1) {
return errno;
}
if (!(ksp = sigar->ks.system)) { if (!(ksp = sigar->ks.system)) {
return -1; return -1;
@ -1367,7 +1376,9 @@ static int get_fs_kstat(sigar_t *sigar,
kstat_t *ksp, *first; kstat_t *ksp, *first;
char *ptr; char *ptr;
sigar_kstat_update(sigar); if (sigar_kstat_update(sigar) == -1) {
return errno;
}
first = ksp = first = ksp =
kstat_lookup(sigar->kc, fsk->module, fsk->instance, NULL); kstat_lookup(sigar->kc, fsk->module, fsk->instance, NULL);
@ -1451,7 +1462,9 @@ int sigar_cpu_info_list_get(sigar_t *sigar,
unsigned int i; unsigned int i;
int status = SIGAR_OK; int status = SIGAR_OK;
sigar_kstat_update(sigar); /* for sigar->ncpu */ if (sigar_kstat_update(sigar) == -1) { /* for sigar->ncpu */
return errno;
}
/* /*
* stats we care about will be the same for each * stats we care about will be the same for each
@ -1980,7 +1993,9 @@ static int sigar_net_ifstat_get_any(sigar_t *sigar, const char *name,
char dev[64], *ptr=dev; char dev[64], *ptr=dev;
int num; int num;
sigar_kstat_update(sigar); if (sigar_kstat_update(sigar) == -1) {
return errno;
}
strncpy(dev, name, sizeof(dev)-1); strncpy(dev, name, sizeof(dev)-1);
dev[sizeof(dev)-1] = '\0'; dev[sizeof(dev)-1] = '\0';