diff options
| author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-04-18 14:33:28 (GMT) |
|---|---|---|
| committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-04-18 14:33:28 (GMT) |
| commit | 33feeab598f5b0926a2835837c70c257f9be6749 (patch) | |
| tree | 705dd9ecea80c8857cdea1a96972730f46c28a4b | |
| parent | 8e4eeef4ee8589ecaf8537b1060920f9c5027de7 (diff) | |
| download | cpython-33feeab598f5b0926a2835837c70c257f9be6749.zip cpython-33feeab598f5b0926a2835837c70c257f9be6749.tar.gz cpython-33feeab598f5b0926a2835837c70c257f9be6749.tar.bz2 | |
(Merge 3.1) Issue #11768: The signal handler of the signal module only calls
Py_AddPendingCall() for the first signal to fix a deadlock on reentrant or
parallel calls. PyErr_SetInterrupt() writes also into the wake up file.
| -rw-r--r-- | Misc/NEWS | 4 | ||||
| -rw-r--r-- | Modules/signalmodule.c | 26 |
2 files changed, 20 insertions, 10 deletions
@@ -55,6 +55,10 @@ Core and Builtins Library ------- +- Issue #11768: The signal handler of the signal module only calls + Py_AddPendingCall() for the first signal to fix a deadlock on reentrant or + parallel calls. PyErr_SetInterrupt() writes also into the wake up file. + - Issue #11442: Add a charset parameter to the Content-type in SimpleHTTPServer to avoid XSS attacks. diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index 2441099..f306bba 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -167,6 +167,20 @@ checksignals_witharg(void * unused) } static void +trip_signal(int sig_num) +{ + Handlers[sig_num].tripped = 1; + if (is_tripped) + return; + /* Set is_tripped after setting .tripped, as it gets + cleared in PyErr_CheckSignals() before .tripped. */ + is_tripped = 1; + Py_AddPendingCall(checksignals_witharg, NULL); + if (wakeup_fd != -1) + write(wakeup_fd, "\0", 1); +} + +static void signal_handler(int sig_num) { int save_errno = errno; @@ -183,13 +197,7 @@ signal_handler(int sig_num) if (getpid() == main_pid) #endif { - Handlers[sig_num].tripped = 1; - /* Set is_tripped after setting .tripped, as it gets - cleared in PyErr_CheckSignals() before .tripped. */ - is_tripped = 1; - Py_AddPendingCall(checksignals_witharg, NULL); - if (wakeup_fd != -1) - write(wakeup_fd, "\0", 1); + trip_signal(sig_num); } #ifndef HAVE_SIGACTION @@ -934,9 +942,7 @@ PyErr_CheckSignals(void) void PyErr_SetInterrupt(void) { - is_tripped = 1; - Handlers[SIGINT].tripped = 1; - Py_AddPendingCall((int (*)(void *))PyErr_CheckSignals, NULL); + trip_signal(SIGINT); } void |
