[PATCH v5 36/42] vpnd: Add function that quits vpnd if no VPN configurations are found

Jukka Rissanen jukka.rissanen at linux.intel.com
Mon Nov 12 04:07:52 PST 2012


---
 vpn/vpn-provider.c | 22 ++++++++++++++++++++++
 vpn/vpn.h          |  1 +
 2 files changed, 23 insertions(+)

diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index 27783bc..a69b458 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -2109,6 +2109,28 @@ void vpn_provider_driver_unregister(struct vpn_provider_driver *driver)
 	driver_list = g_slist_remove(driver_list, driver);
 }
 
+static gboolean check_vpn_count(gpointer data)
+{
+	if (configuration_count == 0) {
+		connman_info("No VPN configurations found, quitting.");
+		raise(SIGTERM);
+	}
+
+	return FALSE;
+}
+
+void __vpn_provider_check_connections(void)
+{
+	/*
+	 * If we were started when there is no providers configured,
+	 * then just quit. This happens when connman starts and its
+	 * vpn plugin asks connman-vpnd if it has any connections
+	 * configured. If there are none, then we can stop the vpn
+	 * daemon.
+	 */
+	g_timeout_add(1000, check_vpn_count, NULL);
+}
+
 int __vpn_provider_init(gboolean do_routes)
 {
 	DBG("");
diff --git a/vpn/vpn.h b/vpn/vpn.h
index 598c86d..2b36b30 100644
--- a/vpn/vpn.h
+++ b/vpn/vpn.h
@@ -87,6 +87,7 @@ int __vpn_provider_connect(struct vpn_provider *provider);
 int __vpn_provider_connect_path(const char *path);
 int __vpn_provider_disconnect(struct vpn_provider *provider);
 int __vpn_provider_remove(const char *path);
+void __vpn_provider_check_connections(void);
 void __vpn_provider_cleanup(void);
 int __vpn_provider_init(gboolean handle_routes);
 
-- 
1.7.11.4




More information about the connman mailing list