Calling g_io_channel_set_close_on_unref() after crating channel
authordarpan.ka <darpan.ka@samsung.com>
Wed, 17 Apr 2013 05:02:46 +0000 (10:32 +0530)
committerdarpan.ka <darpan.ka@samsung.com>
Wed, 17 Apr 2013 05:17:38 +0000 (10:47 +0530)
Change-Id: I9ab9ca6eea5a5a3bbf7670252c8b8e7c8352e05e
Signed-off-by: darpan.ka <darpan.ka@samsung.com>
src/base/runtime/FBaseRt_EventDispatcher.cpp
src/base/runtime/FBaseRt_EventManager.cpp
src/base/runtime/FBaseRt_MainLoop.cpp

index db5bec8..9137277 100644 (file)
@@ -54,8 +54,8 @@ _EventDispatcher::~_EventDispatcher(void)
 {
        if (__pEventFdSource)
        {
-               g_source_destroy(__pEventFdSource);
                g_source_unref(__pEventFdSource);
+               g_source_destroy(__pEventFdSource);
                __pEventFdSource = null;
        }
 
@@ -90,6 +90,9 @@ _EventDispatcher::Construct(GMainContext* pGMainContext)
        g_io_channel_set_encoding(__pEventFdIo, null, &pGError);
        g_io_channel_set_flags(__pEventFdIo, G_IO_FLAG_NONBLOCK, &pGError);
 
+       g_io_channel_set_close_on_unref(__pEventFdIo, TRUE);
+       eventFd = -1;
+
        __pEventFdSource = g_io_create_watch(__pEventFdIo, G_IO_IN);
        SysTryCatch(NID_BASE_RT, __pEventFdSource != null, r = E_SYSTEM, E_SYSTEM,
                           "[E_SYSTEM] Failed to create a gsource for a channel.");
@@ -117,6 +120,7 @@ CATCH:
        if (__pEventFdSource)
        {
                g_source_unref(__pEventFdSource);
+               g_source_destroy(__pEventFdSource);
                __pEventFdSource = null;
        }
 
@@ -126,6 +130,11 @@ CATCH:
                __pEventFdIo = null;
        }
 
+       if (eventFd != -1)
+       {
+               close(eventFd);
+       }
+
        return r;
 }
 
index 5f49426..4b1a81d 100644 (file)
@@ -95,8 +95,8 @@ _EventManager::~_EventManager(void)
 
        if (__pSource)
        {
-               g_source_destroy(__pSource);
                g_source_unref(__pSource);
+               g_source_destroy(__pSource);
        }
 
        if (__pChannel)
@@ -157,8 +157,8 @@ CATCH:
 
        if (pSource)
        {
-               g_source_destroy(pSource);
                g_source_unref(pSource);
+               g_source_destroy(pSource);
        }
 
        if (pChannel)
index 4133af8..7b9fcf6 100644 (file)
@@ -85,6 +85,7 @@ _MainLoop::~_MainLoop(void)
        if (__pSource)
        {
                g_source_unref(__pSource);
+               g_source_destroy(__pSource);
                __pSource = null;
        }
 
@@ -114,6 +115,9 @@ _MainLoop::Construct(GMainLoop* pGmainLoop, GMainContext* pGmainContext)
        g_io_channel_set_encoding(__pChannel, null, &pGError);
        g_io_channel_set_flags(__pChannel, G_IO_FLAG_NONBLOCK, &pGError);
 
+       g_io_channel_set_close_on_unref(__pChannel, TRUE);
+       eventFd = -1;
+
        __pSource = g_io_create_watch(__pChannel, G_IO_IN);
        SysTryCatch(NID_BASE_RT, __pSource != null, r = E_SYSTEM, E_SYSTEM,
                           "[E_SYSTEM] Failed to create a gsource for a channel.");
@@ -143,6 +147,7 @@ CATCH:
        if (__pSource)
        {
                g_source_unref(__pSource);
+               g_source_destroy(__pSource);
                __pSource = null;
        }
 
@@ -152,6 +157,10 @@ CATCH:
                __pChannel = null;
        }
 
+       if (eventFd != -1)
+       {
+               close(eventFd);
+       }
        return r;
 }