From d128fd8aeda44569cc18596235e78d4533470c7a Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Tue, 5 Apr 2016 14:18:56 +0900 Subject: Fix notification_is_service_ready bug Change-Id: Ib49ec6068e92813e2c4bdd1f86652665832fc5fd Signed-off-by: Hyunho Kang --- src/notification_ipc.c | 61 ++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/notification_ipc.c b/src/notification_ipc.c index 4ce6465..4f6edc3 100755 --- a/src/notification_ipc.c +++ b/src/notification_ipc.c @@ -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; -- cgit v1.2.3