diff --git a/ChangeLog b/ChangeLog index bd7ce80c4..cd7dba426 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-04-08 Dan Williams + + * libnm-glib/nm-object-cache.c + libnm-glib/nm-settings.c + src/dhcp-manager/nm-dhcp-manager.c + system-settings/plugins/ifcfg-fedora/plugin.c + system-settings/plugins/ifcfg-suse/plugin.c + system-settings/src/nm-system-config-hal-manager.c + libnm-util/nm-utils.c + - Remove usage of GStaticMutex since gcc-4.3 hates it and because we're + not threadsafe anyway + 2008-04-08 Dan Williams * system-settings/src/main.c diff --git a/libnm-glib/nm-object-cache.c b/libnm-glib/nm-object-cache.c index b669fc077..83249cfc2 100644 --- a/libnm-glib/nm-object-cache.c +++ b/libnm-glib/nm-object-cache.c @@ -25,7 +25,6 @@ #include "nm-object-cache.h" #include "nm-object.h" -static GStaticMutex cache_mutex = G_STATIC_MUTEX_INIT; static GHashTable *cache = NULL; static void @@ -38,19 +37,15 @@ _init_cache (void) void nm_object_cache_remove_by_path (const char *path) { - g_static_mutex_lock (&cache_mutex); _init_cache (); g_hash_table_remove (cache, path); - g_static_mutex_unlock (&cache_mutex); } void nm_object_cache_remove_by_object (NMObject *object) { - g_static_mutex_lock (&cache_mutex); _init_cache (); g_hash_table_remove (cache, nm_object_get_path (object)); - g_static_mutex_unlock (&cache_mutex); } void @@ -58,13 +53,11 @@ nm_object_cache_add (NMObject *object) { char *path; - g_static_mutex_lock (&cache_mutex); _init_cache (); path = g_strdup (nm_object_get_path (object)); g_hash_table_insert (cache, path, object); g_object_set_data_full (G_OBJECT (object), "nm-object-cache-tag", path, (GDestroyNotify) nm_object_cache_remove_by_path); - g_static_mutex_unlock (&cache_mutex); } NMObject * @@ -72,10 +65,8 @@ nm_object_cache_get (const char *path) { NMObject *object; - g_static_mutex_lock (&cache_mutex); _init_cache (); object = g_hash_table_lookup (cache, path); - g_static_mutex_unlock (&cache_mutex); return object; } diff --git a/libnm-glib/nm-settings.c b/libnm-glib/nm-settings.c index 867b0deb2..1dce10d5c 100644 --- a/libnm-glib/nm-settings.c +++ b/libnm-glib/nm-settings.c @@ -350,7 +350,6 @@ nm_exported_connection_register_object (NMExportedConnection *connection, DBusGConnection *dbus_connection) { NMExportedConnectionPrivate *priv; - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; static guint32 ec_counter = 0; char *path; @@ -359,10 +358,7 @@ nm_exported_connection_register_object (NMExportedConnection *connection, priv = NM_EXPORTED_CONNECTION_GET_PRIVATE (connection); - g_static_mutex_lock (&mutex); path = g_strdup_printf ("%s/%u", NM_DBUS_PATH_SETTINGS, ec_counter++); - g_static_mutex_unlock (&mutex); - nm_connection_set_path (priv->wrapped, path); nm_connection_set_scope (priv->wrapped, scope); diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c index 2e50a5b05..207bb0ded 100644 --- a/libnm-util/nm-utils.c +++ b/libnm-util/nm-utils.c @@ -124,33 +124,29 @@ static GHashTable * langToEncodings2 = NULL; static void init_lang_to_encodings_hash (void) { - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; - - g_static_mutex_lock (&mutex); - if (G_UNLIKELY (!langToEncodings5 || !langToEncodings2)) - { - const struct IsoLangToEncodings * enc = &isoLangEntries5[0]; + struct IsoLangToEncodings *enc; + if (G_UNLIKELY (langToEncodings5 == NULL)) { /* Five-letter codes */ + enc = (struct IsoLangToEncodings *) &isoLangEntries5[0]; langToEncodings5 = g_hash_table_new (g_str_hash, g_str_equal); - while (enc->lang) - { + while (enc->lang) { g_hash_table_insert (langToEncodings5, (gpointer) enc->lang, (gpointer) &enc->encodings); enc++; } + } + if (G_UNLIKELY (langToEncodings2 == NULL)) { /* Two-letter codes */ - enc = &isoLangEntries2[0]; + enc = (struct IsoLangToEncodings *) &isoLangEntries2[0]; langToEncodings2 = g_hash_table_new (g_str_hash, g_str_equal); - while (enc->lang) - { + while (enc->lang) { g_hash_table_insert (langToEncodings2, (gpointer) enc->lang, (gpointer) &enc->encodings); enc++; } } - g_static_mutex_unlock (&mutex); } diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c index 8ab7fa8ba..de82c1661 100644 --- a/src/dhcp-manager/nm-dhcp-manager.c +++ b/src/dhcp-manager/nm-dhcp-manager.c @@ -121,14 +121,11 @@ get_leasefile_for_iface (const char * iface) NMDHCPManager * nm_dhcp_manager_get (void) { - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; static NMDHCPManager *singleton = NULL; - g_static_mutex_lock (&mutex); if (!singleton) singleton = nm_dhcp_manager_new (); g_object_ref (singleton); - g_static_mutex_unlock (&mutex); return singleton; } diff --git a/system-settings/plugins/ifcfg-fedora/plugin.c b/system-settings/plugins/ifcfg-fedora/plugin.c index e8dde7ebe..75dd32f10 100644 --- a/system-settings/plugins/ifcfg-fedora/plugin.c +++ b/system-settings/plugins/ifcfg-fedora/plugin.c @@ -989,14 +989,12 @@ system_config_interface_init (NMSystemConfigInterface *system_config_interface_c G_MODULE_EXPORT GObject * nm_system_config_factory (void) { - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; static SCPluginIfcfg *singleton = NULL; - g_static_mutex_lock (&mutex); if (!singleton) singleton = SC_PLUGIN_IFCFG (g_object_new (SC_TYPE_PLUGIN_IFCFG, NULL)); - g_object_ref (singleton); - g_static_mutex_unlock (&mutex); + else + g_object_ref (singleton); return G_OBJECT (singleton); } diff --git a/system-settings/plugins/ifcfg-suse/plugin.c b/system-settings/plugins/ifcfg-suse/plugin.c index 4ed5f86c5..fa278ba24 100644 --- a/system-settings/plugins/ifcfg-suse/plugin.c +++ b/system-settings/plugins/ifcfg-suse/plugin.c @@ -425,14 +425,12 @@ system_config_interface_init (NMSystemConfigInterface *system_config_interface_c G_MODULE_EXPORT GObject * nm_system_config_factory (void) { - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; static SCPluginIfcfg *singleton = NULL; - g_static_mutex_lock (&mutex); if (!singleton) singleton = SC_PLUGIN_IFCFG (g_object_new (SC_TYPE_PLUGIN_IFCFG, NULL)); - g_object_ref (singleton); - g_static_mutex_unlock (&mutex); + else + g_object_ref (singleton); return G_OBJECT (singleton); } diff --git a/system-settings/src/nm-system-config-hal-manager.c b/system-settings/src/nm-system-config-hal-manager.c index e0004a0fd..ce05d2033 100644 --- a/system-settings/src/nm-system-config-hal-manager.c +++ b/system-settings/src/nm-system-config-hal-manager.c @@ -260,15 +260,12 @@ nm_system_config_hal_manager_new (DBusGConnection *g_connection) NMSystemConfigHalManager * nm_system_config_hal_manager_get (DBusGConnection *g_connection) { - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; static NMSystemConfigHalManager *singleton = NULL; - g_static_mutex_lock (&mutex); if (!singleton) singleton = nm_system_config_hal_manager_new (g_connection); else g_object_ref (singleton); - g_static_mutex_unlock (&mutex); return singleton; }