provider: Remove provider if there is an error when connecting
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Wed, 14 Sep 2011 12:34:59 +0000 (15:34 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 29 Sep 2011 14:54:06 +0000 (16:54 +0200)
If vpn service cannot be started for some reason, we must
remove the provider so that user can reconnect to it later.

src/provider.c

index d6d1b7e..9f7050f 100644 (file)
@@ -359,6 +359,8 @@ int connman_provider_indicate_error(struct connman_provider *provider,
                                        enum connman_provider_error error)
 {
        enum connman_service_error service_error;
+       const char *path;
+       int ret;
 
        switch (error) {
        case CONNMAN_PROVIDER_ERROR_LOGIN_FAILED:
@@ -375,8 +377,12 @@ int connman_provider_indicate_error(struct connman_provider *provider,
                break;
        }
 
-       return __connman_service_indicate_error(provider->vpn_service,
+       ret = __connman_service_indicate_error(provider->vpn_service,
                                                        service_error);
+       path = __connman_service_get_path(provider->vpn_service);
+       __connman_provider_remove(path);
+
+       return ret;
 }
 
 static void unregister_provider(gpointer data)