nptl: Handle spurious EINTR when thread cancellation is disabled (BZ#29029)
Some Linux interfaces never restart after being interrupted by a signal handler, regardless of the use of SA_RESTART [1]. It means that for pthread cancellation, if the target thread disables cancellation with pthread_setcancelstate and calls such interfaces (like poll or select), it should not see spurious EINTR failures due the internal SIGCANCEL. However recent changes made pthread_cancel to always sent the internal signal, regardless of the target thread cancellation status or type. To fix it, the previous semantic is restored, where the cancel signal is only sent if the target thread has cancelation enabled in asynchronous mode. The cancel state and cancel type is moved back to cancelhandling and atomic operation are used to synchronize between threads. The patch essentially revert the following commits: 8c1c0aae nptl: Move cancel type out of cancelhandling 2b517425 nptl: Move cancel state out of cancelhandling 26cfbb71 nptl: Remove CANCELING_BITMASK However I changed the atomic operation to follow the internal C11 semantic and removed the MACRO usage, it simplifies a bit the resulting code (and removes another usage of the old atomic macros). Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu, and powerpc64-linux-gnu. [1] https://man7.org/linux/man-pages/man7/signal.7.html Reviewed-by:Florian Weimer <fweimer@redhat.com> Tested-by:
Aurelien Jarno <aurelien@aurel32.net>
Loading
-
mentioned in commit 290db095
-
mentioned in commit ba9c42ac
-
mentioned in commit 62be9681
-
mentioned in commit 71326f1f
-
mentioned in commit 68d3a9a6
-
mentioned in commit c7d36dce
-
mentioned in commit 97dd8b3f
-
mentioned in commit a7ec6363
-
mentioned in commit f27e5e21
-
mentioned in commit 7789a849
-
mentioned in commit 51e2d3b5
Please register or sign in to comment