[sane-devel] sane_init(), sane_get_devices() and SANE_Authorization_Callback()

m. allan noah kitno455 at gmail.com
Wed May 26 21:04:32 UTC 2010

>> Many backends do not properly re-scan for devices. Those backends
>> should be fixed. Which version of sane-backends is this?
> This was sane-backends 1.0.21 from the ubunntu ppa mentioned in a couple of
> mails back. The backends I use are epson2 and v4l

v4l is pretty much unmaintained, so I don't know that will get fixed,
and A. Zummo has been too busy to work on epson2 lately, but I might
step in a fix that.

>> sane-backends is not designed to be thread safe, as only one function
>> (sane_cancel) is explicitly required to be reentrant. So, arrange your
>> app to only call sane from one thread. But, more to your question- you
>> should only call sane_init once. If you call it again (particularly
>> without calling sane_exit first), I would not be surprised to hear of
>> bad things happening.
> OK, I'll ensure that sane_init is called only once. Does this also mean that
> the sane callbacks that take a sane handle can have local variables that would
> conflict?
> Since libksane provides a "widget" it always runs in the main event loop and
> will not reenter the same function twice.

Any sane function could step on the toes of another sane function. I
did not say that calling the same function twice was a problem-
calling ANY two functions simultaneously is a problem, except
sane_cancel. You must ensure

> One workaround I can think of would be to start a separate process that would
> read the available devices...

only if you are going to use that process to also do the scanning,
since the device list would have to be rescanned in any other process.

>> > 4) Again in a multi threaded application there might be two scanners that
>> > require authentication. The resource string that is provided to
>> > SANE_Authorization_Callback() contains the backend name and a md5 hash,
>> > but it does not contain the same ":libusb:001:004" extra info type of
>> > sting that sane_get_devices() returns for the backend.
>> Which backend?
> At least "epson2" and "test" through the net backend.

weird- i've never used the auth callback, and none of my backends need
it, so I'd have to play around with it to comment further...

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

More information about the sane-devel mailing list