[gvfs] mtp: do not crash when device is unplugged
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] mtp: do not crash when device is unplugged
- Date: Tue, 4 Nov 2014 12:40:22 +0000 (UTC)
commit 37727a10ee377d5675413c9d72fee4b9273c60b2
Author: Ondrej Holy <oholy redhat com>
Date: Mon Nov 3 19:17:00 2014 +0100
mtp: do not crash when device is unplugged
Leak the mutex if the backend is force unmounted to avoid crash
caused by abort(), when trying to clear already locked mutex.
https://bugzilla.gnome.org/show_bug.cgi?id=739575
daemon/gvfsbackendmtp.c | 7 ++++++-
daemon/gvfsbackendmtp.h | 1 +
2 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/daemon/gvfsbackendmtp.c b/daemon/gvfsbackendmtp.c
index 63a213b..abb69f9 100644
--- a/daemon/gvfsbackendmtp.c
+++ b/daemon/gvfsbackendmtp.c
@@ -415,7 +415,11 @@ g_vfs_backend_mtp_finalize (GObject *object)
g_hash_table_foreach (backend->monitors, remove_monitor_weak_ref, backend->monitors);
g_hash_table_unref (backend->monitors);
- g_mutex_clear (&backend->mutex);
+
+ /* Leak the mutex if the backend is force unmounted to avoid crash caused by
+ * abort(), when trying to clear already locked mutex. */
+ if (!backend->force_unmounted)
+ g_mutex_clear (&backend->mutex);
(*G_OBJECT_CLASS (g_vfs_backend_mtp_parent_class)->finalize) (object);
@@ -591,6 +595,7 @@ on_uevent (GUdevClient *client, gchar *action, GUdevDevice *device, gpointer use
(char *)path);
}
+ op_backend->force_unmounted = TRUE;
g_vfs_backend_force_unmount ((GVfsBackend*)op_backend);
}
diff --git a/daemon/gvfsbackendmtp.h b/daemon/gvfsbackendmtp.h
index c45618b..9ae0301 100644
--- a/daemon/gvfsbackendmtp.h
+++ b/daemon/gvfsbackendmtp.h
@@ -61,6 +61,7 @@ struct _GVfsBackendMtp
GHashTable *monitors;
guint hb_id;
gint unmount_started;
+ gboolean force_unmounted;
gboolean android_extension;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]