diff options
author | Alexander Larsson <alexl@redhat.com> | 2009-03-05 17:27:40 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2009-03-05 17:27:40 +0000 |
commit | 7b05ef821218511f60d46ab40c890da0ed8791f3 (patch) | |
tree | 320a6b14543ca1a65e00cab7e9c4c3fbaac24240 | |
parent | 0c5553f70d8bcdda0a88295ec5a492b389646ea1 (diff) | |
download | gvfs-7b05ef821218511f60d46ab40c890da0ed8791f3.tar.gz |
Remove all locking (not needed since we're now a single threaded process).
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.
svn path=/trunk/; revision=2290
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | monitor/hal/ghaldrive.c | 95 | ||||
-rw-r--r-- | monitor/hal/ghalmount.c | 93 | ||||
-rw-r--r-- | monitor/hal/ghalvolume.c | 109 | ||||
-rw-r--r-- | monitor/hal/ghalvolumemonitor.c | 48 |
5 files changed, 52 insertions, 308 deletions
@@ -1,5 +1,20 @@ 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. + +2009-03-05 Alexander Larsson <alexl@redhat.com> + Bug 564003 – gvfs Cygwin patches * common/Makefile.am: diff --git a/monitor/hal/ghaldrive.c b/monitor/hal/ghaldrive.c index a4be710c..b6f3814e 100644 --- a/monitor/hal/ghaldrive.c +++ b/monitor/hal/ghaldrive.c @@ -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 @@ _do_update_from_hal (GHalDrive *d) } } -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 @@ _update_from_hal (GHalDrive *d, gboolean emit_changed) 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 @@ _update_from_hal (GHalDrive *d, gboolean emit_changed) 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 @@ g_hal_drive_disconnected (GHalDrive *drive) { 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 @@ g_hal_drive_set_volume (GHalDrive *drive, 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 @@ g_hal_drive_unset_volume (GHalDrive *drive, { 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 @@ g_hal_drive_has_udi (GHalDrive *drive, const char *udi) { 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 @@ g_hal_drive_get_icon (GDrive *drive) 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 @@ g_hal_drive_get_name (GDrive *drive) 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 @@ g_hal_drive_get_volumes (GDrive *drive) 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 @@ static gboolean 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 @@ g_hal_drive_can_eject (GDrive *drive) 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 @@ g_hal_drive_eject_do (GDrive *drive, 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 @@ g_hal_drive_eject (GDrive *drive, 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 @@ g_hal_drive_eject (GDrive *drive, 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_hal_drive_poll_for_media (GDrive *drive, /*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 @@ g_hal_drive_get_identifier (GDrive *drive, 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 @@ g_hal_drive_enumerate_identifiers (GDrive *drive) 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_hal_drive_enumerate_identifiers (GDrive *drive) 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); diff --git a/monitor/hal/ghalmount.c b/monitor/hal/ghalmount.c index f85dfe09..2c84f4b4 100644 --- a/monitor/hal/ghalmount.c +++ b/monitor/hal/ghalmount.c @@ -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 @@ g_hal_mount_init (GHalMount *hal_mount) { } -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 @@ update_from_hal (GHalMount *m, gboolean emit_changed) 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 @@ update_from_hal (GHalMount *m, gboolean emit_changed) 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 @@ g_hal_mount_new_for_hal_device (GVolumeMonitor *volume_monitor, 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 @@ g_hal_mount_override_name (GHalMount *mount, const char *name) 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 @@ g_hal_mount_override_icon (GHalMount *mount, GIcon *icon) else mount->override_icon = NULL; - G_UNLOCK (hal_mount); - update_from_hal (mount, TRUE); } @@ -634,27 +615,23 @@ g_hal_mount_new (GVolumeMonitor *volume_monitor, 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 @@ static GFile * 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 @@ g_hal_mount_has_uuid (GHalMount *mount, { 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 @@ gboolean 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 @@ g_hal_mount_has_udi (GHalMount *mount, { 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 @@ g_hal_mount_get_drive (GMount *mount) 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 @@ g_hal_mount_get_volume (GMount *mount) 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 @@ g_hal_mount_can_unmount (GMount *mount) 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 @@ g_hal_mount_can_eject (GMount *mount) GDrive *drive; gboolean can_eject; - G_LOCK (hal_mount); can_eject = FALSE; if (hal_mount->volume != NULL) { @@ -820,7 +761,6 @@ g_hal_mount_can_eject (GMount *mount) if (drive != NULL) can_eject = g_drive_can_eject (drive); } - G_UNLOCK (hal_mount); return can_eject; } @@ -968,11 +908,8 @@ g_hal_mount_unmount (GMount *mount, 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 @@ g_hal_mount_eject (GMount *mount, 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 @@ g_hal_mount_eject_finish (GMount *mount, 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 @@ g_hal_mount_guess_content_type_sync (GMount *mount, 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 @@ g_hal_mount_guess_content_type_sync (GMount *mount, result = (char **) g_ptr_array_free (p, FALSE); } - G_UNLOCK (hal_mount); - return result; } diff --git a/monitor/hal/ghalvolume.c b/monitor/hal/ghalvolume.c index eaf537a6..47dda661 100644 --- a/monitor/hal/ghalvolume.c +++ b/monitor/hal/ghalvolume.c @@ -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 @@ g_hal_volume_init (GHalVolume *hal_volume) { } -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 @@ update_from_hal (GHalVolume *mv, gboolean emit_changed) 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 @@ update_from_hal (GHalVolume *mv, gboolean emit_changed) 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 @@ void 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_volume_removed (GHalVolume *volume) 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 @@ g_hal_volume_set_mount (GHalVolume *volume, 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 @@ g_hal_volume_set_drive (GHalVolume *volume, 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 @@ g_hal_volume_get_icon (GVolume *volume) const char *name; const char *fallback; - G_LOCK (hal_volume); name = hal_volume->icon; if (hal_volume->icon_fallback) @@ -534,7 +509,6 @@ g_hal_volume_get_icon (GVolume *volume) fallback = name; icon = get_themed_icon_with_fallbacks (name, fallback); - G_UNLOCK (hal_volume); return icon; } @@ -542,39 +516,24 @@ static char * 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 @@ g_hal_volume_can_eject (GVolume *volume) 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 @@ static gboolean 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 @@ g_hal_volume_get_drive (GVolume *volume) 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 @@ g_hal_volume_get_mount (GVolume *volume) 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 @@ g_hal_volume_has_mount_path (GHalVolume *volume, { 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 @@ g_hal_volume_has_device_path (GHalVolume *volume, 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 @@ g_hal_volume_has_udi (GHalVolume *volume, 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 @@ g_hal_volume_has_uuid (GHalVolume *volume, 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 @@ foreign_mount_unmounted (GMount *mount, gpointer user_data) 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 @@ foreign_mount_unmounted (GMount *mount, gpointer user_data) 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 @@ g_hal_volume_adopt_foreign_mount (GHalVolume *volume, GMount *foreign_mount) } 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 @@ g_hal_volume_has_foreign_mount_root (GHalVolume *volume, 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 @@ g_hal_volume_mount (GVolume *volume, 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 @@ g_hal_volume_mount (GVolume *volume, argv[4] = "-n"; spawn_do (volume, cancellable, callback, user_data, argv); } - G_UNLOCK (hal_volume); } static gboolean @@ -901,14 +833,11 @@ g_hal_volume_mount_finish (GVolume *volume, 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_hal_volume_eject (GVolume *volume, /*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 @@ g_hal_volume_eject_finish (GVolume *volume, 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 @@ g_hal_volume_get_identifier (GVolume *volume, 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 @@ g_hal_volume_get_identifier (GVolume *volume, 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 @@ g_hal_volume_enumerate_identifiers (GVolume *volume) GPtrArray *res; const char *label, *uuid; - G_LOCK (hal_volume); - res = g_ptr_array_new (); g_ptr_array_add (res, @@ -1029,8 +950,6 @@ g_hal_volume_enumerate_identifiers (GVolume *volume) /* Null-terminate */ g_ptr_array_add (res, NULL); - G_UNLOCK (hal_volume); - return (char **)g_ptr_array_free (res, FALSE); } @@ -1040,10 +959,8 @@ g_hal_volume_get_activation_root (GVolume *volume) 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; } diff --git a/monitor/hal/ghalvolumemonitor.c b/monitor/hal/ghalvolumemonitor.c index a7bb5cf9..819cd57b 100644 --- a/monitor/hal/ghalvolumemonitor.c +++ b/monitor/hal/ghalvolumemonitor.c @@ -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 @@ g_hal_volume_monitor_dispose (GObject *object) 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 @@ get_mounts (GVolumeMonitor *volume_monitor) 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 @@ get_volumes (GVolumeMonitor *volume_monitor) 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 @@ get_connected_drives (GVolumeMonitor *volume_monitor) 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 @@ get_volume_for_uuid (GVolumeMonitor *volume_monitor, const char *uuid) 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 @@ get_volume_for_uuid (GVolumeMonitor *volume_monitor, const char *uuid) goto found; } - G_UNLOCK (hal_vm); - return NULL; found: g_object_ref (volume); - - G_UNLOCK (hal_vm); return (GVolume *)volume; } @@ -277,8 +255,6 @@ get_mount_for_uuid (GVolumeMonitor *volume_monitor, const char *uuid) 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 @@ get_mount_for_uuid (GVolumeMonitor *volume_monitor, const char *uuid) goto found; } - G_UNLOCK (hal_vm); - return NULL; found: g_object_ref (mount); - G_UNLOCK (hal_vm); - return (GMount *)mount; } @@ -316,11 +288,9 @@ get_mount_for_mount_path (const char *mount_path, 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 @@ get_mount_for_mount_path (const char *mount_path, { GList *l; - G_LOCK (hal_vm); - for (l = volume_monitor->mounts; l != NULL; l = l->next) { hal_mount = l->data; @@ -354,8 +322,6 @@ get_mount_for_mount_path (const char *mount_path, } } - G_UNLOCK (hal_vm); - g_object_unref (volume_monitor); } @@ -408,14 +374,11 @@ g_hal_volume_monitor_constructor (GType type, 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 @@ g_hal_volume_monitor_constructor (GType type, update_all (monitor, FALSE, TRUE); - G_LOCK (hal_vm); the_volume_monitor = monitor; - G_UNLOCK (hal_vm); return object; } @@ -482,10 +443,8 @@ adopt_orphan_mount (GMount *mount, GVolumeMonitor *monitor) */ ret = NULL; - G_LOCK (hal_vm); if (the_volume_monitor == NULL) { - G_UNLOCK (hal_vm); return NULL; } @@ -507,7 +466,6 @@ adopt_orphan_mount (GMount *mount, GVolumeMonitor *monitor) found: g_object_unref (mount_root); - G_UNLOCK (hal_vm); return ret; } @@ -989,14 +947,12 @@ update_all (GHalVolumeMonitor *monitor, 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) { |