Runtime process should be terminated when Extension process is crashed 79/45979/1
authorWonYoung Choi <wy80.choi@samsung.com>
Thu, 13 Aug 2015 01:44:14 +0000 (10:44 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Thu, 13 Aug 2015 01:44:14 +0000 (10:44 +0900)
Change-Id: Ia1166736eea3bb0e8ae8bb7ada971f626da28424

src/common/dbus_server.cc
src/common/dbus_server.h
src/runtime/web_application.cc

index 6693d35..d6f770b 100755 (executable)
@@ -102,6 +102,14 @@ static void OnClosedConnection(GDBusConnection* connection,
                                gboolean /*remote_peer_vanished*/,
                                GError* /*error*/,
                                gpointer user_data) {
+  DBusServer* self = reinterpret_cast<DBusServer*>(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_;
index bdf6c15..166b00c 100755 (executable)
@@ -37,6 +37,7 @@ class DBusServer {
   typedef std::function<bool(GDBusConnection* connection,
                              const gchar* property,
                              GVariant* value)> PropertySetter;
+  typedef std::function<void(GDBusConnection* connection)> 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<std::string, MethodCallback> method_callbacks_;
   std::map<std::string, PropertyGetter> property_getters_;
index 52dfc5a..826ef3d 100755 (executable)
@@ -378,6 +378,11 @@ void WebApplication::Launch(std::unique_ptr<wrt::AppControl> 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_);