diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2012-11-26 14:56:39 +0200 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-11-26 16:25:21 +0200 |
commit | 994e0eea142b8d8abcfbec6a241c32bd1cd53001 (patch) | |
tree | 881e2087632e4849b20439b147b987cbc92a038f /plugins | |
parent | af7bc4b78e399944c8a95c36523148ffb81d8b63 (diff) | |
download | connman-994e0eea142b8d8abcfbec6a241c32bd1cd53001.tar.gz connman-994e0eea142b8d8abcfbec6a241c32bd1cd53001.tar.bz2 connman-994e0eea142b8d8abcfbec6a241c32bd1cd53001.zip |
vpn: Do not remove vpn connections hash when vpnd dies
We must keep the vpn connections hash alive as long as
connman is running. We must not remove the hash when
vpnd dies, otherwise we might feed null pointer to
various glib hash functions.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/vpn.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/plugins/vpn.c b/plugins/vpn.c index c7f59a98..82fbdb5f 100644 --- a/plugins/vpn.c +++ b/plugins/vpn.c @@ -47,7 +47,6 @@ static DBusConnection *connection; static GHashTable *vpn_connections = NULL; -static gboolean starting_vpnd = TRUE; static guint watch; static guint added_watch; static guint removed_watch; @@ -1455,22 +1454,12 @@ static void vpnd_created(DBusConnection *conn, void *user_data) { DBG("connection %p", conn); - if (starting_vpnd == TRUE) { - vpn_connections = g_hash_table_new_full(g_str_hash, - g_str_equal, - g_free, connection_destroy); - get_connections(user_data); - starting_vpnd = FALSE; - } + get_connections(user_data); } static void vpnd_removed(DBusConnection *conn, void *user_data) { DBG("connection %p", conn); - - g_hash_table_destroy(vpn_connections); - vpn_connections = NULL; - starting_vpnd = TRUE; } static void remove_connection(DBusConnection *conn, const char *path) @@ -1773,8 +1762,13 @@ static int vpn_init(void) } err = connman_provider_driver_register(&provider_driver); - if (err == 0) + if (err == 0) { + vpn_connections = g_hash_table_new_full(g_str_hash, + g_str_equal, + g_free, connection_destroy); + vpnd_created(connection, &provider_driver); + } return err; @@ -1798,7 +1792,8 @@ static void vpn_exit(void) connman_provider_driver_unregister(&provider_driver); - g_hash_table_destroy(vpn_connections); + if (vpn_connections != NULL) + g_hash_table_destroy(vpn_connections); dbus_connection_unref(connection); } |