Unref GSources after attaching them to prevent memory leaks 88/121288/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Mon, 27 Mar 2017 11:58:14 +0000 (20:58 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Mon, 27 Mar 2017 11:58:14 +0000 (20:58 +0900)
Change-Id: Ie1c8b46f48380781bbe43296eb620c4dcd7029e5
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
src/server/ServiceBase.cpp
src/server/Timer.cpp

index e769944..51455d5 100644 (file)
@@ -77,6 +77,7 @@ void ServiceBase::stop()
                // In this way, already scheduled idle tasks are not discarded.
                g_source_set_callback(gSrc, __stopMainLoop, this, NULL);
                g_source_attach(gSrc, __mainContext);
+               g_source_unref(gSrc);
        } else {
                __stopMainLoop(this);
        }
@@ -131,6 +132,7 @@ void ServiceBase::notifyUserNew()
 
        g_source_set_callback(gSrc, __onUserActivated, this, NULL);
        g_source_attach(gSrc, __mainContext);
+       g_source_unref(gSrc);
 }
 
 void ServiceBase::notifyUserRemoved()
@@ -143,6 +145,7 @@ void ServiceBase::notifyUserRemoved()
 
        g_source_set_callback(gSrc, __onUserDeactivated, this, NULL);
        g_source_attach(gSrc, __mainContext);
+       g_source_unref(gSrc);
 }
 
 gboolean ServiceBase::__onUserActivated(gpointer data)
index aa20f79..fa97699 100644 (file)
@@ -157,6 +157,7 @@ unsigned int Timer::addIdle(ITimerListener* listener)
 
        g_source_set_callback(gSrc, __onGSourceExpired, info, NULL);
        g_source_attach(gSrc, __context);
+       g_source_unref(gSrc);
 
        return info->timerId;
 }
@@ -188,6 +189,7 @@ unsigned int Timer::addTimeout(unsigned int intervalMs, ITimerListener* listener
 
        g_source_set_callback(gSrc, __onGSourceExpired, info, NULL);
        g_source_attach(gSrc, __context);
+       g_source_unref(gSrc);
 
        return info->timerId;
 }
@@ -257,6 +259,7 @@ int Timer::__alarmMgrCb(int alarmId, void *userData)
 
        g_source_set_callback(gSrc, __onAlarmExpired, userData, NULL);
        g_source_attach(gSrc, info->timer->__context);
+       g_source_unref(gSrc);
 
        return 0;
 }