libftdi Archives

Subject: Re: ftdi_transfer_data_done busy loop

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Cc: Eugene Hutorny <eugene@xxxxxxxxxxxxx>
Date: Wed, 2 Oct 2019 13:28:23 +0200
Hi Omri,

You wrote on Thu, Aug 22, 2019 at 11:22:35AM +0300:
> It seems that both ftdi_transfer_data_done and ftdi_transfer_data_cancel
> call libusb_handle_events_timeout_completed with zero timeval, with the
> intention of indefinitely blocking (it even states so in
> ftdi_transfer_data_cancel's documentation).
> However, in practice, libusb_handle_events_timeout_completed with zero
> timeval just acts as a non-blocking function, which means both of these
> functions actually busy-wait instead of polling indefinitely.
> Am I missing something?
> Shall I propose a patch?

ftdi_transfer_data_cancel() allows the user to pass an optional timeout.

ftdi_transfer_data_done() lacks this API and we can't
easily extend it without breaking existing users.

I've checked the libusb_handle_events_timeout_completed() API documentation,
theoretically it should not make much of a difference in user visible
behavior if we specify a timeout of one second or so.

CC:ing Eugene as he might know this code more than me.
(=read: Supplied the patch that added the timeouts)

[second email]
> Do you think it's worth fixing for the next release?
> I can write up a patch and manually test it.

if there's really no user visible change, I think it's worth it
as it will make the code more efficient and reduce power consumption.

Cheers,
Thomas

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread