From: Jukka Rissanen Date: Tue, 14 Aug 2012 14:05:35 +0000 (+0300) Subject: provider: Return EINPROGRESS to the caller when connect is pending X-Git-Tag: 1.5~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=daedd87010ddcd57759b5f6c146e1ca7936136d4;p=platform%2Fupstream%2Fconnman.git provider: Return EINPROGRESS to the caller when connect is pending --- 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, diff --git a/src/service.c b/src/service.c index 205573a6..8ebf6742 100644 --- a/src/service.c +++ b/src/service.c @@ -3467,6 +3467,12 @@ static void reply_pending(struct connman_service *service, int error) NULL); service->pending = NULL; } + + if (service->provider_pending != NULL) { + __connman_service_reply_dbus_pending(service->provider_pending, + error, service->path); + service->provider_pending = NULL; + } } connman_bool_t