a089ec2f5f
Resolves: rhbz#1217202 (virt-manager) May help with rhbz#1338042 (gnome-boxes)
61 lines
2.5 KiB
Diff
61 lines
2.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Christophe Fergeau <cfergeau@redhat.com>
|
|
Date: Wed, 29 Jun 2016 16:48:18 +0200
|
|
Subject: [PATCH] usbredir: Use atomic for UsbDeviceManager::event_thread_run
|
|
|
|
This variable is accessed from 2 different threads (main thread and USB
|
|
event thread), so some care must be taken to read/write it.
|
|
---
|
|
src/usb-device-manager.c | 10 +++++-----
|
|
1 file changed, 5 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
|
|
index 1fc8fc1..808ec6c 100644
|
|
--- a/src/usb-device-manager.c
|
|
+++ b/src/usb-device-manager.c
|
|
@@ -112,7 +112,7 @@ struct _SpiceUsbDeviceManagerPrivate {
|
|
libusb_context *context;
|
|
int event_listeners;
|
|
GThread *event_thread;
|
|
- gboolean event_thread_run;
|
|
+ gint event_thread_run;
|
|
struct usbredirfilter_rule *auto_conn_filter_rules;
|
|
struct usbredirfilter_rule *redirect_on_connect_rules;
|
|
int auto_conn_filter_rules_count;
|
|
@@ -380,7 +380,7 @@ static void spice_usb_device_manager_dispose(GObject *gobject)
|
|
priv->hp_handle = 0;
|
|
}
|
|
#endif
|
|
- if (priv->event_thread && !priv->event_thread_run) {
|
|
+ if (priv->event_thread && !g_atomic_int_get(&priv->event_thread_run)) {
|
|
g_thread_join(priv->event_thread);
|
|
priv->event_thread = NULL;
|
|
}
|
|
@@ -1280,7 +1280,7 @@ static gpointer spice_usb_device_manager_usb_ev_thread(gpointer user_data)
|
|
SpiceUsbDeviceManagerPrivate *priv = self->priv;
|
|
int rc;
|
|
|
|
- while (priv->event_thread_run) {
|
|
+ while (g_atomic_int_get(&priv->event_thread_run)) {
|
|
rc = libusb_handle_events(priv->context);
|
|
if (rc && rc != LIBUSB_ERROR_INTERRUPTED) {
|
|
const char *desc = spice_usbutil_libusb_strerror(rc);
|
|
@@ -1310,7 +1310,7 @@ gboolean spice_usb_device_manager_start_event_listening(
|
|
g_thread_join(priv->event_thread);
|
|
priv->event_thread = NULL;
|
|
}
|
|
- priv->event_thread_run = TRUE;
|
|
+ g_atomic_int_set(&priv->event_thread_run, TRUE);
|
|
priv->event_thread = g_thread_new("usb_ev_thread",
|
|
spice_usb_device_manager_usb_ev_thread,
|
|
self);
|
|
@@ -1326,7 +1326,7 @@ void spice_usb_device_manager_stop_event_listening(
|
|
|
|
priv->event_listeners--;
|
|
if (priv->event_listeners == 0)
|
|
- priv->event_thread_run = FALSE;
|
|
+ g_atomic_int_set(&priv->event_thread_run, FALSE);
|
|
}
|
|
|
|
static void spice_usb_device_manager_check_redir_on_connect(
|