Fix service app finalization 02/144402/6 accepted/tizen_3.0_common accepted/tizen_3.0_ivi accepted/tizen_3.0_mobile accepted/tizen_3.0_tv accepted/tizen_3.0_wearable tizen_3.0 accepted/tizen/3.0/common/20170818.112411 accepted/tizen/3.0/ivi/20170818.001358 accepted/tizen/3.0/mobile/20170818.001324 accepted/tizen/3.0/tv/20170818.001310 accepted/tizen/3.0/wearable/20170818.001343 submit/tizen_3.0/20170817.090741
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 16 Aug 2017 12:00:39 +0000 (21:00 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 17 Aug 2017 07:59:02 +0000 (16:59 +0900)
While calling service_app_exit() or service_app_exit_without_restart(),
the application sends the status dying event to the amd.
If the initialization is failed, the aul_finalize() API will be called
to release the resources about AUL.

Change-Id: If131f838d478c02b9dd99bd1ff61dc4147375ddf
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/appcore-agent.c

index 0439166..2daace6 100644 (file)
@@ -906,8 +906,10 @@ EXPORT_API int appcore_agent_init(const struct agent_ops *ops,
                goto err;
 
        r = aul_launch_argv_handler(argc, argv);
-       if (r < 0)
+       if (r < 0) {
+               aul_finalize();
                goto err;
+       }
 
        core.ops = ops;
        core.state = 1;         /* TODO: use enum value */
@@ -956,6 +958,7 @@ static int __before_loop(struct agent_priv *agent, int argc, char **argv)
                if (r < 0) {
                        if (agent->ops && agent->ops->terminate)
                                agent->ops->terminate(agent->ops->data);
+                       aul_finalize();
                        ecore_shutdown();
                        errno = ECANCELED;
                        return -1;
@@ -972,13 +975,14 @@ static void __after_loop(struct agent_priv *agent)
        priv.state = AGS_DYING;
        if (agent->ops && agent->ops->terminate)
                agent->ops->terminate(agent->ops->data);
+       aul_finalize();
        ecore_shutdown();
 }
 
 EXPORT_API int appcore_agent_terminate()
 {
        __del_vconf_list();
-       aul_finalize();
+       aul_status_update(STATUS_DYING);
        ecore_main_loop_thread_safe_call_sync((Ecore_Data_Cb)__exit_loop, NULL);
 
        return 0;
@@ -988,6 +992,7 @@ EXPORT_API int appcore_agent_terminate_without_restart()
 {
        __del_vconf_list();
        aul_status_update(STATUS_NORESTART);
+       aul_status_update(STATUS_DYING);
        ecore_main_loop_thread_safe_call_sync((Ecore_Data_Cb)__exit_loop, NULL);
 
        return 0;