Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit873ab97

Browse files
committed
Use SA_RESTART for all signals, including SIGALRM.
The exclusion of SIGALRM dates back to Berkeley days, when Postgres usedSIGALRM in only one very short stretch of code. Nowadays, allowing it tointerrupt kernel calls doesn't seem like a very good idea, since its usefor statement_timeout means SIGALRM could occur anyplace in the code, andthere are far too many call sites where we aren't prepared to deal withEINTR failures. When third-party code is taken into consideration, itseems impossible that we ever could be fully EINTR-proof, so better touse SA_RESTART always and deal with the implications of that. One suchimplication is that we should not assume pg_usleep() will be terminatedearly by a signal. Therefore, long sleeps should probably be replacedby WaitLatch operations where practical.Back-patch to 9.3 so we can get some beta testing on this change.
1 parent5242fef commit873ab97

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

‎src/backend/port/sysv_sema.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,8 @@ PGSemaphoreLock(PGSemaphore sema, bool interruptOK)
405405
* it's necessary for cancel/die interrupts to be serviced directly by the
406406
* signal handler.On these platforms the behavior is really the same
407407
* whether the signal arrives just before the semop() begins, or while it
408-
* is waiting.The loop on EINTR is thus important only forother types
409-
*of interrupts.
408+
* is waiting.The loop on EINTR is thus important only forplatforms
409+
*without SA_RESTART.
410410
*/
411411
do
412412
{

‎src/port/pqsignal.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ pqsignal(int signo, pqsigfunc func)
6060

6161
act.sa_handler=func;
6262
sigemptyset(&act.sa_mask);
63-
act.sa_flags=0;
64-
if (signo!=SIGALRM)
65-
act.sa_flags |=SA_RESTART;
63+
act.sa_flags=SA_RESTART;
6664
#ifdefSA_NOCLDSTOP
6765
if (signo==SIGCHLD)
6866
act.sa_flags |=SA_NOCLDSTOP;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp