[PATCH] fix DownloadWidget behavior

Danilo Cesar Lemes de Paula danilo.eu at gmail.com
Sat Aug 24 17:15:29 UTC 2013


On 08/24/2013 06:24 PM, Jef Driesen wrote:> On 24-08-13 16:42, Danilo 
Cesar wrote:
>> I would ask that someone make a test for me before applying this
>> patch, please.
>>
>> Right now I'm facing a problem with libdivingcomputer where I set
>> import_thread_cancelled=true but libdivecomputer doesn't stop the
>> download.
>>
>> Since I'm having exactly the same problem on the Gtk version, I
>> believe the problem might be a bug in libdivingcomputer AND my diving
>> computer (mares matrix).
>
> The fact that libdivecomputer doesn't cancel the current operation
> immediately (or even at all) is by design.
>
> The underlying reason is that not all communication protocols can
> technically support this feature. Take for example a protocol where you
> send a single request and get all data back at once. Once that request
> has been send, there isn't anything you can do to stop the dive computer
> from transmitting data. Since aborting abruptly might cause trouble,
> libdivecomputer will ignore the cancellation request and continue.
>
> The protocols that do support cancellation are typically the ones where
> you have to send multiple requests, and in that case, libdivecomputer
> can safely cancel between two requests. But even then a cancellation
> request won't be handled immediately, because libdivecomputer has to
> wait until the current packet has been finished. (Technically, because
> libdivecomputer does blocking I/O it won't even notice your cancellation
> request, except at those points where it explicitly checks for it with
> the device_is_cancelled function.)
>
> Thus cancellation is always a best effort, without any guarantees
> ("cooperative cancellation"). A cancellation request may be handled
> almost instantly, with a small delay, or not at all.
>

Thanks for the explanation.

But even if you fix that on the libdivingcomputer it also needs a fix 
on the UI side, since it always expects the download to be canceled.
Whoever merge patches from the mailing list, please ignore my last one. 
I will send a better one tomorrow.

BR
Danilo


More information about the subsurface mailing list