From: darpan.ka Date: Wed, 17 Apr 2013 05:02:46 +0000 (+0530) Subject: Calling g_io_channel_set_close_on_unref() after crating channel X-Git-Tag: accepted/tizen_2.1/20130425.034849~47^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4f26ef4968986cabbe26e07ee47135934330dc45;p=framework%2Fosp%2Fappfw.git Calling g_io_channel_set_close_on_unref() after crating channel Change-Id: I9ab9ca6eea5a5a3bbf7670252c8b8e7c8352e05e Signed-off-by: darpan.ka --- diff --git a/src/base/runtime/FBaseRt_EventDispatcher.cpp b/src/base/runtime/FBaseRt_EventDispatcher.cpp index db5bec8..9137277 100644 --- a/src/base/runtime/FBaseRt_EventDispatcher.cpp +++ b/src/base/runtime/FBaseRt_EventDispatcher.cpp @@ -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; } diff --git a/src/base/runtime/FBaseRt_EventManager.cpp b/src/base/runtime/FBaseRt_EventManager.cpp index 5f49426..4b1a81d 100644 --- a/src/base/runtime/FBaseRt_EventManager.cpp +++ b/src/base/runtime/FBaseRt_EventManager.cpp @@ -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) diff --git a/src/base/runtime/FBaseRt_MainLoop.cpp b/src/base/runtime/FBaseRt_MainLoop.cpp index 4133af8..7b9fcf6 100644 --- a/src/base/runtime/FBaseRt_MainLoop.cpp +++ b/src/base/runtime/FBaseRt_MainLoop.cpp @@ -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; }