stop_vpn(provider);
connman_provider_set_data(provider, NULL);
+ connman_provider_unref(provider);
connman_rtnl_remove_watch(data->watch);
vpn_exit:
case VPN_STATE_CONNECT:
case VPN_STATE_READY:
index = connman_provider_get_index(provider);
+ connman_provider_ref(provider);
data->watch = connman_rtnl_add_newlink_watch(index,
vpn_newlink, provider);
connman_inet_ifup(index);
if (vpn_driver_data->vpn_driver->disconnect)
vpn_driver_data->vpn_driver->disconnect();
- if (data->watch != 0)
+ if (data->watch != 0) {
+ connman_provider_unref(provider);
connman_rtnl_remove_watch(data->watch);
+ data->watch = 0;
+ }
- data->watch = 0;
data->state = VPN_STATE_DISCONNECT;
connman_task_stop(data->task);
if (data == NULL)
return 0;
- if (data->watch != 0)
+ if (data->watch != 0) {
+ connman_provider_unref(provider);
connman_rtnl_remove_watch(data->watch);
- data->watch = 0;
+ data->watch = 0;
+ }
+
connman_task_stop(data->task);
g_usleep(G_USEC_PER_SEC);