[sane-devel] network scanner problems
Tue, 7 Aug 2001 23:41:27 +0200
On Tue, Aug 07, 2001 at 10:17:26PM +0200, Guido Socher wrote:
> Has anybody seen the following problem with the net backend
> in sane 1.0.5?
> The xscanimage program crashes because it tries to write
> data to a closed connection.
As far as I see only the data connection is closed, not the normal
control connection. But I'm not an expert in the net protocoll.
> The connection is closed in the sane_read() function in
> net.c because it executes this code:
> if (s->bytes_remaining == (size_t) - 1)
> char ch;
> /* turn off non-blocking I/O (s->data will be closed anyhow): */
> fcntl (s->data, F_SETFL, 0);
> /* read the status byte: */
> if (read (s->data, &ch, sizeof (ch)) != 1)
> ch = SANE_STATUS_IO_ERROR;
> do_cancel (s);
> return (SANE_Status) ch;
> That is s->bytes_remaining is -1 and then do_cancel(s) is
> called which closes the connection.
> Next xscanimage (ignoring the closed connection) tries
> to set some control options using this
> closed connection and that is where the sigpipe is received.
I don't think the problem is the closed data socket. I'm not sure if
something like (size_t) -1 is portable but it doesn't seem to be a
> The interessting thing is that the scan as such is ok, i.e I can
> see the full picture in the preview for a second.
> I have the feeling that the -1 record length is used as a special
> value to signal the end of the scan and unfortunately net.c
> thinks that this is an error. Is that possible?
It's the end of the scan (no more data) and the data socket is closed.
I have just tried this with the Mustek and mustek_usb backends. No
sigpipe or other error.
> It think that is is the case because scanning directly without
> the network inbetween works perfectly.
Maybe there is a problem in the net backend but sometimes backend
problems occur only when used over the net. By the way: what backend
and what scanner are we talking about? What platform and OS? Are the
server and host the same or different computers?
> Anybody who managed to get the network scan backend to work in
No problem here and I don't remember any bug report about net since
the great hunt for memory violations and leaks between 1.0.4 and 1.0.5.
> And here the debug sequence:
Huh? Why isn't there a [net] in front of the output?
> sane_read: max_length = 8192
> sane_read: next record length=-1 bytes
> sane_control_option: option 4, action 1
> sane_get_option_descriptor: option 4
> sane_control_option: option 22, action 1
Very similar here, but I don't get a
> Broken pipe
As net bails out only after the 2nd sane_control_option I think the
problem is somewhere else.
> Exit 141
Sorry, I have no idea, what's the exact problem.
By the way: net.c, also in sane_read:
DBG(3, "sane_read: max_length = %d\n", max_length);
if (s->data < 0)
*length = 0;
if (s->data < 0)
What is this intended to do (when can the second if be true?)?