From 8016d738948344a10b641644a3c05d8cfda17c9f Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 16 Aug 2017 21:00:39 +0900 Subject: [PATCH] Fix service app finalization 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 --- src/appcore-agent.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/appcore-agent.c b/src/appcore-agent.c index 0439166..2daace6 100644 --- a/src/appcore-agent.c +++ b/src/appcore-agent.c @@ -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; -- 2.7.4