eio icon indicating copy to clipboard operation
eio copied to clipboard

Check EINTR is handled correctly

Open talex5 opened this issue 2 years ago • 2 comments

System calls need to be retried if they return EINTR (unless this was due to them being cancelled; you don't always get ECANCELED in that case).

There is some handling already, e.g. here's eio_linux handling EINTR for rw ops:

https://github.com/ocaml-multicore/eio/blob/85841dc0b779a920bc4b1daca9172456e33988ee/lib_eio_linux/eio_linux.ml#L519-L527

Check if we need this in more places, and also check the eio_luv backend.

@hannesm notes in https://github.com/mirage/mirage-crypto/pull/155#issuecomment-1106412128 that getrandom needs this too.

talex5 avatar Apr 22 '22 13:04 talex5

We could also just enforce SA_RESTART. Not sure how you feel about eio calling sigaction though.

haesbaert avatar Jul 25 '22 11:07 haesbaert

Reading signal(7), it seems hard to avoid EINTR in all cases. In particular, it seems that SIGCONT can generate EINTR.

It's also a bit unclear to me what happens with signals and io_uring operations. I would expect that the io_uring_enter call would return EINTR rather than the individual operations, so maybe the retry logic above isn't even needed. That code has been there since the very first commit by @avsm; I don't know if it was needed for something.

talex5 avatar Jul 25 '22 13:07 talex5

As far as I know this is working correctly everywhere, so I'll close this. We can reopen if we find any remaining places we missed.

talex5 avatar Mar 28 '23 11:03 talex5