summaryrefslogtreecommitdiffstats
path: root/occ_errors.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'occ_errors.cpp')
-rw-r--r--occ_errors.cpp34
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
OpenPOWER on IntegriCloud