Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f98b847

Browse files
committed
Use signals for postmaster death on FreeBSD.
Use FreeBSD 11.2's new support for detecting parent process death to make PostmasterIsAlive() very cheap, as was done for Linux in an earlier commit. Author: Thomas Munro Discussion: https://postgr.es/m/7261eb39-0369-f2f4-1bb5-62f3b6083b5e@iki.fi
1 parent 9f09529 commit f98b847

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

configure

+1-1
Original file line numberDiff line numberDiff line change
@@ -12494,7 +12494,7 @@ $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
1249412494
fi
1249512495

1249612496

12497-
for ac_header in atomic.h crypt.h dld.h fp_class.h getopt.h ieeefp.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/ipc.h sys/prctl.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/tas.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h
12497+
for ac_header in atomic.h crypt.h dld.h fp_class.h getopt.h ieeefp.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/ipc.h sys/prctl.h sys/procctl.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/tas.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h
1249812498
do :
1249912499
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
1250012500
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"

configure.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ AC_SUBST(UUID_LIBS)
12601260

12611261
AC_HEADER_STDBOOL
12621262

1263-
AC_CHECK_HEADERS([atomic.h crypt.h dld.h fp_class.h getopt.h ieeefp.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/ipc.h sys/prctl.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/tas.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h])
1263+
AC_CHECK_HEADERS([atomic.h crypt.h dld.h fp_class.h getopt.h ieeefp.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/ipc.h sys/prctl.h sys/procctl.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/tas.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h])
12641264

12651265
# On BSD, test for net/if.h will fail unless sys/socket.h
12661266
# is included first.

src/backend/storage/ipc/pmsignal.c

+3
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ PostmasterDeathSignalInit(void)
379379
#if defined(PR_SET_PDEATHSIG)
380380
if (prctl(PR_SET_PDEATHSIG, signum) < 0)
381381
elog(ERROR, "could not request parent death signal: %m");
382+
#elif defined(PROC_PDEATHSIG_CTL)
383+
if (procctl(P_PID, 0, PROC_PDEATHSIG_CTL, &signum) < 0)
384+
elog(ERROR, "could not request parent death signal: %m");
382385
#else
383386
#error "USE_POSTMASTER_DEATH_SIGNAL set, but there is no mechanism to request the signal"
384387
#endif

src/include/pg_config.h.in

+3
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,9 @@
603603
/* Define to 1 if you have the <sys/prctl.h> header file. */
604604
#undef HAVE_SYS_PRCTL_H
605605

606+
/* Define to 1 if you have the <sys/procctl.h> header file. */
607+
#undef HAVE_SYS_PROCCTL_H
608+
606609
/* Define to 1 if you have the <sys/pstat.h> header file. */
607610
#undef HAVE_SYS_PSTAT_H
608611

src/include/storage/pmsignal.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
#include "sys/prctl.h"
1919
#endif
2020

21+
#ifdef HAVE_SYS_PROCCTL_H
22+
#include "sys/procctl.h"
23+
#endif
24+
2125
/*
2226
* Reasons for signaling the postmaster. We can cope with simultaneous
2327
* signals for different reasons. If the same reason is signaled multiple
@@ -66,7 +70,8 @@ extern void PostmasterDeathSignalInit(void);
6670
* the parent dies. Checking the flag first makes PostmasterIsAlive() a lot
6771
* cheaper in usual case that the postmaster is alive.
6872
*/
69-
#if defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_PDEATHSIG)
73+
#if (defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_PDEATHSIG)) || \
74+
(defined(HAVE_SYS_PROCCTL_H) && defined(PROC_PDEATHSIG_CTL))
7075
#define USE_POSTMASTER_DEATH_SIGNAL
7176
#endif
7277

0 commit comments

Comments
 (0)