rhythmbox r6072 - in trunk: . rhythmdb
- From: jmatthew svn gnome org
- To: svn-commits-list gnome org
- Subject: rhythmbox r6072 - in trunk: . rhythmdb
- Date: Fri, 21 Nov 2008 11:55:32 +0000 (UTC)
Author: jmatthew
Date: Fri Nov 21 11:55:32 2008
New Revision: 6072
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=6072&view=rev
Log:
2008-11-21 Jonathan Matthew <jonathan d14n org>
* rhythmdb/rhythmdb-monitor.c: (rhythmdb_init_monitoring),
(rhythmdb_finalize_monitoring), (actually_add_monitor),
(rhythmdb_process_changed_files):
Add a mutex around the monitored directory map because it can be
accessed from multiple threads. Probably fixes #484611.
Modified:
trunk/ChangeLog
trunk/rhythmdb/rhythmdb-monitor.c
Modified: trunk/rhythmdb/rhythmdb-monitor.c
==============================================================================
--- trunk/rhythmdb/rhythmdb-monitor.c (original)
+++ trunk/rhythmdb/rhythmdb-monitor.c Fri Nov 21 11:55:32 2008
@@ -61,6 +61,8 @@
void
rhythmdb_init_monitoring (RhythmDB *db)
{
+ db->priv->monitor_mutex = g_mutex_new ();
+
db->priv->monitored_directories = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal,
(GDestroyNotify) g_object_unref,
(GDestroyNotify)g_file_monitor_cancel);
@@ -106,6 +108,8 @@
g_hash_table_destroy (db->priv->monitored_directories);
g_hash_table_destroy (db->priv->changed_files);
+
+ g_mutex_free (db->priv->monitor_mutex);
}
void
@@ -126,7 +130,10 @@
return;
}
+ g_mutex_lock (db->priv->monitor_mutex);
+
if (g_hash_table_lookup (db->priv->monitored_directories, directory)) {
+ g_mutex_unlock (db->priv->monitor_mutex);
return;
}
@@ -141,6 +148,8 @@
g_object_ref (directory),
monitor);
}
+
+ g_mutex_unlock (db->priv->monitor_mutex);
}
static void
@@ -228,6 +237,11 @@
static gboolean
rhythmdb_process_changed_files (RhythmDB *db)
{
+ /*
+ * no need for a mutex around the changed files map as it's only accessed
+ * from the main thread. GFileMonitor's 'changed' signal is emitted from an
+ * idle handler, and we only process the map in a timeout callback.
+ */
if (g_hash_table_size (db->priv->changed_files) == 0) {
db->priv->changed_files_id = 0;
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]