From 2dc9b1a24f753270eae01be8b71c0c89a3c669cc Mon Sep 17 00:00:00 2001 From: Vishwanatha Subbanna Date: Fri, 18 Aug 2017 18:29:41 +0530 Subject: Enable OCC error monitoring Fixes openbmc/openbmc#2165 Change-Id: I93f317a32c910f279003fa0fce6ae2d597f90312 Signed-off-by: Vishwanatha Subbanna --- occ_errors.cpp | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'occ_errors.cpp') diff --git a/occ_errors.cpp b/occ_errors.cpp index f2da49f..fe81f17 100644 --- a/occ_errors.cpp +++ b/occ_errors.cpp @@ -56,25 +56,37 @@ void Error::registerCallBack() // Starts to watch for errors void Error::addWatch() { - // Open the file - openFile(); + if (!watching) + { + // Open the file + openFile(); + + // register the callback handler + registerCallBack(); - // register the callback handler - registerCallBack(); + // Set we are watching the error + watching = true; + } } // Stops watching for errors void Error::removeWatch() { - // Close the file - if (fd >= 0) + if (watching) { - close(fd); + // Close the file + if (fd >= 0) + { + close(fd); + } + + // Reduce the reference count. Since there is only one instances + // of add_io, this will result empty loop + eventSource.reset(); + + // We are no more watching the error + watching = false; } - - // Reduce the reference count. Since there is only one instances - // of add_io, this will result empty loop - eventSource.reset(); } // Callback handler when there is an activity on the FD -- cgit v1.2.1