source/*: Make updating callbacks possible

Sometimes callers want to be able to update the callback used when the
source is acted upon. This is needed for updating references stored in
the callback.

Tested:
    Run through the unit test suite.

Change-Id: I78bda32569287964bfc9d49501869d3a2b497f3d
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/source/child.cpp b/test/source/child.cpp
index e1e1322..ab173b1 100644
--- a/test/source/child.cpp
+++ b/test/source/child.cpp
@@ -91,6 +91,10 @@
     EXPECT_EQ(1, completions);
     EXPECT_EQ(expected_si, return_si);
 
+    child.set_callback(std::bind([]() {}));
+    EXPECT_EQ(0, handler(nullptr, expected_si, &child));
+    EXPECT_EQ(1, completions);
+
     expect_destruct();
 }
 
diff --git a/test/source/event.cpp b/test/source/event.cpp
index 90edaec..e4d7b2a 100644
--- a/test/source/event.cpp
+++ b/test/source/event.cpp
@@ -83,6 +83,10 @@
     EXPECT_EQ(0, handler(nullptr, &defer));
     EXPECT_EQ(1, completions);
 
+    defer.set_callback(std::bind([]() {}));
+    EXPECT_EQ(0, handler(nullptr, &defer));
+    EXPECT_EQ(1, completions);
+
     expect_destruct();
 }
 
diff --git a/test/source/io.cpp b/test/source/io.cpp
index b680be7..89506b1 100644
--- a/test/source/io.cpp
+++ b/test/source/io.cpp
@@ -92,6 +92,10 @@
     EXPECT_EQ(5, return_fd);
     EXPECT_EQ(EPOLLIN, return_revents);
 
+    io.set_callback(std::bind([]() {}));
+    EXPECT_EQ(0, handler(nullptr, 5, EPOLLIN, &io));
+    EXPECT_EQ(1, completions);
+
     expect_destruct();
 }
 
diff --git a/test/source/signal.cpp b/test/source/signal.cpp
index c99aa6b..d3b53a7 100644
--- a/test/source/signal.cpp
+++ b/test/source/signal.cpp
@@ -92,6 +92,10 @@
     EXPECT_EQ(1, completions);
     EXPECT_EQ(expected_si, return_si);
 
+    signal.set_callback(std::bind([]() {}));
+    EXPECT_EQ(0, handler(nullptr, expected_si, &signal));
+    EXPECT_EQ(1, completions);
+
     expect_destruct();
 }
 
diff --git a/test/source/time.cpp b/test/source/time.cpp
index aa25da0..96a920e 100644
--- a/test/source/time.cpp
+++ b/test/source/time.cpp
@@ -90,6 +90,11 @@
     EXPECT_EQ(Time<id>::TimePoint(std::chrono::microseconds(2000100)),
               saved_time);
 
+    time.set_callback(std::bind([]() {}));
+    EXPECT_EQ(0, handler(nullptr, 0, userdata));
+    EXPECT_EQ(Time<id>::TimePoint(std::chrono::microseconds(2000100)),
+              saved_time);
+
     expect_time_destroy(expected_event, expected_source);
 }