The previous async calling method occurs the crash when TC calls
'gatt deinit' function frequently. Even if bluez provides
the dbus method as async, we can call it using dbus sync call.
It will reduce some timing issue.
Change-Id: Iaa9cb17016180b09291ec7620f1cacb2609a29d3
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
static int register_pending_cnt = 0;
static bool is_server_started = false;
static int register_pending_cnt = 0;
static bool is_server_started = false;
+GCancellable *register_cancel;
+
/* Introspection data for the service we are exporting */
static const gchar service_introspection_xml[] =
"<node name='/'>"
/* Introspection data for the service we are exporting */
static const gchar service_introspection_xml[] =
"<node name='/'>"
register_pending_cnt = 0;
register_pending_cnt = 0;
- result = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
-
- if (result == NULL) {
- /* dBUS-RPC is failed */
- BT_ERR("Dbus-RPC is failed\n");
-
- if (error != NULL) {
- /* dBUS gives error cause */
- BT_ERR("D-Bus API failure: errCode[%x], message[%s]\n",
- error->code, error->message);
- g_clear_error(&error);
- }
- } else {
- g_variant_unref(result);
+ if (register_cancel) {
+ g_object_unref(register_cancel);
+ register_cancel = NULL;
-}
-
-void unregister_application_cb(GObject *object, GAsyncResult *res,
- gpointer user_data)
-{
- BT_INFO("UnregisterApplication is completed");
-
- GError *error = NULL;
- GVariant *result;
result = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
result = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);
BT_ERR("Dbus-RPC is failed\n");
if (error != NULL) {
BT_ERR("Dbus-RPC is failed\n");
if (error != NULL) {
- /* dBUS gives error cause */
+ /* dBUS gives error cause */
BT_ERR("D-Bus API failure: errCode[%x], message[%s]\n",
BT_ERR("D-Bus API failure: errCode[%x], message[%s]\n",
- error->code, error->message);
+ error->code, error->message);
g_clear_error(&error);
}
} else {
g_clear_error(&error);
}
} else {
GDBusProxy *proxy = NULL;
if (is_server_started) {
GDBusProxy *proxy = NULL;
if (is_server_started) {
+ GVariant *ret;
+ GError *err = NULL;
+
proxy = __bt_gatt_gdbus_get_manager_proxy("org.bluez",
"/org/bluez/hci0", GATT_MNGR_INTERFACE);
proxy = __bt_gatt_gdbus_get_manager_proxy("org.bluez",
"/org/bluez/hci0", GATT_MNGR_INTERFACE);
BT_INFO("UnregisterApplication");
BT_INFO("UnregisterApplication");
+ is_server_started = false;
+
/* Async Call to Unregister Service */
/* Async Call to Unregister Service */
- g_dbus_proxy_call(proxy,
+ ret = g_dbus_proxy_call_sync(proxy,
"UnregisterApplication",
g_variant_new("(o)",
app_path),
G_DBUS_CALL_FLAGS_NONE, -1,
"UnregisterApplication",
g_variant_new("(o)",
app_path),
G_DBUS_CALL_FLAGS_NONE, -1,
- NULL,
- (GAsyncReadyCallback) unregister_application_cb,
- NULL);
+ NULL, &err);
+
+ if (ret == NULL) {
+ /* dBUS-RPC is failed */
+ BT_ERR("dBUS-RPC is failed");
+ if (err != NULL) {
+ /* dBUS gives error cause */
+ BT_ERR("D-Bus API failure: errCode[%x], message[%s]",
+ err->code, err->message);
+
+ g_clear_error(&err);
+ }
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+ g_variant_unref(ret);
+
+ BT_INFO("UnregisterApplication is completed");
- is_server_started = false;
return BLUETOOTH_ERROR_NONE;
}
return BLUETOOTH_ERROR_NONE;
}
BT_EXPORT_API int bluetooth_gatt_deinit()
{
int ret = BLUETOOTH_ERROR_NONE;
BT_EXPORT_API int bluetooth_gatt_deinit()
{
int ret = BLUETOOTH_ERROR_NONE;
+
+ if (register_cancel) {
+ g_cancellable_cancel(register_cancel);
+ g_object_unref(register_cancel);
+ register_cancel = NULL;
+ }
+
/* Unown gdbus bus */
if (owner_id) {
/* remove/unregister all services */
/* Unown gdbus bus */
if (owner_id) {
/* remove/unregister all services */
BT_INFO("RegisterApplication");
BT_INFO("RegisterApplication");
+ if (register_cancel) {
+ g_cancellable_cancel(register_cancel);
+ g_object_unref(register_cancel);
+ }
+
+ register_cancel = g_cancellable_new();
+
g_dbus_proxy_call(proxy,
"RegisterApplication",
g_variant_new("(oa{sv})",
app_path, NULL),
G_DBUS_CALL_FLAGS_NONE, -1,
g_dbus_proxy_call(proxy,
"RegisterApplication",
g_variant_new("(oa{sv})",
app_path, NULL),
G_DBUS_CALL_FLAGS_NONE, -1,
(GAsyncReadyCallback) register_application_cb,
NULL);
(GAsyncReadyCallback) register_application_cb,
NULL);