Prevent to add rule when stt service is reset 90/162190/1
authorWonnam Jang <wn.jang@samsung.com>
Wed, 29 Nov 2017 12:22:58 +0000 (21:22 +0900)
committerWonnam Jang <wn.jang@samsung.com>
Wed, 29 Nov 2017 12:22:58 +0000 (21:22 +0900)
Change-Id: I4e7fb242c9847d6a3268084baafcae7d7abad165
Signed-off-by: Wonnam Jang <wn.jang@samsung.com>
client/stt_dbus.c

index 97b726b..b4e7f21 100644 (file)
@@ -1009,17 +1009,26 @@ int stt_dbus_request_initialize(int uid, bool* silence_supported, bool* credenti
                                SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt initialize : result = %d, silence(%d), credential(%d)",
                                        result, *silence_supported, *credential_needed);
 
-                               /* add a rule for daemon error */
-                               char rule_err[256] = {0, };
-                               snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", g_server_service_interface);
-                               dbus_bus_add_match(g_conn_listener, rule_err, &err);
-                               dbus_connection_flush(g_conn_listener);
-
-                               if (dbus_error_is_set(&err)) {
-                                       SLOG(LOG_ERROR, TAG_STTC, "Match Error (%s)", err.message);
-                                       dbus_error_free(&err);
+                               stt_client_s* client = stt_client_get_by_uid(uid);
+                               if (NULL == client) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "Fail to get STT client");
                                        return STT_ERROR_OPERATION_FAILED;
                                }
+                               
+                               if (STT_ERROR_SERVICE_RESET != client->reason) {
+                                       /* add a rule for daemon error */
+                                       char rule_err[256] = {0, };
+
+                                       snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", g_server_service_interface);
+                                       dbus_bus_add_match(g_conn_listener, rule_err, &err);
+                                       dbus_connection_flush(g_conn_listener);
+
+                                       if (dbus_error_is_set(&err)) {
+                                               SLOG(LOG_ERROR, TAG_STTC, "Match Error (%s)", err.message);
+                                               dbus_error_free(&err);
+                                               return STT_ERROR_OPERATION_FAILED;
+                                       }
+                               }
                        } else {
                                SLOG(LOG_ERROR, TAG_STTC, "<<<< stt initialize : result = %d", result);
                        }