[Spice-devel] [PATCH v3 00/13] Make start and stop usb redirection asynchronous
Kirill Moizik
kirill at daynix.com
Mon Aug 3 06:10:40 PDT 2015
From: Kirill Moizik <kmoizik at redhat.com>
This patches series make start/stop usb redirection flows run in their own threads.
It solve spice freeze problem since start and stop redirection is time consuming operations.
This series includes new api exposure, threads syncronization and new usb redirection widget behavior.
When redirection starts/ends widget will turn inactive/active
Synchronization strategy explanation:
To avoid application freeze during usb redirection flow connect and disconnect flows will run in separate thread.
Theads synchronization underlying ideas is as following.
1) Main thread is already syncronized with usb handler thread.
2) connect/disconnect flows should be serialized, i.e 2 parallel redirection flows could not run concurrently
New thread use SpiceUsbredirChannel object during the flow.
More specifically it use next object fields :
channel->priv->state
channel->priv->host
channel->priv->device
channel->priv->catch_error
channel->priv->spice_device
Threads synchronization goal is to prevent concurrent access to those fields fromm main thread/ usb handler thread and prevent calls to non thread safe usbredir functions.
It is achieved next steps:
1) to make sure channel is not disposed while redirection in progress, add reference on flow start and unref on the end
2) make channel reset use disconnect async api
3) on redirection start/stop acquire lock and release it when resources are not in use anymore
4) all critical sections which can be reached in main thread guarded with lock
(critical section is a section uses same resources as a thread or section make a call to non thread safe usbredir function)
v3 changeset:
remove spice_g_udev_handle_device_change api
cosmetic changes
set redirection state at usbdevice manager level
remove set_redirecton and set_sensitive_all
check for redirection state at check_can_redirect
expose mutex to guard all critical sections
v2 changeset:
fix trailing whitespace
fix linux build with usb redirection
fix linux build without ussb redirection
set redirecting state as gobject property
separate commit for widget manipulations
commit messages fixes
Kirill Moizik (13):
Usbredir channel: expose mutex
Add redirecting state
GUdevClient: Do not process udb add/remove events if redirection in
progress
UsbDeviceManager: move existing code to separate function
UsbDeviceManager and redirect channel: spawn a different thread for
connect device flow
Usbredir Channel: Change disconnect signature to reuse in async
context
UsbDeviceManager and redirect channel: spawn a different thread for
disconnect device flow
Usbredir channel: use disconnect_async
Add additional locks to critical sections of redirection flows
UsbDeviceWidget: if redirecting update infobar accordingly
UsbDeviceWidget: consider asynchronous redirecting flow
UsbDeviceWidget: use async disconnect
Fix preprocessor commands for different kinds of build
src/channel-usbredir-priv.h | 12 ++-
src/channel-usbredir.c | 145 +++++++++++++++++++++-----
src/map-file | 2 +
src/usb-device-manager.c | 241 ++++++++++++++++++++++++++++++++++++--------
src/usb-device-manager.h | 8 ++
src/usb-device-widget.c | 77 +++++++++-----
src/win-usb-dev.c | 16 +++
src/win-usb-dev.h | 1 +
8 files changed, 412 insertions(+), 90 deletions(-)
--
2.4.3
More information about the Spice-devel
mailing list