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

Commit3b8d23a

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 parent3a0e385 commit3b8d23a

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"
@@ -355,6 +356,7 @@ dsm_impl_posix_resize(int fd, off_t size)
355356
{
356357
intrc;
357358
intsave_errno;
359+
sigset_tsave_sigmask;
358360

359361
/*
360362
* Block all blockable signals, except SIGQUIT. posix_fallocate() can run
@@ -363,7 +365,7 @@ dsm_impl_posix_resize(int fd, off_t size)
363365
* conflicts), the retry loop might never succeed.
364366
*/
365367
if (IsUnderPostmaster)
366-
PG_SETMASK(&BlockSig);
368+
sigprocmask(SIG_SETMASK,&BlockSig,&save_sigmask);
367369

368370
pgstat_report_wait_start(WAIT_EVENT_DSM_ALLOCATE);
369371
#if defined(HAVE_POSIX_FALLOCATE)&& defined(__linux__)
@@ -402,7 +404,7 @@ dsm_impl_posix_resize(int fd, off_t size)
402404
if (IsUnderPostmaster)
403405
{
404406
save_errno=errno;
405-
PG_SETMASK(&UnBlockSig);
407+
sigprocmask(SIG_SETMASK,&save_sigmask,NULL);
406408
errno=save_errno;
407409
}
408410

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp