bpo-30768: Recompute timeout on interrupted lock (GH-4103)
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 24 Oct 2017 23:53:32 +0000 (16:53 -0700)
committerGitHub <noreply@github.com>
Tue, 24 Oct 2017 23:53:32 +0000 (16:53 -0700)
commit850a18e03e8f8309bc8c39adc6e7d51a4568cd9a
tree56455b89cb152566734d1fc5de5c70029c3baa70
parent3557b05c5a7dfd7d97ddfd3b79aefd53d25e5132
bpo-30768: Recompute timeout on interrupted lock (GH-4103)

Fix the pthread+semaphore implementation of
PyThread_acquire_lock_timed() when called with timeout > 0 and
intr_flag=0: recompute the timeout if sem_timedwait() is interrupted
by a signal (EINTR).

See also the PEP 475.

The pthread implementation of PyThread_acquire_lock() now fails with
a fatal error if the timeout is larger than PY_TIMEOUT_MAX, as done
in the Windows implementation.

The check prevents any risk of overflow in PyThread_acquire_lock().

Add also PY_DWORD_MAX constant.
Include/pyport.h
Include/pythread.h
Misc/NEWS.d/next/Library/2017-10-24-12-00-16.bpo-30768.Om8Yj_.rst [new file with mode: 0644]
Modules/_threadmodule.c
Modules/_winapi.c
Modules/clinic/_winapi.c.h
Modules/posixmodule.c
Python/thread_nt.h
Python/thread_pthread.h