40 #ifdef HAVE_SYS_EPOLL_H
41 #include <sys/epoll.h>
43 #ifdef HAVE_SYS_EVENT_H
44 #include <sys/event.h>
46 #ifdef HAVE_SYS_SIGNALFD_H
47 #include <sys/signalfd.h>
72 #if defined(WAIT_USE_EPOLL) || defined(WAIT_USE_POLL) || \
73 defined(WAIT_USE_KQUEUE) || defined(WAIT_USE_WIN32)
75 #elif defined(HAVE_SYS_EPOLL_H)
76 #define WAIT_USE_EPOLL
77 #elif defined(HAVE_KQUEUE)
78 #define WAIT_USE_KQUEUE
79 #elif defined(HAVE_POLL)
82 #define WAIT_USE_WIN32
84 #error "no wait set implementation available"
91 #if defined(WAIT_USE_POLL) || defined(WAIT_USE_EPOLL)
92 #if defined(WAIT_USE_SELF_PIPE) || defined(WAIT_USE_SIGNALFD)
94 #elif defined(WAIT_USE_EPOLL) && defined(HAVE_SYS_SIGNALFD_H)
95 #define WAIT_USE_SIGNALFD
97 #define WAIT_USE_SELF_PIPE
131 #if defined(WAIT_USE_EPOLL)
134 struct epoll_event *epoll_ret_events;
135 #elif defined(WAIT_USE_KQUEUE)
138 struct kevent *kqueue_ret_events;
139 bool report_postmaster_not_running;
140 #elif defined(WAIT_USE_POLL)
143 #elif defined(WAIT_USE_WIN32)
158 #define LatchWaitSetLatchPos 0
165 #ifdef WAIT_USE_SIGNALFD
167 static int signal_fd = -1;
170 #ifdef WAIT_USE_SELF_PIPE
183 #if defined(WAIT_USE_SELF_PIPE) || defined(WAIT_USE_SIGNALFD)
184 static void drain(
void);
187 #if defined(WAIT_USE_EPOLL)
189 #elif defined(WAIT_USE_KQUEUE)
191 #elif defined(WAIT_USE_POLL)
193 #elif defined(WAIT_USE_WIN32)
198 WaitEvent *occurred_events,
int nevents);
205 .
name =
"WaitEventSet",
234 #if defined(WAIT_USE_SELF_PIPE)
286 if (pipe(pipefd) < 0)
288 if (fcntl(pipefd[0], F_SETFL, O_NONBLOCK) == -1)
289 elog(
FATAL,
"fcntl(F_SETFL) failed on read-end of self-pipe: %m");
290 if (fcntl(pipefd[1], F_SETFL, O_NONBLOCK) == -1)
291 elog(
FATAL,
"fcntl(F_SETFL) failed on write-end of self-pipe: %m");
292 if (fcntl(pipefd[0], F_SETFD, FD_CLOEXEC) == -1)
293 elog(
FATAL,
"fcntl(F_SETFD) failed on read-end of self-pipe: %m");
294 if (fcntl(pipefd[1], F_SETFD, FD_CLOEXEC) == -1)
295 elog(
FATAL,
"fcntl(F_SETFD) failed on write-end of self-pipe: %m");
308 #ifdef WAIT_USE_SIGNALFD
309 sigset_t signalfd_mask;
321 (void)
close(signal_fd);
331 sigemptyset(&signalfd_mask);
332 sigaddset(&signalfd_mask, SIGURG);
333 signal_fd = signalfd(-1, &signalfd_mask, SFD_NONBLOCK | SFD_CLOEXEC);
339 #ifdef WAIT_USE_KQUEUE
366 #if defined(WAIT_USE_POLL)
376 #if defined(WAIT_USE_SELF_PIPE)
384 #if defined(WAIT_USE_SIGNALFD)
401 #if defined(WAIT_USE_SELF_PIPE)
404 #elif defined(WAIT_USE_SIGNALFD)
407 #elif defined(WAIT_USE_WIN32)
408 latch->event = CreateEvent(NULL, TRUE, FALSE, NULL);
409 if (latch->event == NULL)
410 elog(
ERROR,
"CreateEvent failed: error code %lu", GetLastError());
433 SECURITY_ATTRIBUTES
sa;
438 ZeroMemory(&
sa,
sizeof(
sa));
439 sa.nLength =
sizeof(
sa);
440 sa.bInheritHandle = TRUE;
442 latch->event = CreateEvent(&
sa, TRUE, FALSE, NULL);
443 if (latch->event == NULL)
444 elog(
ERROR,
"CreateEvent failed: error code %lu", GetLastError());
470 #if defined(WAIT_USE_SELF_PIPE)
473 #elif defined(WAIT_USE_SIGNALFD)
480 elog(
PANIC,
"latch already owned by PID %d", owner_pid);
541 wait_event_info) == 0)
566 long timeout,
uint32 wait_event_info)
686 #if defined(WAIT_USE_SELF_PIPE)
695 kill(owner_pid, SIGURG);
706 handle = latch->event;
766 #if defined(WAIT_USE_EPOLL)
767 sz +=
MAXALIGN(
sizeof(
struct epoll_event) * nevents);
768 #elif defined(WAIT_USE_KQUEUE)
769 sz +=
MAXALIGN(
sizeof(
struct kevent) * nevents);
770 #elif defined(WAIT_USE_POLL)
771 sz +=
MAXALIGN(
sizeof(
struct pollfd) * nevents);
772 #elif defined(WAIT_USE_WIN32)
774 sz +=
MAXALIGN(
sizeof(HANDLE) * (nevents + 1));
777 if (resowner != NULL)
788 #if defined(WAIT_USE_EPOLL)
789 set->epoll_ret_events = (
struct epoll_event *)
data;
791 #elif defined(WAIT_USE_KQUEUE)
792 set->kqueue_ret_events = (
struct kevent *)
data;
794 #elif defined(WAIT_USE_POLL)
797 #elif defined(WAIT_USE_WIN32)
798 set->handles = (HANDLE)
data;
806 if (resowner != NULL)
809 set->
owner = resowner;
812 #if defined(WAIT_USE_EPOLL)
818 set->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
819 if (set->epoll_fd < 0)
824 #elif defined(WAIT_USE_KQUEUE)
830 set->kqueue_fd = kqueue();
831 if (set->kqueue_fd < 0)
836 if (fcntl(set->kqueue_fd, F_SETFD, FD_CLOEXEC) == -1)
838 int save_errno = errno;
840 close(set->kqueue_fd);
843 elog(
ERROR,
"fcntl(F_SETFD) failed on kqueue descriptor: %m");
845 set->report_postmaster_not_running =
false;
846 #elif defined(WAIT_USE_WIN32)
882 #if defined(WAIT_USE_EPOLL)
883 close(set->epoll_fd);
885 #elif defined(WAIT_USE_KQUEUE)
886 close(set->kqueue_fd);
888 #elif defined(WAIT_USE_WIN32)
904 WSAEventSelect(cur_event->fd, NULL, 0);
905 WSACloseEvent(set->handles[cur_event->pos + 1]);
919 #if defined(WAIT_USE_EPOLL)
920 close(set->epoll_fd);
922 #elif defined(WAIT_USE_KQUEUE)
980 elog(
ERROR,
"cannot wait on a latch owned by another process");
982 elog(
ERROR,
"cannot wait on more than one latch");
984 elog(
ERROR,
"latch events only support being set");
989 elog(
ERROR,
"cannot wait on latch without a specified latch");
994 elog(
ERROR,
"cannot wait on socket event without a socket");
999 event->events = events;
1000 event->user_data = user_data;
1002 event->reset =
false;
1009 #if defined(WAIT_USE_SELF_PIPE)
1011 #elif defined(WAIT_USE_SIGNALFD)
1012 event->fd = signal_fd;
1015 #ifdef WAIT_USE_EPOLL
1028 #if defined(WAIT_USE_EPOLL)
1029 WaitEventAdjustEpoll(set, event, EPOLL_CTL_ADD);
1030 #elif defined(WAIT_USE_KQUEUE)
1031 WaitEventAdjustKqueue(set, event, 0);
1032 #elif defined(WAIT_USE_POLL)
1034 #elif defined(WAIT_USE_WIN32)
1035 WaitEventAdjustWin32(set, event);
1052 #if defined(WAIT_USE_KQUEUE)
1056 Assert(pos < set->nevents);
1058 event = &set->
events[pos];
1059 #if defined(WAIT_USE_KQUEUE)
1060 old_events =
event->
events;
1069 if (events == event->
events &&
1076 elog(
ERROR,
"cannot modify latch event");
1081 elog(
ERROR,
"cannot modify postmaster death event");
1085 event->events = events;
1090 elog(
ERROR,
"cannot wait on a latch owned by another process");
1100 #if defined(WAIT_USE_WIN32)
1108 #if defined(WAIT_USE_EPOLL)
1109 WaitEventAdjustEpoll(set, event, EPOLL_CTL_MOD);
1110 #elif defined(WAIT_USE_KQUEUE)
1111 WaitEventAdjustKqueue(set, event, old_events);
1112 #elif defined(WAIT_USE_POLL)
1114 #elif defined(WAIT_USE_WIN32)
1115 WaitEventAdjustWin32(set, event);
1119 #if defined(WAIT_USE_EPOLL)
1126 struct epoll_event epoll_ev;
1130 epoll_ev.data.ptr = event;
1132 epoll_ev.
events = EPOLLERR | EPOLLHUP;
1138 epoll_ev.events |= EPOLLIN;
1142 epoll_ev.events |= EPOLLIN;
1152 epoll_ev.events |= EPOLLIN;
1154 epoll_ev.events |= EPOLLOUT;
1156 epoll_ev.events |= EPOLLRDHUP;
1164 rc = epoll_ctl(set->epoll_fd,
action, event->
fd, &epoll_ev);
1169 errmsg(
"%s() failed: %m",
1174 #if defined(WAIT_USE_POLL)
1178 struct pollfd *pollfd = &set->
pollfds[
event->pos];
1180 pollfd->revents = 0;
1181 pollfd->fd =
event->fd;
1187 pollfd->events = POLLIN;
1191 pollfd->events = POLLIN;
1200 pollfd->events |= POLLIN;
1202 pollfd->events |= POLLOUT;
1205 pollfd->events |= POLLRDHUP;
1213 #if defined(WAIT_USE_KQUEUE)
1221 #define AccessWaitEvent(k_ev) (*((WaitEvent **)(&(k_ev)->udata)))
1224 WaitEventAdjustKqueueAdd(
struct kevent *k_ev,
int filter,
int action,
1227 k_ev->ident =
event->fd;
1228 k_ev->filter = filter;
1232 AccessWaitEvent(k_ev) = event;
1236 WaitEventAdjustKqueueAddPostmaster(
struct kevent *k_ev,
WaitEvent *event)
1240 k_ev->filter = EVFILT_PROC;
1241 k_ev->flags = EV_ADD;
1242 k_ev->fflags = NOTE_EXIT;
1244 AccessWaitEvent(k_ev) = event;
1248 WaitEventAdjustKqueueAddLatch(
struct kevent *k_ev,
WaitEvent *event)
1251 k_ev->ident = SIGURG;
1252 k_ev->filter = EVFILT_SIGNAL;
1253 k_ev->flags = EV_ADD;
1256 AccessWaitEvent(k_ev) = event;
1266 struct kevent k_ev[2];
1268 bool new_filt_read =
false;
1269 bool old_filt_read =
false;
1270 bool new_filt_write =
false;
1271 bool old_filt_write =
false;
1273 if (old_events == event->
events)
1290 WaitEventAdjustKqueueAddPostmaster(&k_ev[count++], event);
1295 WaitEventAdjustKqueueAddLatch(&k_ev[count++], event);
1305 old_filt_read =
true;
1307 new_filt_read =
true;
1309 old_filt_write =
true;
1311 new_filt_write =
true;
1312 if (old_filt_read && !new_filt_read)
1313 WaitEventAdjustKqueueAdd(&k_ev[count++], EVFILT_READ, EV_DELETE,
1315 else if (!old_filt_read && new_filt_read)
1316 WaitEventAdjustKqueueAdd(&k_ev[count++], EVFILT_READ, EV_ADD,
1318 if (old_filt_write && !new_filt_write)
1319 WaitEventAdjustKqueueAdd(&k_ev[count++], EVFILT_WRITE, EV_DELETE,
1321 else if (!old_filt_write && new_filt_write)
1322 WaitEventAdjustKqueueAdd(&k_ev[count++], EVFILT_WRITE, EV_ADD,
1332 rc = kevent(set->kqueue_fd, &k_ev[0], count, NULL, 0, NULL);
1344 (errno == ESRCH || errno == EACCES))
1345 set->report_postmaster_not_running =
true;
1349 errmsg(
"%s() failed: %m",
1361 set->report_postmaster_not_running =
true;
1367 #if defined(WAIT_USE_WIN32)
1371 HANDLE *handle = &set->handles[
event->pos + 1];
1376 *handle = set->
latch->event;
1380 *handle = PostmasterHandle;
1384 int flags = FD_CLOSE;
1391 flags |= FD_CONNECT;
1395 if (*handle == WSA_INVALID_EVENT)
1397 *handle = WSACreateEvent();
1398 if (*handle == WSA_INVALID_EVENT)
1399 elog(
ERROR,
"failed to create event for socket: error code %d",
1402 if (WSAEventSelect(event->
fd, *handle, flags) != 0)
1403 elog(
ERROR,
"failed to set up event for socket: error code %d",
1425 WaitEvent *occurred_events,
int nevents,
1428 int returned_events = 0;
1431 long cur_timeout = -1;
1442 Assert(timeout >= 0 && timeout <= INT_MAX);
1443 cur_timeout = timeout;
1456 while (returned_events == 0)
1517 occurred_events, nevents);
1528 returned_events = rc;
1531 if (returned_events == 0 && timeout >= 0)
1536 if (cur_timeout <= 0)
1546 return returned_events;
1550 #if defined(WAIT_USE_EPOLL)
1562 WaitEvent *occurred_events,
int nevents)
1564 int returned_events = 0;
1567 struct epoll_event *cur_epoll_event;
1570 rc = epoll_wait(set->epoll_fd, set->epoll_ret_events,
1582 errmsg(
"%s() failed: %m",
1598 for (cur_epoll_event = set->epoll_ret_events;
1599 cur_epoll_event < (set->epoll_ret_events + rc) &&
1600 returned_events < nevents;
1604 cur_event = (
WaitEvent *) cur_epoll_event->data.ptr;
1606 occurred_events->
pos = cur_event->
pos;
1608 occurred_events->
events = 0;
1611 cur_epoll_event->events & (EPOLLIN | EPOLLERR | EPOLLHUP))
1625 cur_epoll_event->events & (EPOLLIN | EPOLLERR | EPOLLHUP))
1655 (cur_epoll_event->events & (EPOLLIN | EPOLLERR | EPOLLHUP)))
1662 (cur_epoll_event->events & (EPOLLOUT | EPOLLERR | EPOLLHUP)))
1669 (cur_epoll_event->events & (EPOLLRDHUP | EPOLLERR | EPOLLHUP)))
1675 if (occurred_events->
events != 0)
1677 occurred_events->
fd = cur_event->
fd;
1684 return returned_events;
1687 #elif defined(WAIT_USE_KQUEUE)
1698 WaitEvent *occurred_events,
int nevents)
1700 int returned_events = 0;
1703 struct kevent *cur_kqueue_event;
1704 struct timespec timeout;
1705 struct timespec *timeout_p;
1707 if (cur_timeout < 0)
1711 timeout.tv_sec = cur_timeout / 1000;
1712 timeout.tv_nsec = (cur_timeout % 1000) * 1000000;
1713 timeout_p = &timeout;
1720 if (
unlikely(set->report_postmaster_not_running))
1730 rc = kevent(set->kqueue_fd, NULL, 0,
1731 set->kqueue_ret_events,
1744 errmsg(
"%s() failed: %m",
1760 for (cur_kqueue_event = set->kqueue_ret_events;
1761 cur_kqueue_event < (set->kqueue_ret_events + rc) &&
1762 returned_events < nevents;
1766 cur_event = AccessWaitEvent(cur_kqueue_event);
1768 occurred_events->
pos = cur_event->
pos;
1770 occurred_events->
events = 0;
1773 cur_kqueue_event->filter == EVFILT_SIGNAL)
1784 cur_kqueue_event->filter == EVFILT_PROC &&
1785 (cur_kqueue_event->fflags & NOTE_EXIT) != 0)
1792 set->report_postmaster_not_running =
true;
1808 (cur_kqueue_event->filter == EVFILT_READ))
1815 (cur_kqueue_event->filter == EVFILT_READ) &&
1816 (cur_kqueue_event->flags & EV_EOF))
1823 (cur_kqueue_event->filter == EVFILT_WRITE))
1829 if (occurred_events->
events != 0)
1831 occurred_events->
fd = cur_event->
fd;
1838 return returned_events;
1841 #elif defined(WAIT_USE_POLL)
1851 WaitEvent *occurred_events,
int nevents)
1853 int returned_events = 0;
1856 struct pollfd *cur_pollfd;
1870 errmsg(
"%s() failed: %m",
1883 returned_events < nevents;
1884 cur_event++, cur_pollfd++)
1887 if (cur_pollfd->revents == 0)
1890 occurred_events->
pos = cur_event->
pos;
1892 occurred_events->
events = 0;
1895 (cur_pollfd->revents & (POLLIN | POLLHUP | POLLERR | POLLNVAL)))
1909 (cur_pollfd->revents & (POLLIN | POLLHUP | POLLERR | POLLNVAL)))
1936 int errflags = POLLHUP | POLLERR | POLLNVAL;
1941 (cur_pollfd->revents & (POLLIN | errflags)))
1948 (cur_pollfd->revents & (POLLOUT | errflags)))
1956 (cur_pollfd->revents & (POLLRDHUP | errflags)))
1963 if (occurred_events->
events != 0)
1965 occurred_events->
fd = cur_event->
fd;
1971 return returned_events;
1974 #elif defined(WAIT_USE_WIN32)
1985 WaitEvent *occurred_events,
int nevents)
1987 int returned_events = 0;
1992 for (cur_event = set->
events;
1996 if (cur_event->reset)
1998 WaitEventAdjustWin32(set, cur_event);
1999 cur_event->reset =
false;
2024 if (WSARecv(cur_event->
fd, &
buf, 1, &received, &flags, NULL, NULL) == 0)
2026 occurred_events->
pos = cur_event->
pos;
2029 occurred_events->
fd = cur_event->
fd;
2055 r = WSASend(cur_event->
fd, &
buf, 1, &sent, 0, NULL, NULL);
2056 if (r == 0 || WSAGetLastError() != WSAEWOULDBLOCK)
2058 occurred_events->
pos = cur_event->
pos;
2061 occurred_events->
fd = cur_event->
fd;
2072 rc = WaitForMultipleObjects(set->
nevents + 1, set->handles, FALSE,
2076 if (rc == WAIT_FAILED)
2077 elog(
ERROR,
"WaitForMultipleObjects() failed: error code %lu",
2079 else if (rc == WAIT_TIMEOUT)
2085 if (rc == WAIT_OBJECT_0)
2103 occurred_events->
pos = cur_event->
pos;
2105 occurred_events->
events = 0;
2113 if (!ResetEvent(set->handles[cur_event->
pos + 1]))
2114 elog(
ERROR,
"ResetEvent failed: error code %lu", GetLastError());
2145 WSANETWORKEVENTS resEvents;
2146 HANDLE handle = set->handles[cur_event->
pos + 1];
2150 occurred_events->
fd = cur_event->
fd;
2152 ZeroMemory(&resEvents,
sizeof(resEvents));
2153 if (WSAEnumNetworkEvents(cur_event->
fd, handle, &resEvents) != 0)
2154 elog(
ERROR,
"failed to enumerate network events: error code %d",
2157 (resEvents.lNetworkEvents & FD_READ))
2175 cur_event->reset =
true;
2178 (resEvents.lNetworkEvents & FD_WRITE))
2184 (resEvents.lNetworkEvents & FD_CONNECT))
2190 (resEvents.lNetworkEvents & FD_ACCEPT))
2195 if (resEvents.lNetworkEvents & FD_CLOSE)
2201 if (occurred_events->
events != 0)
2209 if (returned_events == nevents)
2213 next_pos = cur_event->
pos + 1;
2222 count = set->
nevents - next_pos;
2223 rc = WaitForMultipleObjects(count,
2224 set->handles + 1 + next_pos,
2232 if (rc < WAIT_OBJECT_0 || rc >= WAIT_OBJECT_0 + count)
2236 cur_event = &set->
events[next_pos + (rc - WAIT_OBJECT_0)];
2239 return returned_events;
2249 #if (defined(WAIT_USE_POLL) && defined(POLLRDHUP)) || \
2250 defined(WAIT_USE_EPOLL) || \
2251 defined(WAIT_USE_KQUEUE)
2267 #if defined(WAIT_USE_SELF_PIPE)
2314 #if defined(WAIT_USE_SELF_PIPE) || defined(WAIT_USE_SIGNALFD)
2330 #ifdef WAIT_USE_SELF_PIPE
2343 else if (errno ==
EINTR)
2348 #ifdef WAIT_USE_SELF_PIPE
2349 elog(
ERROR,
"read() on self-pipe failed: %m");
2351 elog(
ERROR,
"read() on signalfd failed: %m");
2358 #ifdef WAIT_USE_SELF_PIPE
2359 elog(
ERROR,
"unexpected EOF on self-pipe");
2361 elog(
ERROR,
"unexpected EOF on signalfd");
2364 else if (rc <
sizeof(
buf))
#define pg_memory_barrier()
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
#define StaticAssertStmt(condition, errmessage)
static void PGresult * res
int errcode_for_socket_access(void)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void ReleaseExternalFD(void)
bool AcquireExternalFD(void)
void ReserveExternalFD(void)
#define INSTR_TIME_SET_CURRENT(t)
#define INSTR_TIME_SUBTRACT(x, y)
#define INSTR_TIME_GET_MILLISEC(t)
#define INSTR_TIME_SET_ZERO(t)
if(TABLE==NULL||TABLE_index==NULL)
static void latch_sigurg_handler(SIGNAL_ARGS)
static void sendSelfPipeByte(void)
static void ResourceOwnerForgetWaitEventSet(ResourceOwner owner, WaitEventSet *set)
void InitializeLatchWaitSet(void)
int WaitLatchOrSocket(Latch *latch, int wakeEvents, pgsocket sock, long timeout, uint32 wait_event_info)
#define LatchWaitSetLatchPos
static int selfpipe_readfd
void OwnLatch(Latch *latch)
void DisownLatch(Latch *latch)
static const ResourceOwnerDesc wait_event_set_resowner_desc
void FreeWaitEventSetAfterFork(WaitEventSet *set)
static void WaitEventAdjustPoll(WaitEventSet *set, WaitEvent *event)
static int selfpipe_owner_pid
static int selfpipe_writefd
int GetNumRegisteredWaitEvents(WaitEventSet *set)
void InitSharedLatch(Latch *latch)
void InitializeLatchSupport(void)
static WaitEventSet * LatchWaitSet
static void ResourceOwnerRememberWaitEventSet(ResourceOwner owner, WaitEventSet *set)
void ModifyWaitEvent(WaitEventSet *set, int pos, uint32 events, Latch *latch)
static int WaitEventSetWaitBlock(WaitEventSet *set, int cur_timeout, WaitEvent *occurred_events, int nevents)
static void ResOwnerReleaseWaitEventSet(Datum res)
void SetLatch(Latch *latch)
void ShutdownLatchSupport(void)
WaitEventSet * CreateWaitEventSet(ResourceOwner resowner, int nevents)
bool WaitEventSetCanReportClosed(void)
void InitLatch(Latch *latch)
int AddWaitEventToSet(WaitEventSet *set, uint32 events, pgsocket fd, Latch *latch, void *user_data)
int WaitEventSetWait(WaitEventSet *set, long timeout, WaitEvent *occurred_events, int nevents, uint32 wait_event_info)
static volatile sig_atomic_t waiting
void FreeWaitEventSet(WaitEventSet *set)
void ResetLatch(Latch *latch)
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
#define WL_SOCKET_READABLE
#define WL_EXIT_ON_PM_DEATH
#define WL_SOCKET_CONNECTED
#define WL_POSTMASTER_DEATH
#define WL_SOCKET_WRITEABLE
void pfree(void *pointer)
MemoryContext TopMemoryContext
void * MemoryContextAllocZero(MemoryContext context, Size size)
bool PostmasterIsAliveInternal(void)
#define PostmasterIsAlive()
pqsigfunc pqsignal(int signo, pqsigfunc func)
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
int postmaster_alive_fds[2]
#define POSTMASTER_FD_WATCH
static int fd(const char *x, int i)
ResourceOwner CurrentResourceOwner
void ResourceOwnerForget(ResourceOwner owner, Datum value, const ResourceOwnerDesc *kind)
void ResourceOwnerRemember(ResourceOwner owner, Datum value, const ResourceOwnerDesc *kind)
void ResourceOwnerEnlarge(ResourceOwner owner)
#define RELEASE_PRIO_WAITEVENTSETS
@ RESOURCE_RELEASE_AFTER_LOCKS
void pgwin32_dispatch_queued_signals(void)
HANDLE pgwin32_signal_event
sig_atomic_t maybe_sleeping
bool exit_on_postmaster_death
static void pgstat_report_wait_start(uint32 wait_event_info)
static void pgstat_report_wait_end(void)