Fix blocking libusb event handling 85/129685/1 accepted/tizen/4.0/unified/20170816.012733 accepted/tizen/4.0/unified/20170828.223858 accepted/tizen/unified/20170605.151631 submit/tizen/20170605.090941 submit/tizen_4.0/20170811.094300 submit/tizen_4.0/20170828.100002
authorPaweł Szewczyk <p.szewczyk@samsung.com>
Wed, 17 May 2017 13:01:13 +0000 (15:01 +0200)
committerPaweł Szewczyk <p.szewczyk@samsung.com>
Wed, 17 May 2017 13:18:38 +0000 (15:18 +0200)
This patch changes libusb_handle_events to
libusb_handle_events_timeout_completed, which is non-blocking and does
not cause applications to hang.

Change-Id: Ieebfcab3ae827b158345e09c41d6c136a7ed0e18
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
src/usb_host.c

index 620664d9fc71300ef6dcd98793393e5120297b89..708e0bcab675827453ad1389bb77042afa041ac1 100644 (file)
@@ -370,12 +370,17 @@ out:
 static gboolean usb_host_poll_cb(GIOChannel *source, GIOCondition condition, gpointer data)
 {
        usb_host_context_h ctx = data;
+       int ret;
+       struct timeval tv = {0, 0};
        _I("usb_host_poll_cb");
 
-       if (libusb_handle_events(ctx->lusb_ctx) == 0)
-               return TRUE;
+       ret = libusb_handle_events_timeout_completed(ctx->lusb_ctx, &tv, NULL);
+       if (ret < 0) {
+               _E("Could not handle events");
+               return FALSE;
+       }
 
-       return FALSE;
+       return TRUE;
 }
 
 static int add_fd_watch(int fd, short events, void *user_data)