summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2003-12-11 07:46:08 +0000
committerdes <des@FreeBSD.org>2003-12-11 07:46:08 +0000
commitb37897400db991ebb79d0fdd993975c8dcd48cdf (patch)
treed2f42b400eee213dd1a67d9c9e15d1119a1a01a5 /usr.bin
parente87d087aa128bbb0d28656c2a00af58215fd30b0 (diff)
downloadFreeBSD-src-b37897400db991ebb79d0fdd993975c8dcd48cdf.zip
FreeBSD-src-b37897400db991ebb79d0fdd993975c8dcd48cdf.tar.gz
Revert part of revision 1.74 after bde reminded me of a detail I'd
forgotten about how sysctl works. This removes a potential (though not very likely) race that 1.74 introduced.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/vmstat/vmstat.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index 3255e7b..e034911 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -852,10 +852,13 @@ dointr(void)
kread(X_INTRCNT, intrcnt, intrcntlen);
kread(X_INTRNAMES, intrname, inamlen);
} else {
- mysysctl("hw.intrcnt", NULL, &intrcntlen, NULL, 0);
- if ((intrcnt = malloc(intrcntlen)) == NULL)
- err(1, "calloc()");
- mysysctl("hw.intrcnt", intrcnt, &intrcntlen, NULL, 0);
+ for (intrcnt = NULL, intrcntlen = 1024; ; intrcntlen *= 2) {
+ if ((intrcnt = reallocf(intrcnt, intrcntlen)) == NULL)
+ err(1, "reallocf()");
+ if (mysysctl("hw.intrcnt",
+ intrcnt, &intrcntlen, NULL, 0) == 0)
+ break;
+ }
for (intrname = NULL, inamlen = 1024; ; inamlen *= 2) {
if ((intrname = reallocf(intrname, inamlen)) == NULL)
err(1, "reallocf()");
OpenPOWER on IntegriCloud