[sane-devel] sane_cancel() functionality

m. allan noah kitno455 at gmail.com
Thu Mar 4 14:03:29 UTC 2010


2010/3/4 Kåre Särs <kare.sars at iki.fi>:
> Hi,
>
> I wanted to implement support for the "wait for button" option, available at
> least in epson2 and epkowa backends, but I have a problem with sane_cancel().
>
> If the "wait for button"  parameter is set to true, sane (the backend) stops
> at sane_start() and waits for the user to press the button on the scanner.
>
> Now, if the user decides that he/she wants to cancel the scan, it does not
> seem possible to do it without pressing the button on the scanner. With the
> epson2 backend sane_cancel() did not return before  the button was pressed and
> with the epkowa backend sane_cancel() did return, but sane_start() did not.
>
> In an earlier version of libksane, I tried to use sane_cancel() from a
> different thread, but that resulted in segmentation faults. So this time I
> tried to ensure that sane_cancel() only would be called once while the scan
> thread is waiting for sane_start() to return.
>
> What is the status on sane_cancel() and thread safety?

There is no requirement for thread safety in the spec, IIRC. However,
sane_cancel is required to be re-entrant.

> Should sane_start() return if sane_cancel() is called?

The spec only says that the front-end must continue to wait on
whatever operation was running, even after it calls sane_cancel().
However, I would say that this is a backend bug- the code loop that
checks for button presses should also be checking for sane_cancel to
have been called.

allan
-- 
"The truth is an offense, but not a sin"



More information about the sane-devel mailing list