On Wed, Jun 29, 2016 at 07:20:16PM +0200, Hans de Goede wrote: > Hi, > > On 29-06-16 17:42, Christophe Fergeau wrote: > > This variable is accessed from 2 different threads (main thread and USB > > event thread), so some care must be taken to read/write it. > > The event-thread only reads it, so I believe there is no need for this. https://en.wikipedia.org/wiki/Memory_ordering#Runtime_memory_ordering says that on most architectures stores can be reordered after loads, I'd read this as: main thread sets event_thread_run to FALSE, calls libusb_hotplug_deregister_callback(), usb event thread returns from libusb_handle_events(), reads event_thread_run, but reads the old value (TRUE) rather than the FALSE causing it to exit. I agree that it's likely that either libusb_hotplug_deregister_callback() and/or libusb_handle_events() are going to trigger some barrier, but it feels safer to me to handle the concurrency ourselves. Christophe
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel