From owner-p4-projects@FreeBSD.ORG Sat May 30 20:41:10 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DF2591065674; Sat, 30 May 2009 20:41:09 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F666106566C for ; Sat, 30 May 2009 20:41:09 +0000 (UTC) (envelope-from syl@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 8314E8FC14 for ; Sat, 30 May 2009 20:41:09 +0000 (UTC) (envelope-from syl@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n4UKf9AT012592 for ; Sat, 30 May 2009 20:41:09 GMT (envelope-from syl@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n4UKf2Sj012582 for perforce@freebsd.org; Sat, 30 May 2009 20:41:02 GMT (envelope-from syl@FreeBSD.org) Date: Sat, 30 May 2009 20:41:02 GMT Message-Id: <200905302041.n4UKf2Sj012582@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to syl@FreeBSD.org using -f From: Sylvestre Gallon To: Perforce Change Reviews Cc: Subject: PERFORCE change 163120 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 May 2009 20:41:10 -0000 http://perforce.freebsd.org/chv.cgi?CH=163120 Change 163120 by syl@syl_rincewind on 2009/05/30 20:40:23 - Style change. - Use get_next_timeout() instead of libusb_get_next_timeout() in libusb_handle_events_timeout() and in libusb_handle_evens_locked(). - Fix a deadlock into libusb_get_next_timeout(). - Use USB_TIMED_OUT instead of LIBUSB_TRANSFER_TIMED_OUT. Affected files ... .. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#23 edit .. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10_io.c#6 edit Differences ... ==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#23 (text+ko) ==== ==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10_io.c#6 (text+ko) ==== @@ -259,7 +259,7 @@ ret = ctx->pollfd_modify; pthread_mutex_unlock(&ctx->pollfd_modify_lock); - if (ret) + if (ret != 0) return (0); return (1); } @@ -274,7 +274,7 @@ ret = ctx->pollfd_modify; pthread_mutex_unlock(&ctx->pollfd_modify_lock); - if (ret) + if (ret != 0) return (1); return (ctx->event_handler_active); } @@ -284,7 +284,6 @@ { GET_CONTEXT(ctx); pthread_mutex_lock(&ctx->event_waiters_lock); - return; } void @@ -292,7 +291,6 @@ { GET_CONTEXT(ctx); pthread_mutex_unlock(&ctx->event_waiters_lock); - return; } int @@ -335,16 +333,9 @@ int ret; GET_CONTEXT(ctx); - ret = libusb_get_next_timeout(ctx, &timeout); + ret = get_next_timeout(ctx, tv, &poll_timeout); if (ret != 0) { - if (timerisset(&timeout) == 0) - return (handle_timeouts(ctx)); - if (timercmp(&timeout, tv, <)) - poll_timeout = timeout; - else - poll_timeout = *tv; - } else { - poll_timeout = *tv; + return handle_timeouts(ctx); } retry: if (libusb_try_lock_events(ctx) == 0) { @@ -383,21 +374,14 @@ libusb_handle_events_locked(libusb_context * ctx, struct timeval *tv) { int ret; - struct timeval timeout; struct timeval poll_tv; GET_CONTEXT(ctx); - ret = libusb_get_next_timeout(ctx, &timeout); - if (ret) { - if (timerisset(&timeout) == 0) - return handle_timeouts(ctx); - if (timercmp(&timeout, tv, <) != 0) - poll_tv = timeout; - else - poll_tv = *tv; - } else { - poll_tv = *tv; + ret = get_next_timeout(ctx, tv, &poll_tv); + if (ret != 0) { + return handle_timeouts(ctx); } + return (handle_events(ctx, &poll_tv)); } @@ -414,11 +398,13 @@ GET_CONTEXT(ctx); found = 0; pthread_mutex_lock(&ctx->flying_transfers_lock); - if (USB_LIST_EMPTY(&ctx->flying_transfers)) + if (USB_LIST_EMPTY(&ctx->flying_transfers)) { + pthread_mutex_unlock(&ctx->flying_transfers_lock); return (0); + } LIST_FOREACH_ENTRY(xfer, &ctx->flying_transfers, list) { - if (!(xfer->flags & LIBUSB_TRANSFER_TIMED_OUT)) { + if (!(xfer->flags & USB_TIMED_OUT)) { found = 1; break ; } @@ -438,7 +424,7 @@ return (LIBUSB_ERROR_OTHER); TIMESPEC_TO_TIMEVAL(&cur_tv, &cur_ts); - if (timercmp(&cur_tv, next_tv, >=)) + if (timercmp(&cur_tv, next_tv, >=) != 0) timerclear(tv); else timersub(next_tv, &cur_tv, tv); @@ -473,7 +459,7 @@ ret = calloc(i + 1 , sizeof(struct libusb_pollfd *)); if (ret == NULL) { pthread_mutex_unlock(&ctx->pollfds_lock); - return (NULL); + return (ret); } i = 0;