diff options
-rw-r--r-- | src/provider.c | 26 | ||||
-rwxr-xr-x | test/disconnect-vpn | 3 |
2 files changed, 20 insertions, 9 deletions
diff --git a/src/provider.c b/src/provider.c index b7dc9e9d..adad8dfc 100644 --- a/src/provider.c +++ b/src/provider.c @@ -216,18 +216,30 @@ int __connman_provider_connect(struct connman_provider *provider) int __connman_provider_remove(const char *path) { struct connman_provider *provider; + GHashTableIter iter; + gpointer value, key; DBG("path %s", path); - provider = g_hash_table_lookup(provider_hash, path); - if (provider == NULL) { - DBG("patch %s not found", path); - return -ENXIO; - } + g_hash_table_iter_init(&iter, provider_hash); + while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) { + const char *srv_path; + provider = value; - g_hash_table_remove(provider_hash, path); + if (provider->vpn_service == NULL) + continue; - return 0; + srv_path = __connman_service_get_path(provider->vpn_service); + + if (g_strcmp0(srv_path, path) == 0) { + DBG("Removing VPN %s", provider->identifier); + g_hash_table_remove(provider_hash, + provider->identifier); + return 0; + } + } + + return -ENXIO; } static int set_connected(struct connman_provider *provider, diff --git a/test/disconnect-vpn b/test/disconnect-vpn index 2367f13f..21b50d8e 100755 --- a/test/disconnect-vpn +++ b/test/disconnect-vpn @@ -4,7 +4,7 @@ import sys import dbus if (len(sys.argv) < 2): - print "Usage: %s <provider name> " % (sys.argv[0]) + print "Usage: %s <VPN service path> " % (sys.argv[0]) sys.exit(1) bus = dbus.SystemBus() @@ -18,5 +18,4 @@ print "remove path is %s" %(path) manager.RemoveProvider(sys.argv[1]) -print "remove path is %s" %(path) |