From: Paweł Szewczyk Date: Wed, 17 May 2017 13:01:13 +0000 (+0200) Subject: Fix blocking libusb event handling X-Git-Tag: submit/tizen/20170605.090941^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F85%2F129685%2F1;p=platform%2Fcore%2Fapi%2Fusb-host.git Fix blocking libusb event handling 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 --- diff --git a/src/usb_host.c b/src/usb_host.c index 620664d..708e0bc 100644 --- a/src/usb_host.c +++ b/src/usb_host.c @@ -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)