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

Commitc75b6b4

Browse files
committed
Make dsm_impl_posix_resize more future-proof.
Commit4518c79 blocks signals for a short region of code, but itassumed that whatever called it had the signal mask set to UnBlockSig onentry. That may be true today (or may even not be, in extensions in thewild), but it would be better not to make that assumption. We shouldsave-and-restore the caller's signal mask.The PG_SETMASK() portability macro couldn't be used for that, which iswhy it wasn't done before. But... considering that commita65e086established back in 9.6 that supported POSIX systems have sigprocmask(),and that this is POSIX-only code, there is no reason not to use standardsigprocmask() directly to achieve that.Back-patch to all supported releases, like4518c79 and80845b7.Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/CA%2BhUKGKx6Biq7_UuV0kn9DW%2B8QWcpJC1qwhizdtD9tN-fn0H0g%40mail.gmail.com
1 parent65a0cf8 commitc75b6b4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

‎src/backend/storage/ipc/dsm_impl.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include"postgres.h"
5050

5151
#include<fcntl.h>
52+
#include<signal.h>
5253
#include<unistd.h>
5354
#ifndefWIN32
5455
#include<sys/mman.h>
@@ -62,7 +63,7 @@
6263
#endif
6364

6465
#include"common/file_perm.h"
65-
#include"libpq/pqsignal.h"/* for PG_SETMASK macro */
66+
#include"libpq/pqsignal.h"
6667
#include"miscadmin.h"
6768
#include"pgstat.h"
6869
#include"portability/mem.h"
@@ -352,6 +353,7 @@ dsm_impl_posix_resize(int fd, off_t size)
352353
{
353354
intrc;
354355
intsave_errno;
356+
sigset_tsave_sigmask;
355357

356358
/*
357359
* Block all blockable signals, except SIGQUIT. posix_fallocate() can run
@@ -360,7 +362,7 @@ dsm_impl_posix_resize(int fd, off_t size)
360362
* conflicts), the retry loop might never succeed.
361363
*/
362364
if (IsUnderPostmaster)
363-
PG_SETMASK(&BlockSig);
365+
sigprocmask(SIG_SETMASK,&BlockSig,&save_sigmask);
364366

365367
/* Truncate (or extend) the file to the requested size. */
366368
do
@@ -403,7 +405,7 @@ dsm_impl_posix_resize(int fd, off_t size)
403405
if (IsUnderPostmaster)
404406
{
405407
save_errno=errno;
406-
PG_SETMASK(&UnBlockSig);
408+
sigprocmask(SIG_SETMASK,&save_sigmask,NULL);
407409
errno=save_errno;
408410
}
409411

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp