always open_mib O_RDONLY.

add some missing close_mib calls if error happens.
This commit is contained in:
Doug MacEachern 2005-05-12 16:03:02 +00:00
parent ff280a9b25
commit b16244a3ad
1 changed files with 4 additions and 2 deletions

View File

@ -677,7 +677,7 @@ int sigar_net_route_list_get(sigar_t *sigar,
mib_ipRouteEnt *routes; mib_ipRouteEnt *routes;
sigar_net_route_t *route; sigar_net_route_t *route;
if ((fd = open_mib("/dev/ip", O_RDWR, 0, 0)) < 0) { if ((fd = open_mib("/dev/ip", O_RDONLY, 0, 0)) < 0) {
return errno; return errno;
} }
@ -687,6 +687,7 @@ int sigar_net_route_list_get(sigar_t *sigar,
parms.len = &len; parms.len = &len;
if (get_mib_info(fd, &parms) < 0) { if (get_mib_info(fd, &parms) < 0) {
close_mib(fd);
return errno; return errno;
} }
@ -734,7 +735,7 @@ static int get_mib_ifstat(sigar_t *sigar,
nmapi_phystat *stat; nmapi_phystat *stat;
struct nmparms parms; struct nmparms parms;
if ((fd = open_mib("/dev/ip", O_RDWR, 0, 0)) < 0) { if ((fd = open_mib("/dev/ip", O_RDONLY, 0, 0)) < 0) {
return errno; return errno;
} }
@ -744,6 +745,7 @@ static int get_mib_ifstat(sigar_t *sigar,
parms.len = &len; parms.len = &len;
if (get_mib_info(fd, &parms) < 0) { if (get_mib_info(fd, &parms) < 0) {
close_mib(fd);
return errno; return errno;
} }