When libusb was built with timerfd support but used on a system
without timerfd support the library would hang indefinitely on
completion of the first transfer, since timerfd functions were
being called unconditionally and the error returned when timerfd
was not being used caused a confused internal state.
Many thanks to Ivo Smits for looking into the issue, proposing
an initial solution, and helping with testing! Fixes #73.
USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
struct libusb_context *ctx = TRANSFER_CTX(transfer);
uint8_t flags;
- int r;
+ int r = 0;
/* FIXME: could be more intelligent with the timerfd here. we don't need
* to disarm the timerfd if there was no timer running, and we only need
usbi_mutex_lock(&ctx->flying_transfers_lock);
list_del(&itransfer->list);
- r = arm_timerfd_for_next_timeout(ctx);
+ if (usbi_using_timerfd(ctx))
+ r = arm_timerfd_for_next_timeout(ctx);
usbi_mutex_unlock(&ctx->flying_transfers_lock);
- if (r < 0) {
- return r;
- } else if (r == 0) {
+ if (usbi_using_timerfd(ctx)) {
+ if (r < 0)
+ return r;
r = disarm_timerfd(ctx);
if (r < 0)
return r;