Hi, On 07/10/2012 01:01 PM, Pete Batard wrote: > I expect the attached patch to fix the likely bug reported by Hans. > > As previously indicated, we should be able to either rearm the next timer or > disarm all timers in the arm_timerfd_for_next_timeout() call of io.c, > especially as we always issue it with the flying_transfers locked. > > Note that this patch may result in the timerfd being disarmed twice in > handle_timerfd_trigger(). Apart from a slight overhead, I don't expect that > to be a problem. Especially, the timerfd_settime() man page does not indicate > that disarming a timerfd twice will result in an error code. Of course, to > avoid that we could try to remove the unconditional disarm call at the > beginning of handle_timerfd_trigger(), but I believe we very much want to > have it before issuing handle_timeouts_locked(), to avoid potentially > accumulating a whole bunch of timerfd events, while we already are in the > process of > checking for timeouts anyway. > > Also, I haven't tested this change under the conditions where I'd expect the > issue to manifest itself, so there is a possibility the patch (or the reality > of the problem) is still off.
I had looking further into this / writing a patch on my todo list, looks like you beat me to it, thanks for working on this! You're patch looks good, one possible optimization would be to give arm_timerfd_for_next_timeout() an extra "int stop_timer" argument and only call disarm_timerfd() when that argument is true. In the arm_timerfd_for_next_timeout() call from usbi_handle_transfer_completion() this argument would be true, not changing anything from your last revision, but in the call from handle_timerfd_trigger() it would be false, avoiding an unnecessary call to disarm_timerfd(). As said this is pure optimization, but given that the scenario where no other packets are pending when a timeout hits is not unlikely, I think it is worth it. 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