[sane-devel] USB device locking in the snapscan backend

Julien BLACHE jb at jblache.org
Sun Feb 24 20:57:05 UTC 2008


Giuseppe Sacco <giuseppe at eppesuigoccas.homedns.org> wrote:

Hi,

> ftok() require a filename, but it does not have to be the pathname of
> any scanner device. Since we have an address in the form of
> libusb:<busnumber>:<devicenumber> I suggest to create
> /tmp/libusb:<busnumber>:<devicenumber> prior to getting the lock. I am
> not sure if this is better than any other file system level lock. The
> empty file may be left there, since it doesn't hurt anyone.

You need to remove it after use, otherwise the next user will maybe
not be able to create this file, creating a new failure mode, and you
haven't won anything in the process.

> BTW, the problem might be solved on linux platform, switching to
> pthread. Am I correct?

TTBOMK pthread has some issues in SANE. Moreover, switching to pthread
is going to have interesting side effects on frontends which do not
expect the backend to spawn a new thread. So it's out of the
question...

JB.

-- 
Julien BLACHE                                   <http://www.jblache.org> 
<jb at jblache.org>                                  GPG KeyID 0xF5D65169



More information about the sane-devel mailing list