diff options
author | Adrien Mahieux <adrien.mahieux@gmail.com> | 2020-09-30 19:40:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-30 17:40:25 +0000 |
commit | 884c69d36ddf5d1010d7243bf1251ba5fa709b85 (patch) | |
tree | 4d1be9a4230f00581a0e5bb02b0186c121878d41 /collectors/proc.plugin | |
parent | 2e40a3eace0146a233b52322534e888d669afb68 (diff) |
fix file descriptor leak (#10013)
Diffstat (limited to 'collectors/proc.plugin')
-rw-r--r-- | collectors/proc.plugin/sys_class_infiniband.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/collectors/proc.plugin/sys_class_infiniband.c b/collectors/proc.plugin/sys_class_infiniband.c index 40ba0be494..46f40f2c0e 100644 --- a/collectors/proc.plugin/sys_class_infiniband.c +++ b/collectors/proc.plugin/sys_class_infiniband.c @@ -375,12 +375,12 @@ int do_sys_class_infiniband(int update_every, usec_t dt) // Standard counters are mandatory if (!counters_dir) continue; + closedir(counters_dir); - // Nearly same with hardware counters + // Hardware Counters are optionnal, used later char hwcounters_dirname[FILENAME_MAX + 1]; snprintfz( hwcounters_dirname, FILENAME_MAX, "%s/%s/%s", ports_dirname, port_dent->d_name, "hw_counters"); - DIR *hwcounters_dir = opendir(hwcounters_dirname); // Get new or existing ibport struct ibport *p = get_ibport(dev_dent->d_name, port_dent->d_name); @@ -412,6 +412,7 @@ int do_sys_class_infiniband(int update_every, usec_t dt) FOREACH_COUNTER(GEN_DO_COUNTER_NAME, p) // Check HW Counters vendor dependent + DIR *hwcounters_dir = opendir(hwcounters_dirname); if (hwcounters_dir) { // By default set standard p->do_hwpackets = config_get_boolean_ondemand(buffer, "hwpackets", do_hwpackets); @@ -442,6 +443,7 @@ int do_sys_class_infiniband(int update_every, usec_t dt) p->do_hwpackets = CONFIG_BOOLEAN_NO; p->do_hwerrors = CONFIG_BOOLEAN_NO; } + closedir(hwcounters_dir); } } |