changeset: 69423:319f7af9ee5e branch: 3.1 parent: 69418:6e090d78857c user: Victor Stinner date: Mon Apr 18 16:25:56 2011 +0200 files: Misc/NEWS Modules/signalmodule.c description: 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. diff -r 6e090d78857c -r 319f7af9ee5e Misc/NEWS --- a/Misc/NEWS Mon Apr 18 10:11:21 2011 +0300 +++ b/Misc/NEWS Mon Apr 18 16:25:56 2011 +0200 @@ -55,6 +55,10 @@ 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 #11467: Fix urlparse behavior when handling urls which contains scheme specific part only digits. Patch by Santoso Wijaya. diff -r 6e090d78857c -r 319f7af9ee5e Modules/signalmodule.c --- a/Modules/signalmodule.c Mon Apr 18 10:11:21 2011 +0300 +++ b/Modules/signalmodule.c Mon Apr 18 16:25:56 2011 +0200 @@ -164,6 +164,20 @@ } 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; @@ -180,13 +194,7 @@ 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 @@ -932,9 +940,7 @@ void PyErr_SetInterrupt(void) { - is_tripped = 1; - Handlers[SIGINT].tripped = 1; - Py_AddPendingCall((int (*)(void *))PyErr_CheckSignals, NULL); + trip_signal(SIGINT); } void