From 5a45b5e895b58163e27897f25cb62ce7873bd7ac Mon Sep 17 00:00:00 2001 From: WonYoung Choi Date: Thu, 13 Aug 2015 10:44:14 +0900 Subject: [PATCH] Runtime process should be terminated when Extension process is crashed Change-Id: Ia1166736eea3bb0e8ae8bb7ada971f626da28424 --- src/common/dbus_server.cc | 17 +++++++++++++++++ src/common/dbus_server.h | 4 ++++ src/runtime/web_application.cc | 5 +++++ 3 files changed, 26 insertions(+) diff --git a/src/common/dbus_server.cc b/src/common/dbus_server.cc index 6693d35..d6f770b 100755 --- a/src/common/dbus_server.cc +++ b/src/common/dbus_server.cc @@ -102,6 +102,14 @@ static void OnClosedConnection(GDBusConnection* connection, gboolean /*remote_peer_vanished*/, GError* /*error*/, gpointer user_data) { + DBusServer* self = reinterpret_cast(user_data); + if (self) { + auto callback = self->GetDisconnectedCallback(); + if (callback) { + callback(connection); + } + } + g_signal_handlers_disconnect_by_func(connection, (gpointer)OnClosedConnection, user_data); @@ -236,6 +244,10 @@ void DBusServer::SendSignal(GDBusConnection* connection, } } +void DBusServer::SetDisconnectedCallback(DisconnectedCallback func) { + disconnected_callback_ = func; +} + void DBusServer::SetPeerCredentialsCallback(PeerCredentialsCallback func) { peer_credentials_callback_ = func; } @@ -255,6 +267,11 @@ void DBusServer::SetPropertySetter( property_setters_[iface] = func; } +DBusServer::DisconnectedCallback +DBusServer::GetDisconnectedCallback() const { + return disconnected_callback_; +} + DBusServer::PeerCredentialsCallback DBusServer::GetPeerCredentialsCallback() const { return peer_credentials_callback_; diff --git a/src/common/dbus_server.h b/src/common/dbus_server.h index bdf6c15..166b00c 100755 --- a/src/common/dbus_server.h +++ b/src/common/dbus_server.h @@ -37,6 +37,7 @@ class DBusServer { typedef std::function PropertySetter; + typedef std::function DisconnectedCallback; DBusServer(); virtual ~DBusServer(); @@ -52,10 +53,12 @@ class DBusServer { const std::string& iface, const std::string& signal_name, GVariant* parameters); + void SetDisconnectedCallback(DisconnectedCallback func); void SetPeerCredentialsCallback(PeerCredentialsCallback func); void SetMethodCallback(const std::string& iface, MethodCallback func); void SetPropertyGetter(const std::string& iface, PropertyGetter func); void SetPropertySetter(const std::string& iface, PropertySetter func); + DisconnectedCallback GetDisconnectedCallback() const; PeerCredentialsCallback GetPeerCredentialsCallback() const; MethodCallback GetMethodCallback(const std::string& iface); PropertySetter GetPropertySetter(const std::string& iface); @@ -66,6 +69,7 @@ class DBusServer { GDBusServer* server_; GDBusNodeInfo* node_info_; + DisconnectedCallback disconnected_callback_; PeerCredentialsCallback peer_credentials_callback_; std::map method_callbacks_; std::map property_getters_; diff --git a/src/runtime/web_application.cc b/src/runtime/web_application.cc index 52dfc5a..826ef3d 100755 --- a/src/runtime/web_application.cc +++ b/src/runtime/web_application.cc @@ -378,6 +378,11 @@ void WebApplication::Launch(std::unique_ptr appcontrol) { dbus_server_.Start(app_uuid_ + "." + std::string(kDBusNameForApplication)); + dbus_server_.SetDisconnectedCallback([](GDBusConnection* /*conn*/) { + LOGGER(ERROR) << "Application DBusServer has received disconnection event."; + exit(1); + }); + // Execute ExtensionProcess ExecExtensionProcess(app_uuid_); -- 2.7.4