2005-02-02 Dan Williams <dcbw@redhat.com>
* src/NetworkManagerAPList.c - (nm_ap_list_merge_scanned_ap): merge strength too * src/NetworkManagerUtils.c - (nm_lock_mutex, nm_register_mutex_desc): new calls to facilitate debugging of locking issues by printing out prettier information than g_mutex_lock - Print out names of mutexes registered with nm_register_mutex_desc() - (nm_try_lock_mutex): don't do the waiting thing when trying to lock, causes us to seemingly block here for too long * src/NetworkManager.c src/NetworkManagerAPList.c src/NetworkManagerDevice.c - Convert to using nm_lock_mutex/nm_unlock_mutex rather than the glib variants so we get better debug information printed * src/NetworkManagerDbus.c - (nm_dbus_devices_handle_request): reduce usage of nm_device_need_ap_switch() since it sometimes has locking side effects - (nm_device_get_association_pause_value): Reduce 802.11a card pause value to 8s from 10s - (nm_device_need_ap_switch): If we can't acquire the scan lock, return saying we don't need a switch. This gets called often enough that we can't block until the scan mutex is acquired, because we'll block on device activation and a few other things, which hangs main thread for too long. * src/NetworkManagerPolicy.c - (nm_policy_auto_get_best_device): reduce the possiblity that nm_device_need_ap_switch() will be called git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@407 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
@@ -30,7 +30,50 @@
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
|
||||
/*#define LOCKING_DEBUG */
|
||||
typedef struct MutexDesc
|
||||
{
|
||||
GMutex *mutex;
|
||||
char *desc;
|
||||
} MutexDesc;
|
||||
|
||||
GSList *mutex_descs = NULL;
|
||||
|
||||
/*#define LOCKING_DEBUG*/
|
||||
|
||||
|
||||
static MutexDesc *nm_find_mutex_desc (GMutex *mutex)
|
||||
{
|
||||
GSList *elt;
|
||||
gboolean found = FALSE;
|
||||
|
||||
for (elt = mutex_descs; elt; elt = g_slist_next (elt))
|
||||
{
|
||||
MutexDesc *desc = (MutexDesc *)(elt->data);
|
||||
if (desc && (desc->mutex == mutex))
|
||||
return desc;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_register_mutex_desc
|
||||
*
|
||||
* Associate a description with a particular mutex.
|
||||
*
|
||||
*/
|
||||
void nm_register_mutex_desc (GMutex *mutex, char *string)
|
||||
{
|
||||
if (!(nm_find_mutex_desc (mutex)))
|
||||
{
|
||||
MutexDesc *desc = g_malloc0 (sizeof (MutexDesc));
|
||||
desc->mutex = mutex;
|
||||
desc->desc = g_strdup (string);
|
||||
mutex_descs = g_slist_append (mutex_descs, desc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_try_acquire_mutex
|
||||
@@ -42,30 +85,50 @@
|
||||
*/
|
||||
gboolean nm_try_acquire_mutex (GMutex *mutex, const char *func)
|
||||
{
|
||||
gint i = 5;
|
||||
|
||||
g_return_val_if_fail (mutex != NULL, FALSE);
|
||||
|
||||
while (i > 0)
|
||||
if (g_mutex_trylock (mutex))
|
||||
{
|
||||
if (g_mutex_trylock (mutex))
|
||||
{
|
||||
#ifdef LOCKING_DEBUG
|
||||
if (func) syslog (LOG_DEBUG, "MUTEX: %s got mutex 0x%X", func, mutex);
|
||||
#endif
|
||||
return (TRUE);
|
||||
if (func)
|
||||
{
|
||||
MutexDesc *desc = nm_find_mutex_desc (mutex);
|
||||
syslog (LOG_DEBUG, "MUTEX: <%s %p> acquired by %s", desc ? desc->desc : "(none)", mutex, func);
|
||||
}
|
||||
g_usleep (G_USEC_PER_SEC / 2);
|
||||
i++;
|
||||
#endif
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#ifdef LOCKING_DEBUG
|
||||
if (func) syslog (LOG_DEBUG, "MUTEX: %s FAILED to get mutex 0x%X", func, mutex);
|
||||
if (func)
|
||||
{
|
||||
MutexDesc *desc = nm_find_mutex_desc (mutex);
|
||||
syslog (LOG_DEBUG, "MUTEX: <%s %p> FAILED to be acquired by %s", desc ? desc->desc : "(none)", mutex, func);
|
||||
}
|
||||
#endif
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_lock_mutex
|
||||
*
|
||||
* Blocks until a mutex is grabbed, with debugging.
|
||||
*
|
||||
*/
|
||||
void nm_lock_mutex (GMutex *mutex, const char *func)
|
||||
{
|
||||
#ifdef LOCKING_DEBUG
|
||||
if (func)
|
||||
{
|
||||
MutexDesc *desc = nm_find_mutex_desc (mutex);
|
||||
syslog (LOG_DEBUG, "MUTEX: <%s %p> being acquired by %s", desc ? desc->desc : "(none)", mutex, func);
|
||||
}
|
||||
#endif
|
||||
g_mutex_lock (mutex);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_unlock_mutex
|
||||
*
|
||||
@@ -77,7 +140,11 @@ void nm_unlock_mutex (GMutex *mutex, const char *func)
|
||||
g_return_if_fail (mutex != NULL);
|
||||
|
||||
#ifdef LOCKING_DEBUG
|
||||
if (func) syslog (LOG_DEBUG, "MUTEX: %s released mutex 0x%X", func, mutex);
|
||||
if (func)
|
||||
{
|
||||
MutexDesc *desc = nm_find_mutex_desc (mutex);
|
||||
syslog (LOG_DEBUG, "MUTEX: <%s %p> released by %s", desc ? desc->desc : "(none)", mutex, func);
|
||||
}
|
||||
#endif
|
||||
|
||||
g_mutex_unlock (mutex);
|
||||
|
Reference in New Issue
Block a user