summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2022-10-17 13:55:14 +0100
committerRichard Hughes <richard@hughsie.com>2022-10-17 13:55:14 +0100
commit71cfa716779b1b7a6ee49fbc0d6d3034979a842f (patch)
treed53fa035cfba3b33fa79943ad6d3bec7addb1055
parent440423dcdcfb4e7d290b5e8993e67b0070e1a314 (diff)
downloadgusb-71cfa716779b1b7a6ee49fbc0d6d3034979a842f.tar.gz
Revert "Use GRecMutex to avoid a single-threaded lockup"
This reverts commit cfb40102b0985d52cbd5d9348dedd1a4cc06b10c -- it's the wrong fix as the hotplug callback is being called by two different threads; even a recursive mutex isn't going to save us there.
-rw-r--r--gusb/gusb-context.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/gusb/gusb-context.c b/gusb/gusb-context.c
index f19fd52..5fb7977 100644
--- a/gusb/gusb-context.c
+++ b/gusb/gusb-context.c
@@ -50,7 +50,7 @@ typedef struct {
libusb_context *ctx;
libusb_hotplug_callback_handle hotplug_id;
GPtrArray *idle_events;
- GRecMutex idle_events_mutex;
+ GMutex idle_events_mutex;
guint idle_events_id;
} GUsbContextPrivate;
@@ -140,20 +140,12 @@ g_usb_context_dispose(GObject *object)
g_clear_pointer(&priv->dict_replug, g_hash_table_unref);
g_clear_pointer(&priv->ctx, libusb_exit);
g_clear_pointer(&priv->idle_events, g_ptr_array_unref);
+ g_mutex_clear(&priv->idle_events_mutex);
G_OBJECT_CLASS(g_usb_context_parent_class)->dispose(object);
}
static void
-g_usb_context_finalize(GObject *object)
-{
- GUsbContext *self = G_USB_CONTEXT(object);
- GUsbContextPrivate *priv = GET_PRIVATE(self);
- g_rec_mutex_clear(&priv->idle_events_mutex);
- G_OBJECT_CLASS(g_usb_context_parent_class)->finalize(object);
-}
-
-static void
g_usb_context_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
GUsbContext *self = G_USB_CONTEXT(object);
@@ -199,7 +191,6 @@ g_usb_context_class_init(GUsbContextClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS(klass);
object_class->dispose = g_usb_context_dispose;
- object_class->finalize = g_usb_context_finalize;
object_class->get_property = g_usb_context_get_property;
object_class->set_property = g_usb_context_set_property;
@@ -533,7 +524,7 @@ g_usb_context_idle_hotplug_cb(gpointer user_data)
{
GUsbContext *self = G_USB_CONTEXT(user_data);
GUsbContextPrivate *priv = GET_PRIVATE(self);
- g_autoptr(GRecMutexLocker) locker = g_rec_mutex_locker_new(&priv->idle_events_mutex);
+ g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&priv->idle_events_mutex);
g_assert(locker != NULL);
@@ -567,7 +558,7 @@ g_usb_context_hotplug_cb(struct libusb_context *ctx,
GUsbContext *self = G_USB_CONTEXT(user_data);
GUsbContextIdleHelper *helper;
GUsbContextPrivate *priv = GET_PRIVATE(self);
- g_autoptr(GRecMutexLocker) locker = g_rec_mutex_locker_new(&priv->idle_events_mutex);
+ g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&priv->idle_events_mutex);
g_assert(locker != NULL);
@@ -833,7 +824,7 @@ g_usb_context_init(GUsbContext *self)
priv->dict_replug = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
/* to escape the thread into the mainloop */
- g_rec_mutex_init(&priv->idle_events_mutex);
+ g_mutex_init(&priv->idle_events_mutex);
priv->idle_events =
g_ptr_array_new_with_free_func((GDestroyNotify)g_usb_context_idle_helper_free);
}