PERFORCE change 163120 for review
Sylvestre Gallon
syl at FreeBSD.org
Sat May 30 20:41:10 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=163120
Change 163120 by syl at 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;
More information about the p4-projects
mailing list