2008-04-08 Dan Williams <dcbw@redhat.com>

* 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



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3548 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2008-04-08 21:15:45 +00:00
parent 48ef109007
commit 9a49506152
8 changed files with 24 additions and 39 deletions

View file

@ -1,3 +1,15 @@
2008-04-08 Dan Williams <dcbw@redhat.com>
* 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 <dcbw@redhat.com>
* system-settings/src/main.c

View file

@ -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;
}

View file

@ -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);

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;
}