Incorrect handling of EINTR in Bazaar

Martin (gzlist) gzlist at googlemail.com
Sat Feb 20 00:13:29 GMT 2010


On 19/02/2010, Martin Pool <mbp at canonical.com> wrote:
>>
>> Anyway, you're right, we can't usefully catch EINTR from Python in this
>> case.  Well, actually, we could remember the fileno, and if EINTR occurs
>> then until_no_eintr(os.close, fileno), but that's probably not worth the
>> effort just to avoid leaking an fd in this corner case.
>
> No, actually I think it is important that you handle this, because
> close has larger effects than just closing the filehandle.  If it is
> never successfully called then eg the network socket may not close,
> and this is just the kind of case where you are likely to see eintr.

Okay, this is the sort of hairy territory I think should be avoided
without being looked at upstream first. For pipes, the glibc
documentation has an explicit warning that fclose should be used with
streams to make sure the internal buffers are flushed etc. And for
sockets, there are several platforms where os.close uses a different
function from the one socket.close uses. It would be all too easy to
write a 'workaround' that was actually far less robust than the base
function it was replacing.

Martin



More information about the bazaar mailing list