From 9b0fe60b884b5f291c23da0c34be13354b152593 Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Thu, 11 Jun 2009 15:10:45 -0700 Subject: [PATCH] Fix tearDown event loop - message unref, triggers when bluetoothd crashes. --- .../jni/android_server_BluetoothEventLoop.cpp | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/core/jni/android_server_BluetoothEventLoop.cpp b/core/jni/android_server_BluetoothEventLoop.cpp index 9438b48ddbcbc..e0ea788f5b554 100644 --- a/core/jni/android_server_BluetoothEventLoop.cpp +++ b/core/jni/android_server_BluetoothEventLoop.cpp @@ -294,23 +294,25 @@ static void tearDownEventLoop(native_data_t *nat) { nat->adapter, "org.bluez.Adapter", "UnregisterAgent"); - if (dbus_error_is_set(&err)) { - LOG_AND_FREE_DBUS_ERROR(&err); - dbus_error_free(&err); + if (msg != NULL) { + dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &agent_path, + DBUS_TYPE_INVALID); + reply = dbus_connection_send_with_reply_and_block(nat->conn, + msg, -1, &err); + + if (!reply) { + if (dbus_error_is_set(&err)) { + LOG_AND_FREE_DBUS_ERROR(&err); + dbus_error_free(&err); + } + } else { + dbus_message_unref(reply); + } + dbus_message_unref(msg); + } else { + LOGE("%s: Can't create new method call!", __FUNCTION__); } - dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &agent_path, - DBUS_TYPE_INVALID); - reply = dbus_connection_send_with_reply_and_block(nat->conn, - msg, -1, &err); - dbus_message_unref(msg); - - if (!reply && dbus_error_is_set(&err)) { - LOG_AND_FREE_DBUS_ERROR(&err); - dbus_error_free(&err); - } - - dbus_message_unref(reply); dbus_connection_flush(nat->conn); dbus_connection_unregister_object_path(nat->conn, agent_path);