Enable OCC error monitoring
Fixes openbmc/openbmc#2165
Change-Id: I93f317a32c910f279003fa0fce6ae2d597f90312
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
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 @@
// 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();
+ // 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;
+ }
}
// Callback handler when there is an activity on the FD