Fix notification_is_service_ready bug 20/64720/1 accepted/tizen/common/20160406.143513 accepted/tizen/ivi/20160406.012758 accepted/tizen/mobile/20160406.012643 accepted/tizen/tv/20160406.012701 accepted/tizen/wearable/20160406.012729 submit/tizen/20160405.052614
authorHyunho Kang <hhstark.kang@samsung.com>
Tue, 5 Apr 2016 05:18:56 +0000 (14:18 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Tue, 5 Apr 2016 05:19:47 +0000 (14:19 +0900)
Change-Id: Ib49ec6068e92813e2c4bdd1f86652665832fc5fd
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
src/notification_ipc.c

index 4ce6465..4f6edc3 100755 (executable)
@@ -101,12 +101,44 @@ static inline char *_string_get(char *string)
        return string;
 }
 
+static int _dbus_init()
+{
+       int ret = NOTIFICATION_ERROR_NONE;
+       GError *error = NULL;
+
+       if (_gdbus_conn == NULL) {
+               _gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+
+               if (_gdbus_conn == NULL) {
+                       if (error != NULL) {
+                               NOTIFICATION_ERR("Failed to get dbus [%s]", error->message);
+                               g_error_free(error);
+                       }
+                       return NOTIFICATION_ERROR_IO_ERROR;
+               }
+               _bus_name = g_dbus_connection_get_unique_name(_gdbus_conn);
+               NOTIFICATION_DBG("bus name : %s", _bus_name);
+
+               notification_error_quark();
+
+               ret = NOTIFICATION_ERROR_NONE;
+       }
+       return ret;
+}
 
 int notification_ipc_is_master_ready(void)
 {
        GVariant *result;
        GError *err = NULL;
        gboolean name_exist;
+       int ret = NOTIFICATION_ERROR_NONE;
+
+       ret = _dbus_init();
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               NOTIFICATION_ERR("Can't init dbus %d", result);
+               is_master_started = 0;
+               return is_master_started;
+       }
 
        result = g_dbus_connection_call_sync(
                        _gdbus_conn,
@@ -123,9 +155,10 @@ int notification_ipc_is_master_ready(void)
 
        if (err || (result == NULL)) {
                if (err) {
-               NOTIFICATION_ERR("No reply. error = %s", err->message);
+                       NOTIFICATION_ERR("No reply. error = %s", err->message);
                        g_error_free(err);
                }
+               NOTIFICATION_ERR("is master ready fail");
                is_master_started = 0;
        } else {
                g_variant_get(result, "(b)", &name_exist);
@@ -468,32 +501,6 @@ static int _dbus_signal_init()
        return ret;
 }
 
-
-static int _dbus_init()
-{
-       int ret = NOTIFICATION_ERROR_NONE;
-       GError *error = NULL;
-
-       if (_gdbus_conn == NULL) {
-               _gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-
-               if (_gdbus_conn == NULL) {
-                       if (error != NULL) {
-                               NOTIFICATION_ERR("Failed to get dbus [%s]", error->message);
-                               g_error_free(error);
-                       }
-                       return NOTIFICATION_ERROR_IO_ERROR;
-               }
-               _bus_name = g_dbus_connection_get_unique_name(_gdbus_conn);
-               NOTIFICATION_DBG("bus name : %s", _bus_name);
-
-               notification_error_quark();
-
-               ret = NOTIFICATION_ERROR_NONE;
-       }
-       return ret;
-}
-
 static int _send_sync_noti(GVariant *body, GDBusMessage **reply, char *cmd)
 {
        int ret = NOTIFICATION_ERROR_NONE;