summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-04-22 16:27:11 +0100
committerMarcel Holtmann <marcel@holtmann.org>2009-04-22 16:27:11 +0100
commit3879bf3074ad4611027ea8022e1fd53022eda883 (patch)
tree074833e725d072aa44a6c3b05c5e8e9c8db05f81
parent961d5b2ce43b5cca65cef2e9e34be60f92435f65 (diff)
downloadconnman-3879bf3074ad4611027ea8022e1fd53022eda883.tar.gz
connman-3879bf3074ad4611027ea8022e1fd53022eda883.tar.bz2
connman-3879bf3074ad4611027ea8022e1fd53022eda883.zip
Handle errors with DBusPendingCall and lost connection
-rw-r--r--plugins/bluetooth.c34
-rw-r--r--plugins/modemmgr.c9
-rw-r--r--plugins/supplicant.c29
3 files changed, 68 insertions, 4 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);
}
diff --git a/plugins/modemmgr.c b/plugins/modemmgr.c
index cbb5ebd5..0950848c 100644
--- a/plugins/modemmgr.c
+++ b/plugins/modemmgr.c
@@ -65,13 +65,18 @@ static void modemmgr_connect(DBusConnection *connection, void *user_data)
if (dbus_connection_send_with_reply(connection, message,
&call, TIMEOUT) == FALSE) {
connman_error("Failed to get modem devices");
- 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, enumerate_devices_reply,
NULL, NULL);
+done:
dbus_message_unref(message);
}
diff --git a/plugins/supplicant.c b/plugins/supplicant.c
index 69ef3728..fc57d35b 100644
--- a/plugins/supplicant.c
+++ b/plugins/supplicant.c
@@ -279,6 +279,12 @@ static int add_interface(struct supplicant_task *task)
return -EIO;
}
+ if (call == NULL) {
+ connman_error("D-Bus connection not available");
+ dbus_message_unref(message);
+ return -EIO;
+ }
+
dbus_pending_call_set_notify(call, add_interface_reply, task, NULL);
dbus_message_unref(message);
@@ -349,6 +355,12 @@ static int create_interface(struct supplicant_task *task)
return -EIO;
}
+ if (call == NULL) {
+ connman_error("D-Bus connection not available");
+ dbus_message_unref(message);
+ return -EIO;
+ }
+
dbus_pending_call_set_notify(call, get_interface_reply, task, NULL);
dbus_message_unref(message);
@@ -401,6 +413,12 @@ static int remove_interface(struct supplicant_task *task)
return -EIO;
}
+ if (call == NULL) {
+ connman_error("D-Bus connection not available");
+ dbus_message_unref(message);
+ return -EIO;
+ }
+
dbus_pending_call_set_notify(call, remove_interface_reply, task, NULL);
dbus_message_unref(message);
@@ -1129,6 +1147,12 @@ static void get_properties(struct supplicant_task *task)
goto noscan;
}
+ if (call == NULL) {
+ connman_error("D-Bus connection not available");
+ dbus_message_unref(message);
+ goto noscan;
+ }
+
dbus_pending_call_set_notify(call, properties_reply, task, NULL);
dbus_message_unref(message);
@@ -1220,6 +1244,11 @@ static void scan_results_available(struct supplicant_task *task)
if (task->noscan == FALSE)
connman_device_set_scanning(task->device, TRUE);
+ if (call == NULL) {
+ connman_error("D-Bus connection not available");
+ goto done;
+ }
+
dbus_pending_call_set_notify(call, scan_results_reply, task, NULL);
done: