Change ipc init timing 71/167571/1
authorSeungha Son <seungha.son@samsung.com>
Thu, 18 Jan 2018 08:08:06 +0000 (17:08 +0900)
committerSeungha Son <seungha.son@samsung.com>
Thu, 18 Jan 2018 08:11:58 +0000 (17:11 +0900)
Signed-off-by: Seungha Son <seungha.son@samsung.com>
Change-Id: Iadf84e14e6cbede472b31df9dbbfa8749e955af8

src/notification_internal.c
src/notification_ipc.c

index 45d655b..c09f872 100755 (executable)
@@ -220,9 +220,6 @@ EXPORT_API int notification_resister_changed_cb_for_uid(
        if (changed_cb == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       if (notification_ipc_monitor_init(uid) != NOTIFICATION_ERROR_NONE)
-               return NOTIFICATION_ERROR_IO_ERROR;
-
        if (_noti_cb_hash == NULL)
                _noti_cb_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
 
@@ -248,6 +245,11 @@ EXPORT_API int notification_resister_changed_cb_for_uid(
                noti_cb_list = g_list_append(noti_cb_list, noti_cb_info_new);
        }
 
+       if (notification_ipc_monitor_init(uid) != NOTIFICATION_ERROR_NONE) {
+               notification_unresister_changed_cb_for_uid(changed_cb, uid);
+               return NOTIFICATION_ERROR_IO_ERROR;
+       }
+
        return NOTIFICATION_ERROR_NONE;
 }
 
@@ -1184,9 +1186,6 @@ EXPORT_API int notification_register_detailed_changed_cb_for_uid(
        if (detailed_changed_cb == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       if (notification_ipc_monitor_init(uid) != NOTIFICATION_ERROR_NONE)
-               return NOTIFICATION_ERROR_IO_ERROR;
-
        if (_noti_cb_hash == NULL)
                _noti_cb_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
 
@@ -1212,6 +1211,11 @@ EXPORT_API int notification_register_detailed_changed_cb_for_uid(
                noti_cb_list = g_list_append(noti_cb_list, noti_cb_info_new);
        }
 
+       if (notification_ipc_monitor_init(uid) != NOTIFICATION_ERROR_NONE) {
+               notification_unregister_detailed_changed_cb_for_uid(detailed_changed_cb, user_data, uid);
+               return NOTIFICATION_ERROR_IO_ERROR;
+       }
+
        return NOTIFICATION_ERROR_NONE;
 }
 
index 4ac8d97..9abf88e 100755 (executable)
@@ -2503,6 +2503,8 @@ static int _send_service_register(uid_t uid)
                return result;
        }
 
+       is_master_started = 1;
+
        noti_op = _ipc_create_op(NOTIFICATION_OP_SERVICE_READY, 1, NULL, 1, NULL);
        if (noti_op != NULL) {
                notification_call_changed_cb_for_uid(noti_op, 1, uid);
@@ -2529,8 +2531,9 @@ static void _on_name_appeared(GDBusConnection *connection,
        int uid = GPOINTER_TO_INT(user_data);
 
        DBG("uid[%d] name[%s]", uid, name);
-       is_master_started = 1;
-       _ipc_monitor_register(uid);
+
+       if (is_master_started == 0)
+               _ipc_monitor_register(uid);
 
        /* TODO: dbus activation isn't enough ? */
        _do_deffered_task();
@@ -2578,7 +2581,6 @@ int notification_ipc_monitor_init(uid_t uid)
        }
 
        if (provider_monitor_id == 0) {
-
                provider_monitor_id = g_bus_watch_name_on_connection(
                                _gdbus_conn,
                                PROVIDER_BUS_NAME,