Implement stopHostConsole

stopHostConsole would remove the host console fd from the event loop.

Change-Id: Ie642e7022e7195a7f0f5ec2af38f890cb8fdf524
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/sd_event_loop.cpp b/sd_event_loop.cpp
index 2fc8551..d30aafe 100644
--- a/sd_event_loop.cpp
+++ b/sd_event_loop.cpp
@@ -197,4 +197,24 @@
     source=nullptr;
 }
 
+void EventLoop::stopHostConsole()
+{
+    int rc = 0;
+
+    if (hostConsole.get())
+    {
+        // Disable the host console payload
+        rc = sd_event_source_set_enabled(hostConsole.get(), SD_EVENT_OFF);
+        if (rc < 0)
+        {
+            log<level::ERR>("Failed to disable the host console socket",
+                    entry("RC=%d", rc));
+            hostConsole.reset();
+            throw std::runtime_error("Failed to disable socket descriptor");
+        }
+
+        hostConsole.reset();
+    }
+}
+
 } // namespace eventloop