diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-04-22 16:27:11 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-04-22 16:27:11 +0100 |
commit | 3879bf3074ad4611027ea8022e1fd53022eda883 (patch) | |
tree | 074833e725d072aa44a6c3b05c5e8e9c8db05f81 /plugins/bluetooth.c | |
parent | 961d5b2ce43b5cca65cef2e9e34be60f92435f65 (diff) | |
download | connman-3879bf3074ad4611027ea8022e1fd53022eda883.tar.gz connman-3879bf3074ad4611027ea8022e1fd53022eda883.tar.bz2 connman-3879bf3074ad4611027ea8022e1fd53022eda883.zip |
Handle errors with DBusPendingCall and lost connection
Diffstat (limited to 'plugins/bluetooth.c')
-rw-r--r-- | plugins/bluetooth.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c index 12519c5a..009c6c7d 100644 --- a/plugins/bluetooth.c +++ b/plugins/bluetooth.c @@ -117,6 +117,13 @@ static void get_properties(DBusConnection *connection, return; } + if (call == NULL) { + connman_error("D-Bus connection not available"); + dbus_message_unref(message); + g_free(data); + return; + } + data->connection = connection; data->message = message; data->callback = callback; @@ -240,6 +247,12 @@ static int pan_connect(struct connman_network *network) return -EINVAL; } + if (call == NULL) { + connman_error("D-Bus connection not available"); + dbus_message_unref(message); + return -EINVAL; + } + dbus_pending_call_set_notify(call, connect_reply, network, NULL); dbus_message_unref(message); @@ -307,6 +320,12 @@ static int pan_disconnect(struct connman_network *network) return -EINVAL; } + if (call == NULL) { + connman_error("D-Bus connection not available"); + dbus_message_unref(message); + return -EINVAL; + } + dbus_pending_call_set_notify(call, disconnect_reply, network, NULL); dbus_message_unref(message); @@ -393,6 +412,12 @@ static int change_powered(DBusConnection *connection, const char *path, return -EINVAL; } + if (call == NULL) { + connman_error("D-Bus connection not available"); + dbus_message_unref(message); + return -EINVAL; + } + dbus_pending_call_set_notify(call, powered_reply, NULL, NULL); dbus_message_unref(message); @@ -718,13 +743,18 @@ static void bluetooth_connect(DBusConnection *connection, void *user_data) if (dbus_connection_send_with_reply(connection, message, &call, TIMEOUT) == FALSE) { connman_error("Failed to get Bluetooth adapters"); - dbus_message_unref(message); - return; + goto done; + } + + if (call == NULL) { + connman_error("D-Bus connection not available"); + goto done; } dbus_pending_call_set_notify(call, list_adapters_reply, connection, NULL); +done: dbus_message_unref(message); } |