[sane-devel] Bug in net.c sane_exit
Henning Meier-Geinitz
henning at meier-geinitz.de
Fri Feb 21 17:23:12 GMT 2003
Hi,
On Fri, Feb 21, 2003 at 08:36:57AM -0800, George Garvey wrote:
> On Fri, Feb 21, 2003 at 04:13:21PM +0100, Henning Meier-Geinitz wrote:
> > On Thu, Feb 20, 2003 at 04:14:51PM -0800, George Garvey wrote:
> > > Doesn't set global variables to NULL.
> > Right. I'm curious: Which frontend are you using? Most frontends don't
> > call sane_exit and then sane_init again, as far as I know, that's why
> > I'm asking.
>
> I'm linking libsane-net into our in-house developed contact manager. It
> tends to be run by users all day long. The scanner will only
> occasionally be used. So I chose to call sane_exit after their "last"
> scan, since it may be hours (or minutes, no way of knowing) until they
> want to scan again.
I think that's ok. Backends should free all resources that are
connected to devices when calling sane_close, but running sane_exit
will also free the device list. Also, usually sane_init does a new
detection of devices, which is good if it's a long time since the last
detection was done. At least if devices may change (USB).
> It may have been over cautious, but I was concerned about using up
> resources by leaving sane initialized. From a cursory look, it appears
> that a connection to saned is kept open, and may lock the scanner used
> (of that I'm not certain -- sane_close may free up the scanner -- I
> didn't investigate that closely enough to say).
The network connection stays open until sane_exit (or the timeout of
60 minutes is reached). That's because sane_get_devices may be called
at any time.
> > Thanks for your patch. Can you try this alternative one (against
> > current CVS)? I think it's more obvious to initialize in sane_init.
>
> That works, too. The rest of the devices probably need to be checked for
> this, since as you say, normal frontends are scan only programs and
> don't do this.
I'll add that to the TODO list.
Bye,
Henning
More information about the sane-devel
mailing list