Use vpn_agent_check_and_process_reply_error() to check and process VPN
agent errors. Clear callback and pending D-Bus message (user_data) if
error was processed to avoid calling the callback twice.
---
Changes since V2:
* If no reply received go to error.
* Free private data if D-Bus error is received.
vpn/plugins/openconnect.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/vpn/plugins/openconnect.c b/vpn/plugins/openconnect.c
index 4117471c..b9125ede 100644
--- a/vpn/plugins/openconnect.c
+++ b/vpn/plugins/openconnect.c
@@ -311,12 +311,22 @@ static void request_input_cookie_reply(DBusMessage *reply, void
*user_data)
char *cookie = NULL, *servercert = NULL, *vpnhost = NULL;
char *key;
DBusMessageIter iter, dict;
+ int err_int;
DBG("provider %p", data->provider);
- if (!reply || dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR)
+ if (!reply)
goto err;
+ err_int = vpn_agent_check_and_process_reply_error(reply, data->provider,
+ data->task, data->cb, data->user_data);
+ if (err_int) {
+ /* Ensure cb is called only once */
+ data->cb = NULL;
+ data->user_data = NULL;
+ goto out;
+ }
+
if (!vpn_agent_check_reply_has_dict(reply))
goto err;
@@ -387,6 +397,7 @@ err:
vpn_provider_indicate_error(data->provider,
VPN_PROVIDER_ERROR_AUTH_FAILED);
+out:
free_private_data(data);
}
--
2.20.1