[sane-devel] saned/sanei net bug

2004-10-16 Thread Henning Meier-Geinitz
Hi,

On Fri, Oct 15, 2004 at 04:03:04PM +0200, Johannes Berg wrote:
 somehow saned/the sanei network layer seem to get buffering wrong.

I'm afraid that that's intentional. But that's only a guess.

 For example, I send the following:
 
 SANE_NET_INIT
 SANE_NET_GET_DEVICES
 SANE_NET_EXIT
 
 If I don't wait for the result from SANE_NET_GET_DEVICES before sending
 the control code for SANE_NET_EXIT, then the SANE_NET_EXIT code is
 discarded.

I think you must really read the result of any RPC before sending the
next one.

 I would assume that somewhere there's a buffering problem and the old
 buffer is simply dropped when the direction is changed or something.

That's done in sanei_w_set_direction().
Set SANE_DEBUG_SANEI_WIRE=255 and you'll even get a warning :-)

 The following works:
 (echo  -n -e \\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00 ;
 sleep .1 ; echo -n -e \\00\\00\\x00\\x01 ; sleep 1 ;
 echo -en \\x00\\x00\\x00\\x0A ) | nc localhost 6566 -q 1 | hd
 
 while this doesn't:
 (echo  -n -e \\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00 ;
 sleep .1 ; echo -n -e \\00\\00\\x00\\x01\\x00\\x00\\x00\\x0A
 )| nc localhost 6566 -q 1 | hd
 
 I think this is extremely counter-intuitive. TCP never guarantees
 message boundaries, so one wouldn't think that data is explicitly read
 by the application but then discarded.
 
I guess you are right but I don't really know how to fix that with the
current code. One option would be to set the wire to error state (and
exit?) when data is discarded.

Bye,
  Henning



[sane-devel] saned/sanei net bug

2004-10-15 Thread Johannes Berg
--=-b6utnWCS15VlnOe3728l
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

somehow saned/the sanei network layer seem to get buffering wrong.

For example, I send the following:

SANE_NET_INIT
SANE_NET_GET_DEVICES
SANE_NET_EXIT

If I don't wait for the result from SANE_NET_GET_DEVICES before sending
the control code for SANE_NET_EXIT, then the SANE_NET_EXIT code is
discarded.
I would assume that somewhere there's a buffering problem and the old
buffer is simply dropped when the direction is changed or something.

The following works:
(echo  -n -e \\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00 ;
sleep .1 ; echo -n -e \\00\\00\\x00\\x01 ; sleep 1 ;
echo -en \\x00\\x00\\x00\\x0A ) | nc localhost 6566 -q 1 | hd

while this doesn't:
(echo  -n -e \\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00 ;
sleep .1 ; echo -n -e \\00\\00\\x00\\x01\\x00\\x00\\x00\\x0A
)| nc localhost 6566 -q 1 | hd

I think this is extremely counter-intuitive. TCP never guarantees
message boundaries, so one wouldn't think that data is explicitly read
by the application but then discarded.

johannes

--=-b6utnWCS15VlnOe3728l
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-BEGIN PGP SIGNATURE-
Comment: Johannes Berg (SIP Solutions)

iQIVAwUAQW/YlaVg1VMiehFYAQLFPg//WIumi+9ZBodt1Ns31jdYGEiJa5z0hvkx
RivmO96L+BnL6Ld7Rut2mWx7ftE88yEhWnyzwBj3eFYseXi72n/2E12dpzyKyx+d
4ASxTTeatA/50Prdn2VzaPNe4zccKFpTJdYM7AXYDq3E49XyBrQ0fzin+rCaW0Pd
hjhD+bzzVuWxFxSgTsQn8T9z8h43W5BcUdD+a9fxZZMwRapXaFhTiFCTBxNH2zSI
yHCa7+Kx8xsGoTjsMt3BiggIn0k0ofNaSzht8BaYR0uelnKDEHrj+JdJgpfOz8OK
KcX3gPhsL5JdT4KbmuGyuJSkhZ9gdOGmneBkpX5WB/zUBvS8FxBLM0yyiAmqgzF1
rU9oqAg9psQgotkQY+koeJk8WnOHrstxgHX6rUO6Dbg2EIOv5tNDL/QZ1c/CAQY1
gcPf67was/FbFQ/WDhgyd4C3WdMDnaMrC9WZwIk1klxj6gFz0RqzcQbF97+s+OX0
yAgdl2V3b2SuYW9x9oojshxA6NN+yd3WrIhWxFFlOxkxrdoE1WGlPGwUvQwcVBja
KArLPRV4eHM6c8T0RyK6XWfC2aCOZ004EzTtPyOW8ARZZl026gGXNaF/jlw2L1PN
UiU8+spF5v4pBiQaiYmmEasGaaHmwHYL6oBI6PV2iMjUnFTz4dYM5EgyP3pSKypW
Ph0hiP5wYrc=
=L6hJ
-END PGP SIGNATURE-

--=-b6utnWCS15VlnOe3728l--