diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2012-08-14 17:05:35 +0300 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-08-15 13:49:49 +0300 |
commit | daedd87010ddcd57759b5f6c146e1ca7936136d4 (patch) | |
tree | 6a2727e241c7e5d2ae9ef5d62abda51293045be4 /src/provider.c | |
parent | 3db6c5de810977be99cc44941247847147b62d96 (diff) | |
download | connman-daedd87010ddcd57759b5f6c146e1ca7936136d4.tar.gz connman-daedd87010ddcd57759b5f6c146e1ca7936136d4.tar.bz2 connman-daedd87010ddcd57759b5f6c146e1ca7936136d4.zip |
provider: Return EINPROGRESS to the caller when connect is pending
Diffstat (limited to 'src/provider.c')
-rw-r--r-- | src/provider.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/provider.c b/src/provider.c index 52f3ade3..251d0b05 100644 --- a/src/provider.c +++ b/src/provider.c @@ -898,6 +898,7 @@ int __connman_provider_create_and_connect(DBusMessage *msg) char **networks = NULL; char *ident; int err, count = 0; + connman_bool_t connecting = FALSE; dbus_message_iter_init(msg, &iter); dbus_message_iter_recurse(&iter, &array); @@ -1004,14 +1005,40 @@ int __connman_provider_create_and_connect(DBusMessage *msg) if (err == -EOPNOTSUPP) { goto unref; } else { + if (__connman_service_is_provider_pending( + provider->vpn_service) == TRUE) { + DBG("Provider %p connection already pending", + provider); + dbus_message_ref(msg); + __connman_service_reply_dbus_pending(msg, + EINPROGRESS, NULL); + return 0; + } + err = __connman_service_connect(provider->vpn_service); if (err < 0 && err != -EINPROGRESS) goto failed; + + if (err == -EINPROGRESS) + connecting = TRUE; } } - connman_provider_save(provider); + if (connecting == TRUE) { + /* + * Save the dbus message so that we can reply the + * caller when VPN connection is established. + */ + dbus_message_ref(msg); + + __connman_service_set_provider_pending(provider->vpn_service, + msg); + connman_provider_save(provider); + + return 0; + } + service_path = __connman_service_get_path(provider->vpn_service); g_dbus_send_reply(connection, msg, DBUS_TYPE_OBJECT_PATH, &service_path, |