[Spice-commits] 3 commits - src/usb-device-manager.c src/win-usb-dev.c

Victor Toso de Carvalho victortoso at kemper.freedesktop.org
Tue Nov 15 17:02:59 UTC 2016


 src/usb-device-manager.c |    5 +++++
 src/win-usb-dev.c        |    5 +----
 2 files changed, 6 insertions(+), 4 deletions(-)

New commits:
commit 95031c6cfce51b0cff58a476fe462d7a99e707b3
Author: Victor Toso <me at victortoso.com>
Date:   Tue Nov 15 14:28:54 2016 +0100

    win-usb-dev: improve warning message
    
    With the actual reason for failure. This might help to identify why
    code might be crashing or failing.
    
    Signed-off-by: Victor Toso <victortoso at redhat.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/src/win-usb-dev.c b/src/win-usb-dev.c
index 5e5bb4d..defa71e 100644
--- a/src/win-usb-dev.c
+++ b/src/win-usb-dev.c
@@ -141,7 +141,7 @@ g_udev_client_list_devices(GUdevClient *self, GList **devs,
     rc = libusb_get_device_list(priv->ctx, &lusb_list);
     if (rc < 0) {
         const char *errstr = spice_usbutil_libusb_strerror(rc);
-        g_warning("%s: libusb_get_device_list failed", name);
+        g_warning("%s: libusb_get_device_list failed - %s", name, errstr);
         g_set_error(err, G_UDEV_CLIENT_ERROR, G_UDEV_CLIENT_LIBUSB_FAILED,
                     "%s: Error getting device list from libusb: %s [%"G_GSSIZE_FORMAT"]",
                     name, errstr, rc);
commit bd530d0feeedff39fbf8cafedd011a7abc53ac01
Author: Victor Toso <me at victortoso.com>
Date:   Mon Nov 14 23:50:03 2016 +0100

    win-usb-dev: let _finalize() do libusb_exit()
    
    This fixes a hang in mingw-spice-gtk when the GUdevClient fails to
    initialize due to problems in the UsbDk installation.
    
    Before this patch, libusb_exit() was being called twice:
    - At g_udev_client_initable_init(), after failure with priv->ctx as
      argument
    - At g_udev_client_finalize() as g_udev_client_initable_init() failure
      implies the object failed to initialize and it is terminated. Here
      it was being called with NULL as priv->ctx was set to NULL in
      g_udev_client_initable_init()
    
    Resolves: https://bugs.freedesktop.org/show_bug.cgi?id=98686
    Signed-off-by: Victor Toso <victortoso at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/src/win-usb-dev.c b/src/win-usb-dev.c
index 4b95b2d..5e5bb4d 100644
--- a/src/win-usb-dev.c
+++ b/src/win-usb-dev.c
@@ -232,9 +232,6 @@ g_udev_client_initable_init(GInitable *initable, GCancellable *cancellable,
  g_udev_client_init_failed_unreg:
     UnregisterClass(G_UDEV_CLIENT_WINCLASS_NAME, NULL);
  g_udev_client_init_failed:
-    libusb_exit(priv->ctx);
-    priv->ctx = NULL;
-
     return FALSE;
 }
 
commit d6275ccfc43993365b601aaab6238e7a447c90d8
Author: Victor Toso <me at victortoso.com>
Date:   Mon Nov 14 18:45:18 2016 +0100

    usb-device-manager: handle failures from g_udev_client_new()
    
    As we must handle when GUdevClient creation can fail otherwise code
    might crash.
    
    Signed-off-by: Victor Toso <victortoso at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index 3d4bd98..efb7454 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -321,6 +321,11 @@ static gboolean spice_usb_device_manager_initable_init(GInitable  *initable,
     /* Start listening for usb devices plug / unplug */
 #ifdef USE_GUDEV
     priv->udev = g_udev_client_new(subsystems, err);
+    if (priv->udev == NULL) {
+        const gchar *msg = (err != NULL && *err != NULL) ? (*err)->message : "";
+        g_warning("Error initializing GUdevClient - %s", msg);
+        return FALSE;
+    }
     g_signal_connect(G_OBJECT(priv->udev), "uevent",
                      G_CALLBACK(spice_usb_device_manager_uevent_cb), self);
     /* Do coldplug (detection of already connected devices) */


More information about the Spice-commits mailing list