[gnome-color-manager] Protect gcm_client_remove_device_internal() with a mutex to try and fix a libsane-related segfault



commit 06cd5a0ab254268ea5ab1be21dd1403f8fdd007e
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jun 14 09:54:10 2010 +0100

    Protect gcm_client_remove_device_internal() with a mutex to try and fix a libsane-related segfault

 src/gcm-client.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/src/gcm-client.c b/src/gcm-client.c
index 06b5f2c..5abbfd7 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -264,10 +264,14 @@ gcm_client_remove_device_internal (GcmClient *client, GcmDevice *device, gboolea
 {
 	gboolean ret = FALSE;
 	const gchar *device_id;
+	static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
 
 	g_return_val_if_fail (GCM_IS_CLIENT (client), FALSE);
 	g_return_val_if_fail (GCM_IS_DEVICE (device), FALSE);
 
+	/* lock */
+	g_static_mutex_lock (&mutex);
+
 	/* check device is not connected */
 	device_id = gcm_device_get_id (device);
 	if (gcm_device_get_connected (device)) {
@@ -291,6 +295,9 @@ gcm_client_remove_device_internal (GcmClient *client, GcmDevice *device, gboolea
 		g_signal_emit (client, signals[SIGNAL_REMOVED], 0, device);
 	}
 out:
+	/* unlock */
+	g_static_mutex_unlock (&mutex);
+
 	return ret;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]