until_no_eintr used on unrestartable IO, and cannot address all cases of EINTR.
Bug #496813 reported by
Martin Pool
This bug affects 2 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Fix Released
|
High
|
Andrew Bennetts | ||
2.0 |
Won't Fix
|
Undecided
|
Unassigned | ||
2.1 |
Fix Released
|
High
|
Andrew Bennetts | ||
2.2 |
Fix Released
|
High
|
Andrew Bennetts |
Bug Description
From thread 'until_no_eintr correct?'
> until_no_eintr is in a sense a dangerous function because it encourages you to solve just half the problem. Perhaps we should deprecate it in favour of things that really do read or write all the requested data.
Related branches
lp:~spiv/bzr/siginterrupt-to-avoid-eintr-496813-2.0
Rejected
for merging
into
lp:bzr/2.0
- Andrew Bennetts: Disapprove
- John A Meinel: Approve
- Martin Packman (community): Abstain
-
Diff: 94 lines (+42/-2)3 files modifiedNEWS (+16/-0)
bzrlib/breakin.py (+4/-2)
bzrlib/osutils.py (+22/-0)
lp:~spiv/bzr/siginterrupt-to-avoid-eintr-496813-2.1
Merged
into
lp:bzr/2.1
- John A Meinel: Approve
- Martin Packman (community): Abstain
-
Diff: 91 lines (+43/-3)2 files modifiedNEWS (+21/-2)
bzrlib/osutils.py (+22/-1)
lp:~spiv/bzr/no_until_no_eintr
- Martin Packman (community): Needs Information
- Martin Pool: Approve
-
Diff: 424 lines (+126/-66)5 files modifiedNEWS (+10/-3)
bzrlib/osutils.py (+77/-18)
bzrlib/smart/medium.py (+30/-44)
bzrlib/smart/protocol.py (+7/-1)
bzrlib/smart/server.py (+2/-0)
summary: |
- until_no_eintr ignores the possibility of partial success + until_no_eintr used on unrestartable IO, and cannot address all cases of + EINTR. |
To post a comment you must log in.
Specifically, the problem is that we often catch-and-retry on EINTR with operations that aren't safe to retry. Thanks very much to Martin <gzlist>, who has careful analysed the scope of the problem on the mailing list, and started writing patches towards it.
The current plan is to try use signal.siginterrupt on Python 2.6 to avoid this, at least for signal handlers that bzrlib registers. We probably should write a simple C extension for earlier Python versions to provide the same functionality.
It's possible that plugins and non-bzr programs that use bzrlib might register their own signal handlers; for them we should probably document that bzrlib doesn't expect EINTR in general so that 3rd-party code using our API ought to take care to also use siginterrupt or similar when registering signal handlers.
FWIW, the only signal handlers registered by bzrlib itself are:
* SIGWINCH (in bzrlib/ui/text.py) transport/ ssh.py) — but only to install the SIG_IGN handler, and only in a child process just before exec of an SSH subprocess, so no problem there.
* SIGQUIT (in bzrlib/breakin.py) [we can ignore SIGBREAK, which can't cause EINTR as it is windows-only]
* SIGINT (in bzrlib/
I'm not sure about the signal handlers that CPython installs automatically on VM startup; there's not many, but there is at least the SIGINT handler (to turn Ctrl-C into KeyboardInterrupt). So in addition to running siginterrupt for bzrlib's signal handlers for SIGWINCH and SIGQUIT, we may also want to do siginterrupt( SIGINT, False) in bzrlib. initialize( ). I'll investigate further before submitting my final patch.
If using siginterrupt is a sufficient fix for this issue, as I think and hope it will be, then we can also remove until_no_eintr (after deprecating), which will make everyone happy :)