diff options
author | Vernon Mauery <vernon.mauery@linux.intel.com> | 2018-05-10 16:19:16 -0700 |
---|---|---|
committer | Gunnar Mills <gmills@us.ibm.com> | 2018-05-23 20:35:20 +0000 |
commit | 8ff0ee5419a304297889e78e4d30357cef77c4ce (patch) | |
tree | af44daade5c3d3a3f222570a5e2361e1ff3c3ff2 | |
parent | b6aadecd483ebfb56cef9a1979e6a0e9b6f36262 (diff) | |
download | phosphor-bmc-code-mgmt-8ff0ee5419a304297889e78e4d30357cef77c4ce.tar.gz phosphor-bmc-code-mgmt-8ff0ee5419a304297889e78e4d30357cef77c4ce.zip |
Always call close on fd if file has been opened
The previous logic only called close if the file had been opened AND
there was a valid inotify watch handle. Even if there is not a watch
handle, the file should be closed.
Change-Id: I0bfb3a0fac88d5b648790c4e60755e01af6f5bd7
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
-rw-r--r-- | watch.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -60,9 +60,12 @@ Watch::Watch(sd_event* loop, std::function<int(std::string&)> imageCallback) : Watch::~Watch() { - if ((-1 != fd) && (-1 != wd)) + if (-1 != fd) { - inotify_rm_watch(fd, wd); + if (-1 != wd) + { + inotify_rm_watch(fd, wd); + } close(fd); } } |