[Spice-devel] [spice-gtk v2 9/9] usb-redir: use g_thread_try_new instead of g_thread_new

Victor Toso victortoso at redhat.com
Tue Jul 23 13:49:05 UTC 2019


Hi,

On Tue, Jul 23, 2019 at 10:27:08AM +0300, Yuri Benditovich wrote:
> 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 at daynix.com>
> ---
>  src/usb-backend.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/usb-backend.c b/src/usb-backend.c
> index bbd3b67..272d72a 100644
> --- a/src/usb-backend.c
> +++ b/src/usb-backend.c
> @@ -469,9 +469,9 @@ 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);

Actually, this if() should be moved from 8/9 to 9/9 as it would
just abort() if thread was not created, etc.

Feel free to fix it in the next iteration, still,
Acked-by: Victor Toso <victortoso at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20190723/b8f50fbc/attachment.sig>


More information about the Spice-devel mailing list