Hi,

While debugging an usbredir issue I noticed the following in libusb/io.c:

int usbi_handle_transfer_completion(struct usbi_transfer *itransfer,
         enum libusb_transfer_status status)
{
         ...

         /* FIXME: could be more intelligent with the timerfd here. we don't nee
          * to disarm the timerfd if there was no timer running, and we only nee
          * to rearm the timerfd if the transfer that expired was the one with
          * the shortest timeout. */

         usbi_mutex_lock(&ctx->flying_transfers_lock);
         list_del(&itransfer->list);
         if (usbi_using_timerfd(ctx))
                 r = arm_timerfd_for_next_timeout(ctx);
         usbi_mutex_unlock(&ctx->flying_transfers_lock);

         if (usbi_using_timerfd(ctx)) {
                 if (r < 0)
                         return r;
                 r = disarm_timerfd(ctx);
                 if (r < 0)
                         return r;
         }

         ...
}

Now maybe I'm crazy, but should we not first disarm the timerfd, and then
re-arm it for the next timeout? Because right now the re-arm is a nop as
it gets canceled out by the later disarm?

So either I'm not understanding the code correctly, or we have a bug here,
which cancels any pending timeouts as soon as one packet completes.

Regards,

Hans

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to