Create sd_event outside from EventLoop

Presently timer in the provider library needs the sd_event
and sd_event gets created in the startEventLoop.
RegisterCallbackHandlers gets called before the startEventLoop
hence not getting the event.

This commit creates the sd_event outside from the sd_event_loop
and pass the sd_event reference to the startEventLoop function.

Tested: run the fru print in net-ipmid context.

Change-Id: I2b227154ba60e56d7faa6c8000c20a5231c4417c
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/sd_event_loop.cpp b/sd_event_loop.cpp
index 16a5403..3351da7 100644
--- a/sd_event_loop.cpp
+++ b/sd_event_loop.cpp
@@ -171,7 +171,7 @@
     return 0;
 }
 
-int EventLoop::startEventLoop()
+int EventLoop::startEventLoop(sd_event* events)
 {
     int fd = -1;
     int r = 0;
@@ -180,12 +180,7 @@
     sd_event_source* source = nullptr;
     auto bus = ipmid_get_sd_bus_connection();
 
-    r = sd_event_default(&event);
-    if (r < 0)
-    {
-        goto finish;
-    }
-
+    event = events;
     // Attach the bus to sd_event to service user requests
     r = sd_bus_attach_event(bus, event, SD_EVENT_PRIORITY_NORMAL);
     if (r < 0)
@@ -266,7 +261,6 @@
     r = sd_event_loop(event);
 
 finish:
-    event = sd_event_unref(event);
 
     if (fd >= 0)
     {