[sane-devel] Scanner buttons (kind of RFC)

Matto Marjanovic maddog@mir.com
Wed, 11 Sep 2002 11:35:20 -0400

 >This way several frontends can open the same device and the options are
 >set independant.
 >On my work I think it is normal that 5 people have the frontend(xsane)
 >opened at the same time, all use the same scanner.

I don't see how not locking the device continuously from sane_open() to
 sane_close() has any advantage, aside from not requiring users to quit
 xsane when they are done with a job.

The scanner is not a stateless device, so when someone begins a session,
 they need to own it from start to finish.  Examples of state:

   a)  The document in the scanner.  There is no point in five people being
        able to perform a preview scan on one person's document.

   b)  With ADF or automatic slide feeding, the document state is even more
        complex, because multiple sane_start()'s need to be called by the
        same user, sequentially.

   c)  Some scanners have internal state (which is not necessarily accessible
        by the driver).  For example, the microtek backend keeps track of 
        whether or not the scanner has calibrated itself for particular mode.
        By skipping calibration later, the backend saves time; but if the
        scanner has become calibrated for the wrong mode, it locks up.  The
        backend thus has to maintain control of the entire session, since
        it can't read this state from the scanner.

A printer and print spooler are not entirely different:  the printer device
 is not re-opened for each page; it stays locked for an entire print job.

With the scanner, when someone opens up a frontend to it, they should be
 effectively reserving/holding the scanner for their exclusive use.  Then
 they disconnect the frontend (e.g. quit) when they are done.  If someone
 else tries to connect in the meantime, they will discover that the scanner
 is already in use by someone else, so they wait.

An idea, perhaps for SANE2:  a fancy saned could actually maintain a queue
 of clients waiting to use the scanner.  This would be great in a large
 multi-user facility.  If multiple users try to claim the same scanner, 
 the requests line up (with a "pending/waiting/in-use-by-X" message given),
 and when the scanner is released by the last person, it becomes locked by
 the next person in line.

 >With network scanning it really would be bad if one opens a frontend
 >and keeps it running all the time and nobody else is able to use
 >the scanner because the device file is opend exclusive.

I don't quite understand the point here.  However I think that ideally saned
 would have a mode (maybe the only mode) where it opens the scanner device
 exclusively and keeps it open.  A standalone saned would thus be the 
 authority on who can use the scanner, both locally and remotely.  No
 worries about UID's on devices, and saned does all the authentication,
 even running through an SSL pipe if you want extra security over the net.
 But this is a slightly different topic....

-matt m.