diff --git a/src/backend/port/unix_latch.c b/src/backend/port/unix_latch.c new file mode 100644 index bbd1810..9f934f3 *** a/src/backend/port/unix_latch.c --- b/src/backend/port/unix_latch.c *************** *** 46,51 **** --- 46,54 ---- #ifdef HAVE_SYS_SELECT_H #include #endif + #ifdef HAVE_POLL + #include "portability/instr_time.h" + #endif #include "miscadmin.h" #include "postmaster/postmaster.h" *************** WaitLatchOrSocket(volatile Latch *latch, *** 255,260 **** --- 258,267 ---- waiting = true; do { + #ifdef HAVE_POLL + instr_time poll_start; + instr_time poll_time; + #endif /* * Clear the pipe, then check if the latch is set already. If someone * sets the latch between this and the poll()/select() below, the *************** WaitLatchOrSocket(volatile Latch *latch, *** 311,323 **** } /* Sleep */ rc = poll(pfds, nfds, (int) timeout); /* Check return code */ if (rc < 0) { ! if (errno == EINTR) continue; waiting = false; ereport(ERROR, (errcode_for_socket_access(), --- 318,340 ---- } /* Sleep */ + INSTR_TIME_SET_CURRENT(poll_start); rc = poll(pfds, nfds, (int) timeout); /* Check return code */ if (rc < 0) { ! if (errno == EINTR) ! { ! if (timeout>0) ! { ! INSTR_TIME_SET_CURRENT(poll_time); ! INSTR_TIME_SUBTRACT(poll_time, poll_start); ! timeout-=INSTR_TIME_GET_MILLISEC(poll_time); ! if (timeout < 0) timeout=0; ! }; continue; + }; waiting = false; ereport(ERROR, (errcode_for_socket_access(),