[sane-devel] saned issues for remote scanner access

Henning Meier-Geinitz henning@meier-geinitz.de
Wed, 3 Mar 2004 20:28:38 +0100


[CCed to Herman Kuiper, as this discussion is also about sanetwain]
[Jim George tries to scan with sanetwain but saned always crashes]

Hi,

On Mon, Feb 23, 2004 at 06:57:16PM -0000, Jim George wrote:
> > So sane_open() wasn't ever called in the gt68xx backend. I even think
> > that sane_open() returned with an error (from the dll backend, because
> > no backend reported any scanner).
> >
> > So this code returns SANE_STATUS_INVALID:
> >
> >        reply.status = sane_open (name, &be_handle);
> >
> > And therefore get_handle is never called.
> >
> > So it looks like an error of the frontend/client to call
> > SANE_NET_CANCEL with an invalid handle.
> >
> > saned shouldn't crash anyway.
> >
> > I think the scanner was just not detected on the server by saned for
> > some reason (permission problem?).
> 
> Why would I be able to access the device happily through saned on the same
> server, but not be able to access the same device through the same
> instance of saned but the client is on another machine?

Ok, here is what really happens:

The frontend (sanetwain) asks saned for the device "" (empty string).
saned tells the dll backend to use the device "". The dll backend
opens the first backend (that's v4l usually) and tries to access the
first device of that backend. That fails because you don't have a
video card installed. Now sanetwain tries to cancel the scan which
fails because there wasn't any device or even a scan -> saned crashes.

So there are several bugs and issues:

- saned should not crash when getting ivalid handles. That's (hopefully) fixed in CVS.
- sanetwain should not call sane_cancel() when sane_open() hasn't
  succeeded. That should be fixed by the sanetwain author.
- the dll backend should be more intelligent when beeing askes for the device
  name "" (look at the list of devices and take the first one) maybe.
- sanetwain could look for a specific device name. It can use the
  list gotten from sane_get_devices() and use the first device to do that.

So apart from fixing sanetwain you can try one of the following
work-arounds:

- Tell sanetwain which device to use. I don't know how that works, but
  it must be possible otherwise sanetwain wouldn't work for anyone.
- Disable every backend in dll.conf of the server but "gt68xx". This
  should make sure that this is the first (and only) backend loaded
  and so with device "" your scanner should be found (untested).

Please tell us if it works.

Anyone can test this "bug" of the dll backend:

$ scanimage -L
device mustek_usb:libusb:001:004' is a Mustek 1200 CU flatbed scanner

At least one scanner should be listed. Now:

$ scanimage -d "" -T
scanimage: open of device  failed: Invalid argument

Now I have commented out everything but "mustek_usb":

$ scanimage -d "" -T
scanimage: scanning image of size 419x584 pixels at 8 bits/pixel
scanimage: acquiring gray frame, 8 bits/sample
scanimage: reading one scanline, 419 bytes... PASS
[...]

Bye,
  Henning