From 4a029f2f401a6738c6daa31ad3098eb7f0915c7c Mon Sep 17 00:00:00 2001 From: Adriana Kobylak Date: Wed, 23 May 2018 12:58:19 -0500 Subject: 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: Id1f6d441129e13c6a48d6156161425082aeba8e8 Signed-off-by: Adriana Kobylak --- log_manager.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/log_manager.cpp b/log_manager.cpp index f808e4b..71858f6 100644 --- a/log_manager.cpp +++ b/log_manager.cpp @@ -438,9 +438,12 @@ void Manager::journalSync() ; } - if ((fd != -1) && (wd != -1)) + if (fd != -1) { - inotify_rm_watch(fd, wd); + if (wd != -1) + { + inotify_rm_watch(fd, wd); + } close(fd); } -- cgit v1.2.1