aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys/common/erl_poll.c
diff options
context:
space:
mode:
Diffstat (limited to 'erts/emulator/sys/common/erl_poll.c')
-rw-r--r--erts/emulator/sys/common/erl_poll.c184
1 files changed, 5 insertions, 179 deletions
diff --git a/erts/emulator/sys/common/erl_poll.c b/erts/emulator/sys/common/erl_poll.c
index 52a8b6a53f..3a6ae85b42 100644
--- a/erts/emulator/sys/common/erl_poll.c
+++ b/erts/emulator/sys/common/erl_poll.c
@@ -95,9 +95,6 @@
#define ERTS_POLL_DEBUG_PRINT
#endif
-#if defined(DEBUG) && 0
-#define HARD_DEBUG
-#endif
#ifdef _DARWIN_UNLIMITED_SELECT
typedef struct {
@@ -155,16 +152,11 @@ int ERTS_SELECT(int nfds, ERTS_fd_set *readfds, ERTS_fd_set *writefds,
#define ERTS_POLL_COALESCE_KP_RES (ERTS_POLL_USE_KQUEUE || ERTS_POLL_USE_EPOLL)
-#ifdef ERTS_POLL_NEED_ASYNC_INTERRUPT_SUPPORT
-# define ERTS_POLL_ASYNC_INTERRUPT_SUPPORT 1
-#else
# define ERTS_POLL_ASYNC_INTERRUPT_SUPPORT 0
-#endif
#define ERTS_POLL_USE_WAKEUP_PIPE \
(ERTS_POLL_ASYNC_INTERRUPT_SUPPORT || defined(USE_THREADS))
-#ifdef ERTS_SMP
#define ERTS_POLLSET_LOCK(PS) \
erts_smp_mtx_lock(&(PS)->mtx)
@@ -178,28 +170,13 @@ int ERTS_SELECT(int nfds, ERTS_fd_set *readfds, ERTS_fd_set *writefds,
#define ERTS_POLLSET_IS_POLLED(PS) \
((int) erts_atomic32_read_nob(&(PS)->polled))
-#else
-
-#define ERTS_POLLSET_LOCK(PS)
-#define ERTS_POLLSET_UNLOCK(PS)
-#define ERTS_POLLSET_SET_POLLED_CHK(PS) 0
-#define ERTS_POLLSET_UNSET_POLLED(PS)
-#define ERTS_POLLSET_IS_POLLED(PS) 0
-#endif
-
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
#define ERTS_POLLSET_SET_HAVE_UPDATE_REQUESTS(PS) \
erts_smp_atomic32_set_nob(&(PS)->have_update_requests, (erts_aint32_t) 1)
#define ERTS_POLLSET_UNSET_HAVE_UPDATE_REQUESTS(PS) \
erts_smp_atomic32_set_nob(&(PS)->have_update_requests, (erts_aint32_t) 0)
#define ERTS_POLLSET_HAVE_UPDATE_REQUESTS(PS) \
((int) erts_smp_atomic32_read_nob(&(PS)->have_update_requests))
-#else
-#define ERTS_POLLSET_SET_HAVE_UPDATE_REQUESTS(PS)
-#define ERTS_POLLSET_UNSET_HAVE_UPDATE_REQUESTS(PS)
-#define ERTS_POLLSET_HAVE_UPDATE_REQUESTS(PS) 0
-#endif
#if ERTS_POLL_USE_FALLBACK
# if ERTS_POLL_USE_POLL
@@ -212,7 +189,6 @@ int ERTS_SELECT(int nfds, ERTS_fd_set *readfds, ERTS_fd_set *writefds,
* --- Data types ------------------------------------------------------------
*/
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
#define ERTS_POLLSET_UPDATE_REQ_BLOCK_SIZE 128
typedef struct ErtsPollSetUpdateRequestsBlock_ ErtsPollSetUpdateRequestsBlock;
@@ -222,19 +198,14 @@ struct ErtsPollSetUpdateRequestsBlock_ {
int fds[ERTS_POLLSET_UPDATE_REQ_BLOCK_SIZE];
};
-#endif
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
# define ERTS_POLL_FD_FLG_INURQ (((unsigned short) 1) << 0)
-#endif
#if ERTS_POLL_USE_FALLBACK
# define ERTS_POLL_FD_FLG_INFLBCK (((unsigned short) 1) << 1)
# define ERTS_POLL_FD_FLG_USEFLBCK (((unsigned short) 1) << 2)
#endif
-#if ERTS_POLL_USE_KERNEL_POLL || defined(ERTS_SMP)
# define ERTS_POLL_FD_FLG_RST (((unsigned short) 1) << 3)
-#endif
typedef struct {
#if ERTS_POLL_USE_POLL
int pix;
@@ -244,9 +215,7 @@ typedef struct {
#if ERTS_POLL_COALESCE_KP_RES
unsigned short res_ev_ix;
#endif
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE || ERTS_POLL_USE_FALLBACK
unsigned short flags;
-#endif
} ErtsFdStatus;
@@ -301,27 +270,19 @@ struct ErtsPollSet_ {
ERTS_fd_set output_fds;
ERTS_fd_set res_output_fds;
#endif
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
ErtsPollSetUpdateRequestsBlock update_requests;
ErtsPollSetUpdateRequestsBlock *curr_upd_req_block;
erts_smp_atomic32_t have_update_requests;
-#endif
-#ifdef ERTS_SMP
erts_atomic32_t polled;
erts_smp_mtx_t mtx;
-#endif
-#if ERTS_POLL_USE_WAKEUP_PIPE
int wake_fds[2];
-#endif
#if ERTS_POLL_USE_TIMERFD
int timer_fd;
#endif
#if ERTS_POLL_USE_FALLBACK
int fallback_used;
#endif
-#if defined(USE_THREADS) || ERTS_POLL_ASYNC_INTERRUPT_SUPPORT
erts_atomic32_t wakeup_state;
-#endif
erts_atomic64_t timeout_time;
#ifdef ERTS_POLL_COUNT_AVOIDED_WAKEUPS
erts_smp_atomic_t no_avoided_wakeups;
@@ -413,50 +374,37 @@ get_timeout_time(ErtsPollSet ps)
static ERTS_INLINE void
reset_wakeup_state(ErtsPollSet ps)
{
-#if defined(USE_THREADS) || ERTS_POLL_ASYNC_INTERRUPT_SUPPORT
erts_atomic32_set_mb(&ps->wakeup_state, ERTS_POLL_NOT_WOKEN);
-#endif
}
static ERTS_INLINE int
is_woken(ErtsPollSet ps)
{
-#if defined(USE_THREADS) || ERTS_POLL_ASYNC_INTERRUPT_SUPPORT
return erts_atomic32_read_acqb(&ps->wakeup_state) != ERTS_POLL_NOT_WOKEN;
-#else
- return 0;
-#endif
}
static ERTS_INLINE int
is_interrupted_reset(ErtsPollSet ps)
{
-#if defined(USE_THREADS) || ERTS_POLL_ASYNC_INTERRUPT_SUPPORT
return (erts_atomic32_xchg_acqb(&ps->wakeup_state, ERTS_POLL_NOT_WOKEN)
== ERTS_POLL_WOKEN_INTR);
-#else
- return 0;
-#endif
}
static ERTS_INLINE void
woke_up(ErtsPollSet ps)
{
-#if defined(USE_THREADS) || ERTS_POLL_ASYNC_INTERRUPT_SUPPORT
erts_aint32_t wakeup_state = erts_atomic32_read_acqb(&ps->wakeup_state);
if (wakeup_state == ERTS_POLL_NOT_WOKEN)
(void) erts_atomic32_cmpxchg_nob(&ps->wakeup_state,
ERTS_POLL_WOKEN,
ERTS_POLL_NOT_WOKEN);
ASSERT(erts_atomic32_read_nob(&ps->wakeup_state) != ERTS_POLL_NOT_WOKEN);
-#endif
}
/*
* --- Wakeup pipe -----------------------------------------------------------
*/
-#if ERTS_POLL_USE_WAKEUP_PIPE
static ERTS_INLINE void
wake_poller(ErtsPollSet ps, int interrupted, int async_signal_safe)
@@ -507,18 +455,11 @@ wake_poller(ErtsPollSet ps, int interrupted, int async_signal_safe)
static ERTS_INLINE void
cleanup_wakeup_pipe(ErtsPollSet ps)
{
-#if ERTS_POLL_ASYNC_INTERRUPT_SUPPORT
- int intr = 0;
-#endif
int fd = ps->wake_fds[0];
int res;
do {
char buf[32];
res = read(fd, buf, sizeof(buf));
-#if ERTS_POLL_ASYNC_INTERRUPT_SUPPORT
- if (res > 0)
- intr = 1;
-#endif
} while (res > 0 || (res < 0 && errno == EINTR));
if (res < 0 && errno != ERRNO_BLOCK) {
fatal_error("%s:%d:cleanup_wakeup_pipe(): "
@@ -528,10 +469,6 @@ cleanup_wakeup_pipe(ErtsPollSet ps)
fd,
erl_errno_id(errno), errno);
}
-#if ERTS_POLL_ASYNC_INTERRUPT_SUPPORT
- if (intr)
- erts_atomic32_set_nob(&ps->wakeup_state, ERTS_POLL_WOKEN_INTR);
-#endif
}
static void
@@ -574,7 +511,6 @@ create_wakeup_pipe(ErtsPollSet ps)
ps->wake_fds[1] = wake_fds[1];
}
-#endif /* ERTS_POLL_USE_WAKEUP_PIPE */
/*
* --- timer fd -----------------------------------------------------------
@@ -648,7 +584,6 @@ timerfd_clear(ErtsPollSet ps, int res, int max_res) {
/*
* --- Poll set update requests ----------------------------------------------
*/
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
static ERTS_INLINE void
enqueue_update_request(ErtsPollSet ps, int fd)
@@ -691,7 +626,6 @@ free_update_requests_block(ErtsPollSet ps,
}
}
-#endif /* ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE */
/*
* --- Growing poll set structures -------------------------------------------
@@ -819,9 +753,7 @@ grow_fds_status(ErtsPollSet ps, int min_fd)
#if ERTS_POLL_COALESCE_KP_RES
ps->fds_status[i].res_ev_ix = (unsigned short) ERTS_POLL_MAX_RES;
#endif
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE || ERTS_POLL_USE_FALLBACK
ps->fds_status[i].flags = (unsigned short) 0;
-#endif
}
ps->fds_status_len = new_len;
}
@@ -849,7 +781,7 @@ need_update(ErtsPollSet ps, int fd)
ps->fds_status[fd].flags &= ~ERTS_POLL_FD_FLG_RST;
reset = 0;
}
-#elif defined(ERTS_SMP)
+#else
ps->fds_status[fd].flags &= ~ERTS_POLL_FD_FLG_RST;
#endif
@@ -1518,7 +1450,6 @@ static int update_pollset(ErtsPollSet ps, int fd)
#endif /* ERTS_POLL_USE_POLL || ERTS_POLL_USE_SELECT || ERTS_POLL_USE_FALLBACK */
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
static void
handle_update_requests(ErtsPollSet ps)
@@ -1565,7 +1496,6 @@ handle_update_requests(ErtsPollSet ps)
ERTS_POLLSET_UNSET_HAVE_UPDATE_REQUESTS(ps);
}
-#endif /* ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE */
static ERTS_INLINE ErtsPollEvents
poll_control(ErtsPollSet ps, int fd, ErtsPollEvents events, int on, int *do_wake)
@@ -1583,12 +1513,10 @@ poll_control(ErtsPollSet ps, int fd, ErtsPollEvents events, int on, int *do_wake
goto done;
}
#endif
-#if ERTS_POLL_USE_WAKEUP_PIPE
if (fd == ps->wake_fds[0] || fd == ps->wake_fds[1]) {
new_events = ERTS_POLL_EV_NVAL;
goto done;
}
-#endif
#if ERTS_POLL_USE_TIMERFD
if (fd == ps->timer_fd) {
new_events = ERTS_POLL_EV_NVAL;
@@ -1615,9 +1543,7 @@ poll_control(ErtsPollSet ps, int fd, ErtsPollEvents events, int on, int *do_wake
new_events &= ~events;
if (new_events == (ErtsPollEvents) 0) {
-#if ERTS_POLL_USE_KERNEL_POLL || defined(ERTS_SMP)
ps->fds_status[fd].flags |= ERTS_POLL_FD_FLG_RST;
-#endif
#if ERTS_POLL_USE_FALLBACK
ps->fds_status[fd].flags &= ~ERTS_POLL_FD_FLG_USEFLBCK;
#endif
@@ -1626,18 +1552,12 @@ poll_control(ErtsPollSet ps, int fd, ErtsPollEvents events, int on, int *do_wake
ps->fds_status[fd].events = new_events;
if (new_events == ps->fds_status[fd].used_events
-#if ERTS_POLL_USE_KERNEL_POLL || defined(ERTS_SMP)
&& !(ps->fds_status[fd].flags & ERTS_POLL_FD_FLG_RST)
-#endif
) {
*do_wake = 0;
goto done;
}
-#if !ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
- if (update_pollset(ps, fd) != 0)
- new_events = ERTS_POLL_EV_ERR;
-#else /* ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE */
#if ERTS_POLL_USE_CONCURRENT_UPDATE
if (ERTS_POLLSET_IS_POLLED(ps)) {
@@ -1652,7 +1572,6 @@ poll_control(ErtsPollSet ps, int fd, ErtsPollEvents events, int on, int *do_wake
enqueue_update_request(ps, fd);
-#ifdef ERTS_SMP
/*
* If new events have been added, we need to wake up the
* polling thread, but if events have been removed we don't.
@@ -1660,9 +1579,7 @@ poll_control(ErtsPollSet ps, int fd, ErtsPollEvents events, int on, int *do_wake
if ((new_events && (ps->fds_status[fd].flags & ERTS_POLL_FD_FLG_RST))
|| (~ps->fds_status[fd].used_events & new_events))
*do_wake = 1;
-#endif /* ERTS_SMP */
-#endif /* ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE */
done:
#ifdef ERTS_POLL_DEBUG_PRINT
@@ -1695,10 +1612,8 @@ ERTS_POLL_EXPORT(erts_poll_controlv)(ErtsPollSet ps,
ERTS_POLLSET_UNLOCK(ps);
-#ifdef ERTS_SMP
if (final_do_wake)
wake_poller(ps, 0, 0);
-#endif /* ERTS_SMP */
}
@@ -1718,11 +1633,9 @@ ERTS_POLL_EXPORT(erts_poll_control)(ErtsPollSet ps,
ERTS_POLLSET_UNLOCK(ps);
-#ifdef ERTS_SMP
if (*do_wake) {
wake_poller(ps, 0, 0);
}
-#endif /* ERTS_SMP */
return res;
}
@@ -1739,9 +1652,7 @@ save_kp_result(ErtsPollSet ps, ErtsPollResFd pr[], int max_res, int chk_fds_res)
int res = 0;
int i;
int n = chk_fds_res < max_res ? chk_fds_res : max_res;
-#if ERTS_POLL_USE_WAKEUP_PIPE
int wake_fd = ps->wake_fds[0];
-#endif
#if ERTS_POLL_USE_TIMERFD
int timer_fd = ps->timer_fd;
#endif
@@ -1754,12 +1665,10 @@ save_kp_result(ErtsPollSet ps, ErtsPollResFd pr[], int max_res, int chk_fds_res)
int fd = ps->res_events[i].data.fd;
int ix;
ErtsPollEvents revents;
-#if ERTS_POLL_USE_WAKEUP_PIPE
if (fd == wake_fd) {
cleanup_wakeup_pipe(ps);
continue;
}
-#endif
#if ERTS_POLL_USE_TIMERFD
if (fd == timer_fd) {
continue;
@@ -1805,12 +1714,10 @@ save_kp_result(ErtsPollSet ps, ErtsPollResFd pr[], int max_res, int chk_fds_res)
}
if (ev->filter == EVFILT_READ) {
-#if ERTS_POLL_USE_WAKEUP_PIPE
if (fd == wake_fd) {
cleanup_wakeup_pipe(ps);
continue;
}
-#endif
pr[ix].events |= ERTS_POLL_EV_IN;
}
else if (ev->filter == EVFILT_WRITE)
@@ -1833,12 +1740,10 @@ save_kp_result(ErtsPollSet ps, ErtsPollResFd pr[], int max_res, int chk_fds_res)
if (ps->res_events[i].revents) {
int fd = ps->res_events[i].fd;
ErtsPollEvents revents;
-#if ERTS_POLL_USE_WAKEUP_PIPE
if (fd == wake_fd) {
cleanup_wakeup_pipe(ps);
continue;
}
-#endif
#if ERTS_POLL_USE_TIMERFD
if (fd == timer_fd) {
continue;
@@ -1938,7 +1843,7 @@ save_poll_result(ErtsPollSet ps, ErtsPollResFd pr[], int max_res,
i++;
continue;
}
-#elif ERTS_POLL_USE_WAKEUP_PIPE
+#else
if (fd == wake_fd) {
cleanup_wakeup_pipe(ps);
i++;
@@ -1988,7 +1893,7 @@ save_poll_result(ErtsPollSet ps, ErtsPollResFd pr[], int max_res,
fd++;
continue;
}
-#elif ERTS_POLL_USE_WAKEUP_PIPE
+#else
if (fd == wake_fd) {
cleanup_wakeup_pipe(ps);
fd++;
@@ -2051,7 +1956,7 @@ save_poll_result(ErtsPollSet ps, ErtsPollResFd pr[], int max_res,
fd++;
continue;
}
-#elif ERTS_POLL_USE_WAKEUP_PIPE
+#else
if (fd == wake_fd) {
cleanup_wakeup_pipe(ps);
fd++;
@@ -2073,7 +1978,7 @@ save_poll_result(ErtsPollSet ps, ErtsPollResFd pr[], int max_res,
fd++;
continue;
}
-#elif ERTS_POLL_USE_WAKEUP_PIPE
+#else
if (fd == wake_fd) {
cleanup_wakeup_pipe(ps);
fd++;
@@ -2261,9 +2166,7 @@ check_fd_events(ErtsPollSet ps, ErtsMonotonicTime timeout_time, int max_res)
struct itimerspec its;
timeout = get_timeout_itimerspec(ps, &its, timeout_time);
if (timeout) {
-#ifdef ERTS_SMP
erts_thr_progress_prepare_wait(NULL);
-#endif
ERTS_MSACC_SET_STATE_CACHED_M(ERTS_MSACC_STATE_SLEEP);
timerfd_set(ps, &its);
res = epoll_wait(ps->kp_fd, ps->res_events, max_res, -1);
@@ -2275,9 +2178,7 @@ check_fd_events(ErtsPollSet ps, ErtsMonotonicTime timeout_time, int max_res)
#else /* !ERTS_POLL_USE_TIMERFD */
timeout = (int) get_timeout(ps, 1000, timeout_time);
if (timeout) {
-#ifdef ERTS_SMP
erts_thr_progress_prepare_wait(NULL);
-#endif
ERTS_MSACC_SET_STATE_CACHED_M(ERTS_MSACC_STATE_SLEEP);
}
res = epoll_wait(ps->kp_fd, ps->res_events, max_res, timeout);
@@ -2288,9 +2189,7 @@ check_fd_events(ErtsPollSet ps, ErtsMonotonicTime timeout_time, int max_res)
grow_res_events(ps, max_res);
timeout = get_timeout_timespec(ps, &ts, timeout_time);
if (timeout) {
-#ifdef ERTS_SMP
erts_thr_progress_prepare_wait(NULL);
-#endif
ERTS_MSACC_SET_STATE_CACHED_M(ERTS_MSACC_STATE_SLEEP);
}
res = kevent(ps->kp_fd, NULL, 0, ps->res_events, max_res, &ts);
@@ -2308,18 +2207,14 @@ check_fd_events(ErtsPollSet ps, ErtsMonotonicTime timeout_time, int max_res)
*/
struct dvpoll poll_res;
int nfds = (int) erts_smp_atomic_read_nob(&ps->no_of_user_fds);
-#if ERTS_POLL_USE_WAKEUP_PIPE
nfds++; /* Wakeup pipe */
-#endif
timeout = (int) get_timeout(ps, 1000, timeout_time);
poll_res.dp_nfds = nfds < max_res ? nfds : max_res;
if (poll_res.dp_nfds > ps->res_events_len)
grow_res_events(ps, poll_res.dp_nfds);
poll_res.dp_fds = ps->res_events;
if (timeout) {
-#ifdef ERTS_SMP
erts_thr_progress_prepare_wait(NULL);
-#endif
ERTS_MSACC_SET_STATE_CACHED_M(ERTS_MSACC_STATE_SLEEP);
}
poll_res.dp_timeout = timeout;
@@ -2328,9 +2223,7 @@ check_fd_events(ErtsPollSet ps, ErtsMonotonicTime timeout_time, int max_res)
struct timespec ts;
timeout = get_timeout_timespec(ps, &ts, timeout_time);
if (timeout) {
-#ifdef ERTS_SMP
erts_thr_progress_prepare_wait(NULL);
-#endif
ERTS_MSACC_SET_STATE_CACHED_M(ERTS_MSACC_STATE_SLEEP);
}
res = ppoll(ps->poll_fds, ps->no_poll_fds, &ts, NULL);
@@ -2338,9 +2231,7 @@ check_fd_events(ErtsPollSet ps, ErtsMonotonicTime timeout_time, int max_res)
timeout = (int) get_timeout(ps, 1000, timeout_time);
if (timeout) {
-#ifdef ERTS_SMP
erts_thr_progress_prepare_wait(NULL);
-#endif
ERTS_MSACC_SET_STATE_CACHED_M(ERTS_MSACC_STATE_SLEEP);
}
res = poll(ps->poll_fds, ps->no_poll_fds, timeout);
@@ -2352,9 +2243,7 @@ check_fd_events(ErtsPollSet ps, ErtsMonotonicTime timeout_time, int max_res)
ERTS_FD_COPY(&ps->output_fds, &ps->res_output_fds);
if (timeout) {
-#ifdef ERTS_SMP
erts_thr_progress_prepare_wait(NULL);
-#endif
ERTS_MSACC_SET_STATE_CACHED_M(ERTS_MSACC_STATE_SLEEP);
}
res = ERTS_SELECT(ps->max_fd + 1,
@@ -2362,7 +2251,6 @@ check_fd_events(ErtsPollSet ps, ErtsMonotonicTime timeout_time, int max_res)
&ps->res_output_fds,
NULL,
&to);
-#ifdef ERTS_SMP
if (timeout) {
erts_thr_progress_finalize_wait(NULL);
ERTS_MSACC_POP_STATE_M();
@@ -2397,14 +2285,11 @@ check_fd_events(ErtsPollSet ps, ErtsMonotonicTime timeout_time, int max_res)
res = -1;
}
}
-#endif /* ERTS_SMP */
return res;
#endif /* ----------------------------------------- */
}
if (timeout) {
-#ifdef ERTS_SMP
erts_thr_progress_finalize_wait(NULL);
-#endif
ERTS_MSACC_POP_STATE_M();
}
return res;
@@ -2420,9 +2305,7 @@ ERTS_POLL_EXPORT(erts_poll_wait)(ErtsPollSet ps,
ErtsMonotonicTime to;
int res, no_fds;
int ebadf = 0;
-#ifdef ERTS_SMP
int ps_locked = 0;
-#endif
no_fds = *len;
#ifdef ERTS_POLL_MAX_RES
@@ -2447,13 +2330,11 @@ ERTS_POLL_EXPORT(erts_poll_wait)(ErtsPollSet ps,
? ERTS_POLL_NO_TIMEOUT /* Use zero timeout */
: timeout_time);
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
if (ERTS_POLLSET_HAVE_UPDATE_REQUESTS(ps)) {
ERTS_POLLSET_LOCK(ps);
handle_update_requests(ps);
ERTS_POLLSET_UNLOCK(ps);
}
-#endif
while (1) {
res = check_fd_events(ps, to, no_fds);
@@ -2484,10 +2365,8 @@ ERTS_POLL_EXPORT(erts_poll_wait)(ErtsPollSet ps,
save_results:
#endif
-#ifdef ERTS_SMP
ps_locked = 1;
ERTS_POLLSET_LOCK(ps);
-#endif
no_fds = save_poll_result(ps, pr, no_fds, res, ebadf);
@@ -2499,11 +2378,9 @@ ERTS_POLL_EXPORT(erts_poll_wait)(ErtsPollSet ps,
*len = no_fds;
}
-#ifdef ERTS_SMP
if (ps_locked)
ERTS_POLLSET_UNLOCK(ps);
ERTS_POLLSET_UNSET_POLLED(ps);
-#endif
done:
set_timeout_time(ps, ERTS_MONOTONIC_TIME_MAX);
@@ -2522,25 +2399,12 @@ ERTS_POLL_EXPORT(erts_poll_wait)(ErtsPollSet ps,
void
ERTS_POLL_EXPORT(erts_poll_interrupt)(ErtsPollSet ps, int set)
{
-#if defined(USE_THREADS) || ERTS_POLL_ASYNC_INTERRUPT_SUPPORT
if (!set)
reset_wakeup_state(ps);
else
wake_poller(ps, 1, 0);
-#endif
}
-#if ERTS_POLL_ASYNC_INTERRUPT_SUPPORT
-void
-ERTS_POLL_EXPORT(erts_poll_async_sig_interrupt)(ErtsPollSet ps)
-{
- /*
- * NOTE: This function is called from signal handlers, it,
- * therefore, it has to be async-signal safe.
- */
- wake_poller(ps, 1, 1);
-}
-#endif
/*
* erts_poll_interrupt_timed():
@@ -2552,7 +2416,6 @@ ERTS_POLL_EXPORT(erts_poll_interrupt_timed)(ErtsPollSet ps,
int set,
ErtsMonotonicTime timeout_time)
{
-#if ERTS_POLL_ASYNC_INTERRUPT_SUPPORT || defined(ERTS_SMP)
if (!set)
reset_wakeup_state(ps);
else {
@@ -2568,7 +2431,6 @@ ERTS_POLL_EXPORT(erts_poll_interrupt_timed)(ErtsPollSet ps,
erts_smp_atomic_inc_nob(&ps->no_interrupt_timed);
#endif
}
-#endif
}
int
@@ -2682,22 +2544,14 @@ ERTS_POLL_EXPORT(erts_poll_create_pollset)(void)
ERTS_FD_ZERO(&ps->res_output_fds);
#endif
#endif
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
ps->update_requests.next = NULL;
ps->update_requests.len = 0;
ps->curr_upd_req_block = &ps->update_requests;
erts_smp_atomic32_init_nob(&ps->have_update_requests, 0);
-#endif
-#ifdef ERTS_SMP
erts_atomic32_init_nob(&ps->polled, 0);
erts_smp_mtx_init(&ps->mtx, "pollset", NIL, ERTS_LOCK_FLAGS_CATEGORY_IO);
-#endif
-#if defined(USE_THREADS) || ERTS_POLL_ASYNC_INTERRUPT_SUPPORT
erts_atomic32_init_nob(&ps->wakeup_state, (erts_aint32_t) 0);
-#endif
-#if ERTS_POLL_USE_WAKEUP_PIPE
create_wakeup_pipe(ps);
-#endif
#if ERTS_POLL_USE_TIMERFD
create_timerfd(ps);
#endif
@@ -2724,9 +2578,7 @@ ERTS_POLL_EXPORT(erts_poll_create_pollset)(void)
erts_smp_atomic_init_nob(&ps->no_avoided_interrupts, 0);
erts_smp_atomic_init_nob(&ps->no_interrupt_timed, 0);
#endif
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
handle_update_requests(ps);
-#endif
#if ERTS_POLL_USE_FALLBACK
ps->fallback_used = 0;
#endif
@@ -2772,7 +2624,6 @@ ERTS_POLL_EXPORT(erts_poll_destroy_pollset)(ErtsPollSet ps)
erts_free(ERTS_ALC_T_SELECT_FDS, (void *) ps->res_output_fds.ptr);
#endif
#endif
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
{
ErtsPollSetUpdateRequestsBlock *urqbp = ps->update_requests.next;
while (urqbp) {
@@ -2781,16 +2632,11 @@ ERTS_POLL_EXPORT(erts_poll_destroy_pollset)(ErtsPollSet ps)
free_update_requests_block(ps, free_urqbp);
}
}
-#endif
-#ifdef ERTS_SMP
erts_smp_mtx_destroy(&ps->mtx);
-#endif
-#if ERTS_POLL_USE_WAKEUP_PIPE
if (ps->wake_fds[0] >= 0)
close(ps->wake_fds[0]);
if (ps->wake_fds[1] >= 0)
close(ps->wake_fds[1]);
-#endif
#if ERTS_POLL_USE_TIMERFD
if (ps->timer_fd >= 0)
close(ps->timer_fd);
@@ -2818,9 +2664,7 @@ ERTS_POLL_EXPORT(erts_poll_destroy_pollset)(ErtsPollSet ps)
void
ERTS_POLL_EXPORT(erts_poll_info)(ErtsPollSet ps, ErtsPollInfo *pip)
{
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
int pending_updates;
-#endif
Uint size = 0;
ERTS_POLLSET_LOCK(ps);
@@ -2845,7 +2689,6 @@ ERTS_POLL_EXPORT(erts_poll_info)(ErtsPollSet ps, ErtsPollInfo *pip)
#endif
#endif
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
{
ErtsPollSetUpdateRequestsBlock *urqbp = ps->update_requests.next;
pending_updates = ps->update_requests.len;
@@ -2855,7 +2698,6 @@ ERTS_POLL_EXPORT(erts_poll_info)(ErtsPollSet ps, ErtsPollInfo *pip)
urqbp = urqbp->next;
}
}
-#endif
pip->primary =
#if ERTS_POLL_USE_KQUEUE
@@ -2896,9 +2738,7 @@ ERTS_POLL_EXPORT(erts_poll_info)(ErtsPollSet ps, ErtsPollInfo *pip)
pip->memory_size = size;
pip->poll_set_size = (int) erts_smp_atomic_read_nob(&ps->no_of_user_fds);
-#if ERTS_POLL_USE_WAKEUP_PIPE
pip->poll_set_size++; /* Wakeup pipe */
-#endif
#if ERTS_POLL_USE_TIMERFD
pip->poll_set_size++; /* timerfd */
#endif
@@ -2922,19 +2762,11 @@ ERTS_POLL_EXPORT(erts_poll_info)(ErtsPollSet ps, ErtsPollInfo *pip)
#endif
pip->lazy_updates =
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
1
-#else
- 0
-#endif
;
pip->pending_updates =
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
pending_updates
-#else
- 0
-#endif
;
pip->batch_updates =
@@ -3031,9 +2863,7 @@ ERTS_POLL_EXPORT(erts_poll_get_selected_events)(ErtsPollSet ps,
else {
ev[fd] = ps->fds_status[fd].events;
if (
-#if ERTS_POLL_USE_WAKEUP_PIPE
fd == ps->wake_fds[0] || fd == ps->wake_fds[1] ||
-#endif
#if ERTS_POLL_USE_TIMERFD
fd == ps->timer_fd ||
#endif
@@ -3121,11 +2951,7 @@ print_misc_debug_info(void)
"select"
#endif
,
-#if ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE
"true"
-#else
- "false"
-#endif
,
#if ERTS_POLL_USE_BATCH_UPDATE_POLLSET
"true"