From a33aac1132ed5061f7ce694a318d1b46a7e3a932 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 30 Jun 2008 07:04:28 +0200 Subject: [PATCH] Use read/write lock for driver list instead of a mutex --- src/element.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/element.c b/src/element.c index 93ae5d1..fa06da0 100644 --- a/src/element.c +++ b/src/element.c @@ -32,7 +32,7 @@ static DBusConnection *connection; -static GStaticMutex driver_mutex = G_STATIC_MUTEX_INIT; +static GStaticRWLock driver_lock = G_STATIC_RW_LOCK_INIT; static GSList *driver_list = NULL; static GThreadPool *driver_thread; @@ -247,10 +247,10 @@ int connman_driver_register(struct connman_driver *driver) if (!driver->probe) return -EINVAL; - g_static_mutex_lock(&driver_mutex); + g_static_rw_lock_writer_lock(&driver_lock); driver_list = g_slist_insert_sorted(driver_list, driver, compare_priority); - g_static_mutex_unlock(&driver_mutex); + g_static_rw_lock_writer_unlock(&driver_lock); g_thread_pool_push(driver_thread, driver, NULL); @@ -282,9 +282,9 @@ void connman_driver_unregister(struct connman_driver *driver) remove_driver, driver); g_static_mutex_unlock(&element_mutex); - g_static_mutex_lock(&driver_mutex); + g_static_rw_lock_writer_lock(&driver_lock); driver_list = g_slist_remove(driver_list, driver); - g_static_mutex_unlock(&driver_mutex); + g_static_rw_lock_writer_unlock(&driver_lock); } struct connman_element *connman_element_create(void) @@ -633,7 +633,7 @@ static void element_probe(gpointer data, gpointer user_data) if (connman_element_ref(element) == NULL) return; - g_static_mutex_lock(&driver_mutex); + g_static_rw_lock_reader_lock(&driver_lock); for (list = driver_list; list; list = list->next) { struct connman_driver *driver = list->data; @@ -649,7 +649,7 @@ static void element_probe(gpointer data, gpointer user_data) set_driver(element, NULL); } - g_static_mutex_unlock(&driver_mutex); + g_static_rw_lock_reader_unlock(&driver_lock); connman_element_unref(element); } -- 2.7.4