always use sigar_kstat_update rather than kstat_chain_update directly

This commit is contained in:
Doug MacEachern 2005-12-09 19:24:40 +00:00
parent 142721a52f
commit fb475be338
3 changed files with 29 additions and 17 deletions

View File

@ -16,7 +16,7 @@ int sigar_get_multi_kstats(sigar_t *sigar,
name += kl->nlen; /* e.g. "hme0" + 3 */ name += kl->nlen; /* e.g. "hme0" + 3 */
dev = atoi(name); dev = atoi(name);
if ((kl->num == 0) || (kstat_chain_update(kc) > 0)) { if ((kl->num == 0) || (sigar_kstat_update(sigar) > 0)) {
while ((ksp = kstat_lookup(kc, kl->name, i, NULL))) { while ((ksp = kstat_lookup(kc, kl->name, i, NULL))) {
if (i+1 > kl->num) { if (i+1 > kl->num) {
kl->num = i+1; kl->num = i+1;
@ -111,6 +111,28 @@ int sigar_get_kstats(sigar_t *sigar)
return SIGAR_OK; return SIGAR_OK;
} }
SIGAR_INLINE kid_t sigar_kstat_update(sigar_t *sigar)
{
kid_t id = kstat_chain_update(sigar->kc);
switch (id) {
case -1:
sigar_log_printf(sigar, SIGAR_LOG_ERROR,
"kstat_chain_update error: %s",
sigar_strerror(sigar, errno));
break;
case 0:
break;
default:
sigar_get_kstats(sigar);
sigar_log(sigar, SIGAR_LOG_DEBUG,
"kstat chain updated");
break;
}
return id;
}
/* /*
* bincompat is not possible with certain kstat data structures between * bincompat is not possible with certain kstat data structures between
* solaris 2.6, 2.7, 2.8, etc. alternative is to use kstat_data_lookup() * solaris 2.6, 2.7, 2.8, etc. alternative is to use kstat_data_lookup()

View File

@ -33,6 +33,8 @@ typedef struct {
int nlen; int nlen;
} kstat_list_t; } kstat_list_t;
SIGAR_INLINE kid_t sigar_kstat_update(sigar_t *sigar);
int sigar_get_kstats(sigar_t *sigar); int sigar_get_kstats(sigar_t *sigar);
int sigar_get_multi_kstats(sigar_t *sigar, int sigar_get_multi_kstats(sigar_t *sigar,

View File

@ -154,20 +154,6 @@ char *sigar_os_error_string(sigar_t *sigar, int err)
} }
} }
static SIGAR_INLINE int sigar_kstat_update(sigar_t *sigar)
{
switch (kstat_chain_update(sigar->kc)) {
case 0:
break;
case -1:
return -1; /* shouldn't happen */
default:
sigar_get_kstats(sigar);
}
return SIGAR_OK;
}
#define KPAGE_SHIFT(v) \ #define KPAGE_SHIFT(v) \
((v) << sigar->pagesize) ((v) << sigar->pagesize)
@ -1368,7 +1354,8 @@ static int get_fs_kstat(sigar_t *sigar,
kstat_t *ksp, *first; kstat_t *ksp, *first;
char *ptr; char *ptr;
kstat_chain_update(sigar->kc); sigar_kstat_update(sigar);
first = ksp = first = ksp =
kstat_lookup(sigar->kc, fsk->module, fsk->instance, NULL); kstat_lookup(sigar->kc, fsk->module, fsk->instance, NULL);
@ -1980,7 +1967,8 @@ 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;
kstat_chain_update(kc); sigar_kstat_update(sigar);
strncpy(dev, name, sizeof(dev)-1); strncpy(dev, name, sizeof(dev)-1);
dev[sizeof(dev)-1] = '\0'; dev[sizeof(dev)-1] = '\0';