summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-07-27 10:02:47 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-07-27 17:25:47 +0900
commit3d1703f9a5c9d6a356b561ea7528c70a1dc4fe2d (patch)
treebb914429501b6caf6b1b95092b6dd656ffc4adbe /src/main.cpp
parent7ee936736ec753346d8a1811a3c9c014d4be8b41 (diff)
Fix crashed application can re-launch
WM can't reset the state when application crashes, after the below commit. This patch fix the crashed application can re-launch. Related commit: https://gerrit.automotivelinux.org/gerrit/#/c/14871/ Bug-AGL: SPEC-1471 Change-Id: I46019b30cc8e9a341b4b681a0288f053b3ac1b30 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp59
1 files changed, 23 insertions, 36 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 6521c6c..b5659e2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -176,12 +176,6 @@ int binding_init() noexcept
return -1;
}
-static bool checkFirstReq(afb_req req)
-{
- WMClientCtxt *ctxt = (WMClientCtxt *)afb_req_context_get(req);
- return (ctxt) ? false : true;
-}
-
static void cbRemoveClientCtxt(void *data)
{
WMClientCtxt *ctxt = (WMClientCtxt *)data;
@@ -217,6 +211,20 @@ static void cbRemoveClientCtxt(void *data)
delete ctxt;
}
+static void createSecurityContext(afb_req req, const char* appid, const char* role)
+{
+ WMClientCtxt *ctxt = (WMClientCtxt *)afb_req_context_get(req);
+ if (!ctxt)
+ {
+ // Create Security Context at first time
+ const char *new_role = g_afb_instance->wmgr.convertRoleOldToNew(role);
+ WMClientCtxt *ctxt = new WMClientCtxt(appid, new_role);
+ HMI_DEBUG("wm", "create session for %s", ctxt->name.c_str());
+ afb_req_session_set_LOA(req, 1);
+ afb_req_context_set(req, ctxt, cbRemoveClientCtxt);
+ }
+}
+
void windowmanager_requestsurface(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
@@ -238,41 +246,17 @@ void windowmanager_requestsurface(afb_req req) noexcept
return;
}
- /* Create Security Context */
- bool isFirstReq = checkFirstReq(req);
- if (!isFirstReq)
- {
- WMClientCtxt *ctxt = (WMClientCtxt *)afb_req_context_get(req);
- HMI_DEBUG("wm", "You're %s.", ctxt->name.c_str());
- if (ctxt->name != std::string(a_drawing_name))
- {
- afb_req_fail_f(req, "failed", "Dont request with other name: %s for now", a_drawing_name);
- HMI_DEBUG("wm", "Don't request with other name: %s for now", a_drawing_name);
- return;
- }
- }
-
+ const char *appid = afb_req_get_application_id(req);
auto ret = g_afb_instance->wmgr.api_request_surface(
- afb_req_get_application_id(req), a_drawing_name);
-
- if (isFirstReq)
- {
- WMClientCtxt *ctxt = new WMClientCtxt(afb_req_get_application_id(req), a_drawing_name);
- HMI_DEBUG("wm", "create session for %s", ctxt->name.c_str());
- afb_req_session_set_LOA(req, 1);
- afb_req_context_set(req, ctxt, cbRemoveClientCtxt);
- }
- else
- {
- HMI_DEBUG("wm", "session already created for %s", a_drawing_name);
- }
-
+ appid, a_drawing_name);
if (ret.is_err())
{
afb_req_fail(req, "failed", ret.unwrap_err());
return;
}
+ createSecurityContext(req, appid, a_drawing_name);
+
afb_req_success(req, json_object_new_int(ret.unwrap()), "success");
}
catch (std::exception &e)
@@ -313,15 +297,18 @@ void windowmanager_requestsurfacexdg(afb_req req) noexcept
return;
}
char const *a_ivi_id = json_object_get_string(j_ivi_id);
-
+ char const *appid = afb_req_get_application_id(req);
auto ret = g_afb_instance->wmgr.api_request_surface(
- afb_req_get_application_id(req), a_drawing_name, a_ivi_id);
+ appid, a_drawing_name, a_ivi_id);
+
if (ret != nullptr)
{
afb_req_fail(req, "failed", ret);
return;
}
+ createSecurityContext(req, appid, a_drawing_name);
+
afb_req_success(req, NULL, "success");
}
catch (std::exception &e)