diff options
author | Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com> | 2017-08-18 18:29:41 +0530 |
---|---|---|
committer | Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com> | 2017-08-23 18:56:37 +0530 |
commit | 2dc9b1a24f753270eae01be8b71c0c89a3c669cc (patch) | |
tree | 8a9186650d1402515637a8ee4e1bc6b797dd1a0b /occ_errors.cpp | |
parent | 715595b64ead477ceae235208a290808234cdcf0 (diff) | |
download | openpower-occ-control-2dc9b1a24f753270eae01be8b71c0c89a3c669cc.tar.gz openpower-occ-control-2dc9b1a24f753270eae01be8b71c0c89a3c669cc.zip |
Enable OCC error monitoring
Fixes openbmc/openbmc#2165
Change-Id: I93f317a32c910f279003fa0fce6ae2d597f90312
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
Diffstat (limited to 'occ_errors.cpp')
-rw-r--r-- | occ_errors.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
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 |