From d5a353563462d3eebd5e138a0ed4f850ea8cd809 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Thu, 30 Aug 2018 14:30:16 +0900 Subject: Fix Window Manager crush when application terminated Fix Window Manager crush when applicaiton terminated caused by wrong handling of sd_event_source. v2. Add error check just in case conflict : window_manager.cpp Fix build error Bug-AGL: SPEC-1696 Change-Id: I639a60015cde46fca6bc5a3f6e8037afd8d79330 Signed-off-by: Kazumasa Mitsunari --- policy_manager/policy_manager.cpp | 27 +++++++++++---------------- src/window_manager.cpp | 8 ++++++-- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/policy_manager/policy_manager.cpp b/policy_manager/policy_manager.cpp index 975d412..999bc87 100644 --- a/policy_manager/policy_manager.cpp +++ b/policy_manager/policy_manager.cpp @@ -688,19 +688,16 @@ int PolicyManager::timerEvent(sd_event_source *source, uint64_t usec, void *data int PolicyManager::setStateTransitionProcessToSystemd(int event_id, uint64_t delay_ms, std::string role) { - HMI_DEBUG("event_id:0x%x delay:%d role:%s", event_id, delay_ms, role.c_str()); - - // Store requested role - this->req_role_list[event_id] = role; + struct sd_event_source *event_source; + HMI_DEBUG("wm:pm", "event_id:0x%x delay:%d role:%s", event_id, delay_ms, role.c_str()); if (0 == delay_ms) { - int ret = sd_event_add_defer(afb_daemon_get_event_loop(), NULL, + int ret = sd_event_add_defer(afb_daemon_get_event_loop(), &event_source, &pm::transitionStateWrapper, new int(event_id)); if (0 > ret) { - HMI_ERROR("Faild to sd_event_add_defer: errno:%d", ret); - this->req_role_list.erase(event_id); + HMI_ERROR("wm:pm", "Faild to sd_event_add_defer: errno:%d", ret); return -1; } } @@ -708,27 +705,25 @@ int PolicyManager::setStateTransitionProcessToSystemd(int event_id, uint64_t del { // Get current time struct timespec time_spec; - clock_gettime(CLOCK_MONOTONIC, &time_spec); + clock_gettime(CLOCK_BOOTTIME, &time_spec); // Calculate timer fired time uint64_t usec = (time_spec.tv_sec * 1000000) + (time_spec.tv_nsec / 1000) + (delay_ms * 1000); // Set timer - struct sd_event_source *event_source; int ret = sd_event_add_time(afb_daemon_get_event_loop(), &event_source, - CLOCK_MONOTONIC, usec, 1, + CLOCK_BOOTTIME, usec, 1, &pm::timerEventWrapper, new int(event_id)); if (0 > ret) { - HMI_ERROR("Faild to sd_event_add_time: errno:%d", ret); - this->req_role_list.erase(event_id); + HMI_ERROR("wm:pm", "Faild to sd_event_add_time: errno:%d", ret); return -1; } - - // Store event source - this->event_source_list[event_id] = event_source; } - + // Store event source + this->event_source_list[event_id] = event_source; + // Store requested role + this->req_role_list[event_id] = role; return 0; } diff --git a/src/window_manager.cpp b/src/window_manager.cpp index dec7752..41fc5c8 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -867,8 +867,12 @@ void WindowManager::startTransitionWrapper(vector &actions) if ("" != act.role) { bool found; - auto const &surface_id = this->id_alloc.lookup(act.role); - string appid = g_app_list.getAppID(*surface_id, &found); + auto const &surface_id = this->id_alloc.lookup(act.role.c_str()); + if(surface_id == nullopt) + { + goto proc_remove_request; + } + std::string appid = g_app_list.getAppID(*surface_id, &found); if (!found) { if (TaskVisible::INVISIBLE == act.visible) -- cgit 1.2.3-korg