gvfs r2290 - in trunk: . monitor/hal



Author: alexl
Date: Thu Mar  5 17:27:40 2009
New Revision: 2290
URL: http://svn.gnome.org/viewvc/gvfs?rev=2290&view=rev

Log:
2009-03-05  Alexander Larsson  <alexl redhat com>

        * monitor/hal/ghaldrive.c:
        * monitor/hal/ghalmount.c:
        * monitor/hal/ghalvolume.c:
        * monitor/hal/ghalvolumemonitor.c:
	Remove all locking (not needed since we're now
	a single threaded process).
	Don't emit signals in idle, thus risking callback
	reordering. We don't need this anymore as it was
	part of the locking structure.

	This should fix the "No mount object for mounted
	volume" error when mounting.




Modified:
   trunk/ChangeLog
   trunk/monitor/hal/ghaldrive.c
   trunk/monitor/hal/ghalmount.c
   trunk/monitor/hal/ghalvolume.c
   trunk/monitor/hal/ghalvolumemonitor.c

Modified: trunk/monitor/hal/ghaldrive.c
==============================================================================
--- trunk/monitor/hal/ghaldrive.c	(original)
+++ trunk/monitor/hal/ghaldrive.c	Thu Mar  5 17:27:40 2009
@@ -33,9 +33,6 @@
 #include "ghaldrive.h"
 #include "ghalvolume.h"
 
-/* Protects all fields of GHalDrive that can change */
-G_LOCK_DEFINE_STATIC(hal_drive);
-
 struct _GHalDrive {
   GObject parent;
 
@@ -300,17 +297,12 @@
     }
 }
 
-static gboolean
-changed_in_idle (gpointer data)
+static void
+emit_drive_changed (GHalDrive *drive)
 {
-  GHalDrive *drive = data;
-  
   g_signal_emit_by_name (drive, "changed");
   if (drive->volume_monitor != NULL)
     g_signal_emit_by_name (drive->volume_monitor, "drive_changed", drive);
-  g_object_unref (drive);
-  
-  return FALSE;
 }
 
 static void
@@ -324,8 +316,6 @@
   gboolean old_can_poll_for_media;
   gboolean old_can_eject;
 
-  G_LOCK (hal_drive);
-  
   old_name = g_strdup (d->name);
   old_icon = g_strdup (d->icon);
   old_uses_removable_media = d->uses_removable_media;
@@ -348,12 +338,10 @@
        old_icon == NULL ||
        strcmp (old_name, d->name) != 0 ||
        strcmp (old_icon, d->icon) != 0))
-      g_idle_add (changed_in_idle, g_object_ref (d));
+    emit_drive_changed (d);
   
   g_free (old_name);
   g_free (old_icon);
-
-  G_UNLOCK (hal_drive);
 }
 
 static void
@@ -409,10 +397,8 @@
 {
   GList *l, *volumes;
 
-  G_LOCK (hal_drive);
   volumes = drive->volumes;
   drive->volumes = NULL;
-  G_UNLOCK (hal_drive);
   
   for (l = volumes; l != NULL; l = l->next)
     {
@@ -428,15 +414,11 @@
                         GHalVolume *volume)
 {
 
-  G_LOCK (hal_drive);
-  
   if (g_list_find (drive->volumes, volume) == NULL)
     {
       drive->volumes = g_list_prepend (drive->volumes, volume);
-      g_idle_add (changed_in_idle, g_object_ref (drive));
+      emit_drive_changed (drive);
     }
-
-  G_UNLOCK (hal_drive);
 }
 
 void 
@@ -445,17 +427,13 @@
 {
   GList *l;
 
-  G_LOCK (hal_drive);
-  
   l = g_list_find (drive->volumes, volume);
   if (l != NULL)
     {
       drive->volumes = g_list_delete_link (drive->volumes, l);
 
-      g_idle_add (changed_in_idle, g_object_ref (drive));
+      emit_drive_changed (drive);
     }
-  
-  G_UNLOCK (hal_drive);
 }
 
 gboolean 
@@ -463,9 +441,7 @@
 {
   gboolean res;
   
-  G_LOCK (hal_drive);
   res = strcmp (udi, hal_device_get_udi (drive->device)) == 0;
-  G_UNLOCK (hal_drive);
 
   return res;
 }
@@ -476,9 +452,7 @@
   GHalDrive *hal_drive = G_HAL_DRIVE (drive);
   GIcon *icon;
 
-  G_LOCK (hal_drive);
   icon = g_themed_icon_new_with_default_fallbacks (hal_drive->icon);
-  G_UNLOCK (hal_drive);
   
   return icon; 
 }
@@ -489,9 +463,7 @@
   GHalDrive *hal_drive = G_HAL_DRIVE (drive);
   char *name;
 
-  G_LOCK (hal_drive);
   name = g_strdup (hal_drive->name);
-  G_UNLOCK (hal_drive);
   
   return name;
 }
@@ -502,10 +474,8 @@
   GHalDrive *hal_drive = G_HAL_DRIVE (drive);
   GList *l;
 
-  G_LOCK (hal_drive);
   l = g_list_copy (hal_drive->volumes);
   g_list_foreach (l, (GFunc) g_object_ref, NULL);
-  G_UNLOCK (hal_drive);
 
   return l;
 }
@@ -514,52 +484,32 @@
 g_hal_drive_has_volumes (GDrive *drive)
 {
   GHalDrive *hal_drive = G_HAL_DRIVE (drive);
-  gboolean res;
 
-  G_LOCK (hal_drive);
-  res = hal_drive->volumes != NULL;
-  G_UNLOCK (hal_drive);
-  
-  return res;
+  return hal_drive->volumes != NULL;
 }
 
 static gboolean
 g_hal_drive_is_media_removable (GDrive *drive)
 {
   GHalDrive *hal_drive = G_HAL_DRIVE (drive);
-  gboolean res;
 
-  G_LOCK (hal_drive);
-  res = hal_drive->uses_removable_media;
-  G_UNLOCK (hal_drive);
-  
-  return res;
+  return hal_drive->uses_removable_media;
 }
 
 static gboolean
 g_hal_drive_has_media (GDrive *drive)
 {
   GHalDrive *hal_drive = G_HAL_DRIVE (drive);
-  gboolean res;
 
-  G_LOCK (hal_drive);
-  res = hal_drive->has_media;
-  G_UNLOCK (hal_drive);
-  
-  return res;
+  return hal_drive->has_media;
 }
 
 static gboolean
 g_hal_drive_is_media_check_automatic (GDrive *drive)
 {
   GHalDrive *hal_drive = G_HAL_DRIVE (drive);
-  gboolean res;
 
-  G_LOCK (hal_drive);
-  res = hal_drive->is_media_check_automatic;
-  G_UNLOCK (hal_drive);
-  
-  return res;
+  return hal_drive->is_media_check_automatic;
 }
 
 static gboolean
@@ -568,24 +518,15 @@
   GHalDrive *hal_drive = G_HAL_DRIVE (drive);
   gboolean res;
   
-  G_LOCK (hal_drive);
-  res = hal_drive->can_eject;
-  G_UNLOCK (hal_drive);
-
-  return res;
+  return hal_drive->can_eject;
 }
 
 static gboolean
 g_hal_drive_can_poll_for_media (GDrive *drive)
 {
   GHalDrive *hal_drive = G_HAL_DRIVE (drive);
-  gboolean res;
   
-  G_LOCK (hal_drive);
-  res = hal_drive->can_poll_for_media;
-  G_UNLOCK (hal_drive);
-
-  return res;
+  return hal_drive->can_poll_for_media;
 }
 
 typedef struct {
@@ -639,9 +580,7 @@
   GError *error;
   char *argv[] = {"gnome-mount", "-e", "-b", "-d", NULL, NULL};
 
-  G_LOCK (hal_drive);
   argv[4] = g_strdup (hal_drive->device_path);
-  G_UNLOCK (hal_drive);
   
   data = g_new0 (SpawnOp, 1);
   data->object = g_object_ref (drive);
@@ -799,7 +738,6 @@
   data->user_data = user_data;
   data->flags = flags;
 
-  G_LOCK (hal_drive);
   for (l = hal_drive->volumes; l != NULL; l = l->next)
     {
       GHalVolume *volume = l->data;
@@ -809,7 +747,6 @@
       if (mount != NULL && g_mount_can_unmount (mount))
         data->pending_mounts = g_list_prepend (data->pending_mounts, g_object_ref (mount));
     }
-  G_UNLOCK (hal_drive);
 
   _eject_unmount_mounts (data);
 }
@@ -897,13 +834,11 @@
 
   /*g_warning ("Rescanning udi %s", hal_device_get_udi (hal_drive->device));*/
 
-  G_LOCK (hal_drive);
   con = hal_pool_get_dbus_connection (hal_drive->pool);
   msg = dbus_message_new_method_call ("org.freedesktop.Hal",
                                       hal_device_get_udi (hal_drive->device),
                                       "org.freedesktop.Hal.Device.Storage.Removable",
                                       "CheckForMedia");
-  G_UNLOCK (hal_drive);
 
   if (!dbus_connection_send_with_reply (con, msg, &pending_call, -1))
     {
@@ -949,16 +884,12 @@
 
   res = NULL;
 
-  G_LOCK (hal_drive);
-  
   if (strcmp (kind, G_VOLUME_IDENTIFIER_KIND_HAL_UDI) == 0)
     res = g_strdup (hal_device_get_udi (hal_drive->device));
   
   if (strcmp (kind, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE) == 0)
     res = g_strdup (hal_drive->device_path);
   
-  G_UNLOCK (hal_drive);
-  
   return res;
 }
 
@@ -970,8 +901,6 @@
 
   res = g_ptr_array_new ();
 
-  G_LOCK (hal_drive);
-  
   g_ptr_array_add (res,
                    g_strdup (G_VOLUME_IDENTIFIER_KIND_HAL_UDI));
 
@@ -979,8 +908,6 @@
     g_ptr_array_add (res,
                      g_strdup (G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE));
     
-
-  G_UNLOCK (hal_drive);
   
   /* Null-terminate */
   g_ptr_array_add (res, NULL);

Modified: trunk/monitor/hal/ghalmount.c
==============================================================================
--- trunk/monitor/hal/ghalmount.c	(original)
+++ trunk/monitor/hal/ghalmount.c	Thu Mar  5 17:27:40 2009
@@ -39,9 +39,6 @@
 
 #include "hal-utils.h"
 
-/* Protects all fields of GHalDrive that can change */
-G_LOCK_DEFINE_STATIC(hal_mount);
-
 struct _GHalMount {
   GObject parent;
 
@@ -138,17 +135,12 @@
 {
 }
 
-static gboolean
-changed_in_idle (gpointer data)
+static void
+emit_mount_changed (GHalMount *mount)
 {
-  GHalMount *mount = data;
-  
   g_signal_emit_by_name (mount, "changed");
   if (mount->volume_monitor != NULL)
     g_signal_emit_by_name (mount->volume_monitor, "mount_changed", mount);
-  g_object_unref (mount);
-  
-  return FALSE;
 }
 
 #define KILOBYTE_FACTOR 1000.0
@@ -404,8 +396,6 @@
   char *old_name;
   GIcon *old_icon;
 
-  G_LOCK (hal_mount);
-  
   old_name = g_strdup (m->name);
   old_icon = m->icon != NULL ? g_object_ref (m->icon) : NULL;
 
@@ -420,13 +410,11 @@
           old_icon == NULL ||
           strcmp (old_name, m->name) != 0 ||
           (! g_icon_equal (old_icon, m->icon)))
-        g_idle_add (changed_in_idle, g_object_ref (m));
+        emit_mount_changed (m);
     }
   g_free (old_name);
   if (old_icon != NULL)
     g_object_unref (old_icon);
-
-  G_UNLOCK (hal_mount);
 }
 
 static void
@@ -519,8 +507,6 @@
 void 
 g_hal_mount_override_name (GHalMount *mount, const char *name)
 {
-  G_LOCK (hal_mount);
-  
   g_free (mount->override_name);
 
   if (name != NULL)
@@ -528,15 +514,12 @@
   else
     mount->override_name = NULL;
   
-  G_UNLOCK (hal_mount);
-
   update_from_hal (mount, TRUE);
 }
 
 void
 g_hal_mount_override_icon (GHalMount *mount, GIcon *icon)
 {
-  G_LOCK (hal_mount);
   if (mount->override_icon != NULL)
     g_object_unref (mount->override_icon);
 
@@ -545,8 +528,6 @@
   else
     mount->override_icon = NULL;
 
-  G_UNLOCK (hal_mount);
-  
   update_from_hal (mount, TRUE);
 }
 
@@ -634,27 +615,23 @@
 void
 g_hal_mount_unmounted (GHalMount *mount)
 {
-  G_LOCK (hal_mount);
   if (mount->volume != NULL)
     {
       g_hal_volume_unset_mount (mount->volume, mount);
       mount->volume = NULL;
-      g_idle_add (changed_in_idle, g_object_ref (mount));
+      emit_mount_changed (mount);
     }
-  G_UNLOCK (hal_mount);
 }
 
 void
 g_hal_mount_unset_volume (GHalMount *mount,
                                        GHalVolume  *volume)
 {
-  G_LOCK (hal_mount);
   if (mount->volume == volume)
     {
       mount->volume = NULL;
-      g_idle_add (changed_in_idle, g_object_ref (mount));
+      emit_mount_changed (mount);
     }
-  G_UNLOCK (hal_mount);
 }
 
 static GFile *
@@ -670,52 +647,32 @@
 g_hal_mount_get_root (GMount *mount)
 {
   GHalMount *hal_mount = G_HAL_MOUNT (mount);
-  GFile *root;
-
-  G_LOCK (hal_mount);
-  root = get_root (hal_mount);
-  G_UNLOCK (hal_mount);
-
-  return root;
+  
+  return get_root (hal_mount);
 }
 
 static GIcon *
 g_hal_mount_get_icon (GMount *mount)
 {
   GHalMount *hal_mount = G_HAL_MOUNT (mount);
-  GIcon *icon;
 
-  G_LOCK (hal_mount);
-  icon = g_object_ref (hal_mount->icon);
-  G_UNLOCK (hal_mount);
-  
-  return icon;
+  return g_object_ref (hal_mount->icon);
 }
 
 static char *
 g_hal_mount_get_uuid (GMount *mount)
 {
   GHalMount *hal_mount = G_HAL_MOUNT (mount);
-  char *uuid;
 
-  G_LOCK (hal_mount);
-  uuid = g_strdup (hal_mount->uuid);
-  G_UNLOCK (hal_mount);
-  
-  return uuid;
+  return g_strdup (hal_mount->uuid);
 }
 
 static char *
 g_hal_mount_get_name (GMount *mount)
 {
   GHalMount *hal_mount = G_HAL_MOUNT (mount);
-  char *name;
-
-  G_LOCK (hal_mount);
-  name = g_strdup (hal_mount->name);
-  G_UNLOCK (hal_mount);
   
-  return name;
+  return g_strdup (hal_mount->name);
 }
 
 gboolean
@@ -724,11 +681,9 @@
 {
   gboolean res;
 
-  G_LOCK (hal_mount);
   res = FALSE;
   if (mount->uuid != NULL)
     res = strcmp (mount->uuid, uuid) == 0;
-  G_UNLOCK (hal_mount);
 
   return res;
 }
@@ -737,12 +692,7 @@
 g_hal_mount_has_mount_path (GHalMount *mount,
                             const char  *mount_path)
 {
-  gboolean res;
-
-  G_LOCK (hal_mount);
-  res = strcmp (mount->mount_path, mount_path) == 0;
-  G_UNLOCK (hal_mount);
-  return res;
+  return strcmp (mount->mount_path, mount_path) == 0;
 }
 
 gboolean
@@ -751,11 +701,9 @@
 {
   gboolean res;
 
-  G_LOCK (hal_mount);
   res = FALSE;
   if (mount->device != NULL)
     res = strcmp (hal_device_get_udi (mount->device), udi) == 0;
-  G_UNLOCK (hal_mount);
 
   return res;
 }
@@ -766,11 +714,9 @@
   GHalMount *hal_mount = G_HAL_MOUNT (mount);
   GDrive *drive;
 
-  G_LOCK (hal_mount);
   drive = NULL;
   if (hal_mount->volume != NULL)
     drive = g_volume_get_drive (G_VOLUME (hal_mount->volume));
-  G_UNLOCK (hal_mount);
 
   return drive;
 }
@@ -781,11 +727,9 @@
   GHalMount *hal_mount = G_HAL_MOUNT (mount);
   GVolume *volume;
 
-  G_LOCK (hal_mount);
   volume = NULL;
   if (hal_mount->volume)
     volume = G_VOLUME (g_object_ref (hal_mount->volume));
-  G_UNLOCK (hal_mount);
   
   return volume;
 }
@@ -796,11 +740,9 @@
   GHalMount *hal_mount = G_HAL_MOUNT (mount);
   gboolean res;
 
-  G_LOCK (hal_mount);
   res = TRUE;
   if (hal_mount->cannot_unmount)
     res = FALSE;
-  G_UNLOCK (hal_mount);
 
   return res;
 }
@@ -812,7 +754,6 @@
   GDrive *drive;
   gboolean can_eject;
 
-  G_LOCK (hal_mount);
   can_eject = FALSE;
   if (hal_mount->volume != NULL)
     {
@@ -820,7 +761,6 @@
       if (drive != NULL)
         can_eject = g_drive_can_eject (drive);
     }
-  G_UNLOCK (hal_mount);
 
   return can_eject;
 }
@@ -968,11 +908,8 @@
   gboolean using_legacy = FALSE;
   char *d, *m;
 
-  G_LOCK (hal_mount);
   d = g_strdup (hal_mount->device_path);
   m = g_strdup (hal_mount->mount_path);
-  G_UNLOCK (hal_mount);
-
   
   if (hal_mount->device != NULL)
     argv[4] = d;
@@ -1024,11 +961,9 @@
   GHalMount *hal_mount = G_HAL_MOUNT (mount);
   GDrive *drive;
 
-  G_LOCK (hal_mount);
   drive = NULL;
   if (hal_mount->volume != NULL)
     drive = g_volume_get_drive (G_VOLUME (hal_mount->volume));
-  G_UNLOCK (hal_mount);
   
   if (drive != NULL)
     {
@@ -1053,11 +988,9 @@
 
   res = TRUE;
   
-  G_LOCK (hal_mount);
   drive = NULL;
   if (hal_mount->volume != NULL)
     drive = g_volume_get_drive (G_VOLUME (hal_mount->volume));
-  G_UNLOCK (hal_mount);
   
   if (drive != NULL)
     {
@@ -1086,8 +1019,6 @@
 
   p = g_ptr_array_new ();
 
-  G_LOCK (hal_mount);
-
   root = get_root (hal_mount);
   uri = g_file_get_uri (root);
   if (g_str_has_prefix (uri, "burn://"))
@@ -1149,8 +1080,6 @@
       result = (char **) g_ptr_array_free (p, FALSE);
     }
 
-  G_UNLOCK (hal_mount);
-
   return result;
 }
 

Modified: trunk/monitor/hal/ghalvolume.c
==============================================================================
--- trunk/monitor/hal/ghalvolume.c	(original)
+++ trunk/monitor/hal/ghalvolume.c	Thu Mar  5 17:27:40 2009
@@ -36,9 +36,6 @@
 
 #include "hal-utils.h"
 
-/* Protects all fields of GHalDrive that can change */
-G_LOCK_DEFINE_STATIC(hal_volume);
-
 struct _GHalVolume {
   GObject parent;
 
@@ -123,17 +120,12 @@
 {
 }
 
-static gboolean
-changed_in_idle (gpointer data)
+static void
+emit_volume_changed (GHalVolume *volume)
 {
-  GHalVolume *volume = data;
-  
   g_signal_emit_by_name (volume, "changed");
   if (volume->volume_monitor != NULL)
     g_signal_emit_by_name (volume->volume_monitor, "volume_changed", volume);
-  g_object_unref (volume);
-  
-  return FALSE;
 }
 
 #define KILOBYTE_FACTOR 1000.0
@@ -300,8 +292,6 @@
   char *old_icon;
   char *old_mount_path;
 
-  G_LOCK (hal_volume);
-  
   old_name = g_strdup (mv->name);
   old_icon = g_strdup (mv->icon);
   old_mount_path = g_strdup (mv->mount_path);
@@ -327,13 +317,11 @@
            old_icon == NULL ||
            strcmp (old_name, mv->name) != 0 ||
            strcmp (old_icon, mv->icon) != 0))
-        g_idle_add (changed_in_idle, g_object_ref (mv));
+	emit_volume_changed (mv);
     }
   g_free (old_name);
   g_free (old_icon);
   g_free (old_mount_path);
-
-  G_UNLOCK (hal_volume);
 }
 
 static void
@@ -439,8 +427,6 @@
 g_hal_volume_removed (GHalVolume *volume)
 {
 
-  G_LOCK (hal_volume);
-  
   if (volume->mount != NULL)
     {
       g_hal_mount_unset_volume (volume->mount, volume);
@@ -452,15 +438,12 @@
       g_hal_drive_unset_volume (volume->drive, volume);
       volume->drive = NULL;
     }
-
-  G_UNLOCK (hal_volume);
 }
 
 void
 g_hal_volume_set_mount (GHalVolume  *volume,
                         GHalMount *mount)
 {
-  G_LOCK (hal_volume);
   if (volume->mount != mount)
     {
       
@@ -469,29 +452,25 @@
       
       volume->mount = mount;
 
-      g_idle_add (changed_in_idle, g_object_ref (volume));
+      emit_volume_changed (volume);
     }
-  G_UNLOCK (hal_volume);
 }
  
 void
 g_hal_volume_unset_mount (GHalVolume  *volume,
                           GHalMount *mount)
 {
-  G_LOCK (hal_volume);
   if (volume->mount == mount)
     {
       volume->mount = NULL;
-      g_idle_add (changed_in_idle, g_object_ref (volume));
+      emit_volume_changed (volume);
     }
-  G_UNLOCK (hal_volume);
 }
 
 void
 g_hal_volume_set_drive (GHalVolume  *volume,
                         GHalDrive *drive)
 {
-  G_LOCK (hal_volume);
   if (volume->drive != drive)
     {
       if (volume->drive != NULL)
@@ -499,22 +478,19 @@
       
       volume->drive = drive;
       
-      g_idle_add (changed_in_idle, g_object_ref (volume));
+      emit_volume_changed (volume);
     }
-  G_UNLOCK (hal_volume);
 }
 
 void
 g_hal_volume_unset_drive (GHalVolume  *volume,
                           GHalDrive *drive)
 {
-  G_LOCK (hal_volume);
   if (volume->drive == drive)
     {
       volume->drive = NULL;
-      g_idle_add (changed_in_idle, g_object_ref (volume));
+      emit_volume_changed (volume);
     }
-  G_UNLOCK (hal_volume);
 }
 
 static GIcon *
@@ -525,7 +501,6 @@
   const char *name;
   const char *fallback;
 
-  G_LOCK (hal_volume);
   name = hal_volume->icon;
 
   if (hal_volume->icon_fallback)
@@ -534,7 +509,6 @@
     fallback = name;
 
   icon = get_themed_icon_with_fallbacks (name, fallback);
-  G_UNLOCK (hal_volume);
   return icon;
 }
 
@@ -542,39 +516,24 @@
 g_hal_volume_get_name (GVolume *volume)
 {
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
-  char *name;
 
-  G_LOCK (hal_volume);
-  name = g_strdup (hal_volume->name);
-  G_UNLOCK (hal_volume);
-  
-  return name;
+  return g_strdup (hal_volume->name);
 }
 
 static char *
 g_hal_volume_get_uuid (GVolume *volume)
 {
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
-  char *uuid;
 
-  G_LOCK (hal_volume);
-  uuid = g_strdup (hal_volume->uuid);
-  G_UNLOCK (hal_volume);
-  
-  return uuid;
+  return g_strdup (hal_volume->uuid);
 }
 
 static gboolean
 g_hal_volume_can_mount (GVolume *volume)
 {
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
-  gboolean res;
 
-  G_LOCK (hal_volume);
-  res = hal_volume->is_mountable;
-  G_UNLOCK (hal_volume);
-  
-  return res;
+  return hal_volume->is_mountable;
 }
 
 static gboolean
@@ -583,11 +542,9 @@
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
   gboolean res;
 
-  G_LOCK (hal_volume);
   res = FALSE;
   if (hal_volume->drive != NULL)
     res = g_drive_can_eject (G_DRIVE (hal_volume->drive));
-  G_UNLOCK (hal_volume);
   
   return res;
 }
@@ -596,13 +553,8 @@
 g_hal_volume_should_automount (GVolume *volume)
 {
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
-  gboolean res;
 
-  G_LOCK (hal_volume);
-  res = ! (hal_volume->ignore_automount);
-  G_UNLOCK (hal_volume);
-  
-  return res;
+  return  ! (hal_volume->ignore_automount);
 }
 
 static GDrive *
@@ -611,11 +563,9 @@
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
   GDrive *drive;
 
-  G_LOCK (hal_volume);
   drive = NULL;
   if (hal_volume->drive != NULL)
     drive = g_object_ref (hal_volume->drive);
-  G_UNLOCK (hal_volume);
   
   return drive;
 }
@@ -626,13 +576,11 @@
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
   GMount *mount;
 
-  G_LOCK (hal_volume);
   mount = NULL;
   if (hal_volume->foreign_mount != NULL)
     mount = g_object_ref (hal_volume->foreign_mount);
   else if (hal_volume->mount != NULL)
     mount = g_object_ref (hal_volume->mount);
-  G_UNLOCK (hal_volume);
 
   return mount;
 }
@@ -643,11 +591,9 @@
 {
   gboolean res;
 
-  G_LOCK (hal_volume);
   res = FALSE;
   if (volume->mount_path != NULL)
     res = strcmp (volume->mount_path, mount_path) == 0;
-  G_UNLOCK (hal_volume);
 
   return res;
 }
@@ -659,10 +605,8 @@
   gboolean res;
 
   res = FALSE;
-  G_LOCK (hal_volume);
   if (volume->device_path != NULL)
     res = strcmp (volume->device_path, device_path) == 0;
-  G_UNLOCK (hal_volume);
   return res;
 }
 
@@ -673,11 +617,9 @@
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
   gboolean res;
   
-  G_LOCK (hal_volume);
   res = FALSE;
   if (hal_volume->device != NULL)
     res = strcmp (hal_device_get_udi (hal_volume->device), udi) == 0;
-  G_UNLOCK (hal_volume);
   return res;
 }
 
@@ -688,11 +630,9 @@
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
   gboolean res;
 
-  G_LOCK (hal_volume);
   res = FALSE;
   if (hal_volume->uuid != NULL)
     res = strcmp (hal_volume->uuid, uuid) == 0;
-  G_UNLOCK (hal_volume);
 
   return res;
 }
@@ -703,9 +643,7 @@
   GHalVolume *volume = G_HAL_VOLUME (user_data);
   gboolean check;
 
-  G_LOCK (hal_volume);
   check = volume->foreign_mount == mount;
-  G_UNLOCK (hal_volume);
   if (check)
     g_hal_volume_adopt_foreign_mount (volume, NULL);
 }
@@ -713,7 +651,6 @@
 void
 g_hal_volume_adopt_foreign_mount (GHalVolume *volume, GMount *foreign_mount)
 {
-  G_LOCK (hal_volume);
   if (volume->foreign_mount != NULL)
     g_object_unref (volume->foreign_mount);
 
@@ -724,9 +661,8 @@
     }
   else
     volume->foreign_mount =  NULL;
-
-  g_idle_add (changed_in_idle, g_object_ref (volume));
-  G_UNLOCK (hal_volume);
+  
+  emit_volume_changed (volume);
 }
 
 gboolean
@@ -736,11 +672,9 @@
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
   gboolean res;
 
-  G_LOCK (hal_volume);
   res = FALSE;
   if (hal_volume->foreign_mount_root != NULL)
     res = g_file_equal (hal_volume->foreign_mount_root, mount_root);
-  G_UNLOCK (hal_volume);
   
   return res;
 }
@@ -864,7 +798,6 @@
               hal_volume->foreign_mount_root,
               hal_volume->device_path);*/
 
-  G_LOCK (hal_volume);
   if (hal_volume->foreign_mount_root != NULL)
     {
       ForeignMountOp *data;
@@ -890,7 +823,6 @@
         argv[4] = "-n";
       spawn_do (volume, cancellable, callback, user_data, argv);
     }
-  G_UNLOCK (hal_volume);
 }
 
 static gboolean
@@ -901,14 +833,11 @@
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
   gboolean res;
 
-  G_LOCK (hal_volume);
   res = TRUE;
   
   if (hal_volume->foreign_mount_root != NULL)
     res = g_file_mount_enclosing_volume_finish (hal_volume->foreign_mount_root, result, error);
   
-  G_UNLOCK (hal_volume);
-  
   return res;
 }
 
@@ -942,10 +871,8 @@
   /*g_warning ("hal_volume_eject");*/
 
   drive = NULL;
-  G_LOCK (hal_volume);
   if (hal_volume->drive != NULL)
     drive = g_object_ref (hal_volume->drive);
-  G_UNLOCK (hal_volume);
 
   if (drive != NULL)
     {
@@ -967,11 +894,9 @@
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
   gboolean res;
 
-  G_LOCK (hal_volume);
   res = TRUE;
   if (hal_volume->drive != NULL)
     res = g_drive_eject_finish (G_DRIVE (hal_volume->drive), result, error);
-  G_UNLOCK (hal_volume);
   return res;
 }
 
@@ -982,7 +907,6 @@
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
   char *id;
 
-  G_LOCK (hal_volume);
   id = NULL;
   if (strcmp (kind, G_VOLUME_IDENTIFIER_KIND_HAL_UDI) == 0)
     id = g_strdup (hal_device_get_udi (hal_volume->device));
@@ -992,7 +916,6 @@
     id = g_strdup (hal_device_get_property_string (hal_volume->device, "volume.label"));
   else if (strcmp (kind, G_VOLUME_IDENTIFIER_KIND_UUID) == 0)
     id = g_strdup (hal_device_get_property_string (hal_volume->device, "volume.uuid"));
-  G_UNLOCK (hal_volume);
   
   return id;
 }
@@ -1004,8 +927,6 @@
   GPtrArray *res;
   const char *label, *uuid;
 
-  G_LOCK (hal_volume);
-
   res = g_ptr_array_new ();
 
   g_ptr_array_add (res,
@@ -1029,8 +950,6 @@
   /* Null-terminate */
   g_ptr_array_add (res, NULL);
 
-  G_UNLOCK (hal_volume);
-
   return (char **)g_ptr_array_free (res, FALSE);
 }
 
@@ -1040,10 +959,8 @@
   GHalVolume *hal_volume = G_HAL_VOLUME (volume);
   GFile *root = NULL;
 
-  G_LOCK (hal_volume);
   if (hal_volume->foreign_mount_root != NULL)
     root = g_object_ref (hal_volume->foreign_mount_root);
-  G_UNLOCK (hal_volume);
 
   return root;
 }

Modified: trunk/monitor/hal/ghalvolumemonitor.c
==============================================================================
--- trunk/monitor/hal/ghalvolumemonitor.c	(original)
+++ trunk/monitor/hal/ghalvolumemonitor.c	Thu Mar  5 17:27:40 2009
@@ -42,12 +42,10 @@
  * us without an instance..  and ideally we want to piggyback on an
  * already existing instance. 
  *
- * We avoid locking since GUnionVolumeMonitor, the only user of us,
- * does locking.
+ * We don't need locking since this runs out of process in a single
+ * threaded mode with now weird things happening in signal handlers.
  */
 
-G_LOCK_DEFINE_STATIC(hal_vm);
-
 static GHalVolumeMonitor *the_volume_monitor = NULL;
 static HalPool *pool = NULL;
 
@@ -127,9 +125,7 @@
   
   monitor = G_HAL_VOLUME_MONITOR (object);
 
-  G_LOCK (hal_vm);
   the_volume_monitor = NULL;
-  G_UNLOCK (hal_vm);
   
   if (G_OBJECT_CLASS (g_hal_volume_monitor_parent_class)->dispose)
     (*G_OBJECT_CLASS (g_hal_volume_monitor_parent_class)->dispose) (object);
@@ -176,16 +172,12 @@
   
   monitor = G_HAL_VOLUME_MONITOR (volume_monitor);
 
-  G_LOCK (hal_vm);
-  
   l = g_list_copy (monitor->mounts);
   ll = g_list_copy (monitor->disc_mounts);
   l = g_list_concat (l, ll);
 
   g_list_foreach (l, (GFunc)g_object_ref, NULL);
 
-  G_UNLOCK (hal_vm);
-
   return l;
 }
 
@@ -197,16 +189,12 @@
   
   monitor = G_HAL_VOLUME_MONITOR (volume_monitor);
 
-  G_LOCK (hal_vm);
-
   l = g_list_copy (monitor->volumes);
   ll = g_list_copy (monitor->disc_volumes);
   l = g_list_concat (l, ll);
 
   g_list_foreach (l, (GFunc)g_object_ref, NULL);
 
-  G_UNLOCK (hal_vm);
-  
   return l;
 }
 
@@ -218,13 +206,9 @@
   
   monitor = G_HAL_VOLUME_MONITOR (volume_monitor);
 
-  G_LOCK (hal_vm);
-
   l = g_list_copy (monitor->drives);
   g_list_foreach (l, (GFunc)g_object_ref, NULL);
 
-  G_UNLOCK (hal_vm);
-  
   return l;
 }
 
@@ -237,8 +221,6 @@
   
   monitor = G_HAL_VOLUME_MONITOR (volume_monitor);
 
-  G_LOCK (hal_vm);
-  
   volume = NULL;
 
   for (l = monitor->volumes; l != NULL; l = l->next)
@@ -255,15 +237,11 @@
         goto found;
     }
 
-  G_UNLOCK (hal_vm);
-  
   return NULL;
 
  found:
 
   g_object_ref (volume);
-  
-  G_UNLOCK (hal_vm);
 
   return (GVolume *)volume;
 }
@@ -277,8 +255,6 @@
   
   monitor = G_HAL_VOLUME_MONITOR (volume_monitor);
 
-  G_LOCK (hal_vm);
-  
   mount = NULL;
 
   for (l = monitor->mounts; l != NULL; l = l->next)
@@ -295,16 +271,12 @@
         goto found;
     }
 
-  G_UNLOCK (hal_vm);
-  
   return NULL;
 
  found:
 
   g_object_ref (mount);
   
-  G_UNLOCK (hal_vm);
-  
   return (GMount *)mount;
 }
 
@@ -316,11 +288,9 @@
   GHalMount *hal_mount;
   GHalVolumeMonitor *volume_monitor;
 
-  G_LOCK (hal_vm);
   volume_monitor = NULL;
   if (the_volume_monitor != NULL)
     volume_monitor = g_object_ref (the_volume_monitor);
-  G_UNLOCK (hal_vm);
 
   if (volume_monitor == NULL)
     {
@@ -341,8 +311,6 @@
     {
       GList *l;
 
-      G_LOCK (hal_vm);
-      
       for (l = volume_monitor->mounts; l != NULL; l = l->next)
         {
           hal_mount = l->data;
@@ -354,8 +322,6 @@
             }
         }
 
-      G_UNLOCK (hal_vm);
-      
       g_object_unref (volume_monitor);
     }
 
@@ -408,14 +374,11 @@
   GHalVolumeMonitorClass *klass;
   GObjectClass *parent_class;  
 
-  G_LOCK (hal_vm);
   if (the_volume_monitor != NULL)
     {
       object = g_object_ref (the_volume_monitor);
-      G_UNLOCK (hal_vm);
       return object;
     }
-  G_UNLOCK (hal_vm);
 
   /*g_warning ("creating hal vm");*/
 
@@ -451,9 +414,7 @@
 		    
   update_all (monitor, FALSE, TRUE);
 
-  G_LOCK (hal_vm);
   the_volume_monitor = monitor;
-  G_UNLOCK (hal_vm);
 
   return object;
 }
@@ -482,10 +443,8 @@
   */
   ret = NULL;
   
-  G_LOCK (hal_vm);
   if (the_volume_monitor == NULL)
     {
-      G_UNLOCK (hal_vm);
       return NULL;
     }
 
@@ -507,7 +466,6 @@
  found:
   g_object_unref (mount_root);
   
-  G_UNLOCK (hal_vm);
   return ret;
 }
 
@@ -989,14 +947,12 @@
   added_mounts = NULL;
   removed_mounts = NULL;
   
-  G_LOCK (hal_vm);
   update_drives (monitor, &added_drives, &removed_drives);
   update_volumes (monitor, &added_volumes, &removed_volumes);
   update_mounts (monitor, &added_mounts, &removed_mounts);
   update_discs (monitor,
                 &added_volumes, &removed_volumes,
                 &added_mounts, &removed_mounts);
-  G_UNLOCK (hal_vm);
 
   if (emit_changes)
     {



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