[spice-gtk v3 4/4] usb-redir: use g_thread_try_new instead of g_thread_new

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Newer API (glib 2.32) is safe, in case of error it does not
abort the process and returns error information.

Signed-off-by: Yuri Benditovich <yuri.benditovich@xxxxxxxxxx>
---
 src/usb-backend.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/usb-backend.c b/src/usb-backend.c
index 7c9b544..9ac8595 100644
--- a/src/usb-backend.c
+++ b/src/usb-backend.c
@@ -473,9 +473,14 @@ gboolean spice_usb_backend_register_hotplug(SpiceUsbBackend *be,
     }
 
     g_atomic_int_set(&be->event_thread_run, TRUE);
-    be->event_thread = g_thread_new("usb_ev_thread",
-                                    handle_libusb_events,
-                                    be);
+    be->event_thread = g_thread_try_new("usb_ev_thread",
+                                        handle_libusb_events,
+                                        be, error);
+    if (!be->event_thread) {
+        g_warning("Error starting event thread");
+        spice_usb_backend_deregister_hotplug(be);
+        return FALSE;
+    }
     return TRUE;
 }
 
-- 
2.17.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]