until_no_eintr correct?

John Arbash Meinel john at arbash-meinel.com
Sat Dec 12 20:54:27 GMT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've been digging through some of the networking code, and I've seen a
lot of code that looks like this:

SmartServerPipeStreamMedium._write_out(bytes):
        osutils.until_no_eintr(self._out.write, bytes)

Which looks like it will catch EINTR and keep trying to call write(bytes).

However, wouldn't we have already written some of those bytes to the
file when EINTR comes along? For example, imagine you are writing 40MB
to the ssh file handle, to send it across the network to the caller. If
you wrote 5MB and then got EINTR, wouldn't the call start over at the
beginning and re-write those first 5MB?

Or is EINTR something that can only happen as an all-or-nothing. So if
you get EINTR none of the bytes have been written yet.

I'm guessing that the code is actually pretty broken, which means that
dropping into a debugger while streaming data is actually going to do
very strange things to your data stream...

Can someone confirm/deny?

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkskAwMACgkQJdeBCYSNAAMnNACgtzvF8du44joyT0MNql0eD51Q
Od0An3mfOvWjjLbSWYFeSehKVv6rF9Ej
=Yh3D
-----END PGP SIGNATURE-----



More information about the bazaar mailing list