Utils/Exception: Allow to disable ErrnoExceptions via SENF_NO_ERRNOEXC
[senf.git] / PPI / IOEvent.cc
index 2010b6b..e32b884 100644 (file)
@@ -41,7 +41,7 @@
 
 prefix_ void senf::ppi::IOEvent::v_enable()
 {
-    Scheduler::instance().add(fd_, boost::bind(&IOEvent::cb,this,_1,_2), 
+    Scheduler::instance().add(fd_, boost::bind(&IOEvent::cb,this,_1), 
                               Scheduler::EventId(events_));
 }
 
@@ -50,10 +50,20 @@ prefix_ void senf::ppi::IOEvent::v_disable()
     Scheduler::instance().remove(fd_, Scheduler::EventId(events_));
 }
 
-prefix_ void senf::ppi::IOEvent::cb(int, Scheduler::EventId event)
+prefix_ void senf::ppi::IOEvent::cb(Scheduler::EventId event)
 {
-    IOEventInfo info = { event };
-    callback(info);
+    if ((event & ~events_) != 0) {
+        if (event & Err)
+            throw ErrorException();
+        else if (event & Hup)
+            throw HangupException();
+        else
+            // This cannot happen.
+            BOOST_ASSERT(false);
+    } else {
+        IOEventInfo info = { event };
+        callback(info);
+    }
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////