using namespace std;
static GMainLoop *mainLoop = NULL;
-static gboolean started = FALSE;
static conv::DbusServer *dbusHandle = NULL;
static conv::DiscoveryManager *discoveryMgr = NULL;
static conv::ConnectionManager *connectionMgr = NULL;
{
int result;
- if (started) {
- _D("flowd is started already");
- return;
- }
-
- mainLoop = g_main_loop_new(NULL, FALSE);
-
_I("Init Discovery Manager");
discoveryMgr = new(std::nothrow) conv::DiscoveryManager();
IF_FAIL_CATCH_TAG(discoveryMgr, _E, "Memory allocation failed");
result = dbusHandle->init();
IF_FAIL_CATCH_TAG(result == true, _E, "Initialization Failed");
- _I("Start main loop");
- started = TRUE;
+ mainLoop = g_main_loop_new(NULL, FALSE);
+ _I("Start main loop");
g_main_loop_run(mainLoop);
- return;
-
CATCH:
- _E(RED("Launching Failed"));
- if (mainLoop) {
- g_main_loop_quit(mainLoop);
- mainLoop = NULL;
- }
+ return;
}
void conv::release()
if (requestMgr)
requestMgr->release();
- g_main_loop_unref(mainLoop);
+ if (mainLoop) {
+ g_main_loop_unref(mainLoop);
+ }
delete discoveryMgr;
delete connectionMgr;
delete clientMgr;
delete requestMgr;
delete serviceMgr;
- started = FALSE;
}
-
void conv::sendRequest(Request* requestObj)
{
_D("send_request requestObj:%x request_mg:%x", requestObj, requestMgr);
{
_I("SIGNAL %d received", signo);
+ if (mainLoop == NULL)
+ return;
+
// Stop the main loop
- if (mainLoop) {
+ if (g_main_loop_is_running(mainLoop)) {
g_main_loop_quit(mainLoop);
- mainLoop = NULL;
}
}
conv::initialize();
conv::release();
+ _I(RED("Quit main loop"));
+
return EXIT_SUCCESS;
}