aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2016-05-31 17:36:07 +0200
committerSverker Eriksson <[email protected]>2016-05-31 17:36:07 +0200
commit24da853729d1f02a8c8a3aec1f0c992e00b5ca3f (patch)
treeef6230c70c7864314fef6695c85ba57a775e09b0 /erts/emulator
parent78b50b543395f9af748e2b00afb8c0266e708514 (diff)
downloadotp-24da853729d1f02a8c8a3aec1f0c992e00b5ca3f.tar.gz
otp-24da853729d1f02a8c8a3aec1f0c992e00b5ca3f.tar.bz2
otp-24da853729d1f02a8c8a3aec1f0c992e00b5ca3f.zip
erts: Fix possible race in poller wakeup on windows
Similar bug that was fixed for unix in 7bbb207b30360c60fb99653.
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/sys/win32/erl_poll.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/erts/emulator/sys/win32/erl_poll.c b/erts/emulator/sys/win32/erl_poll.c
index 94f3840b5f..f23c7ab03d 100644
--- a/erts/emulator/sys/win32/erl_poll.c
+++ b/erts/emulator/sys/win32/erl_poll.c
@@ -424,7 +424,7 @@ static ERTS_INLINE int
wakeup_cause(ErtsPollSet ps)
{
int res;
- erts_aint32_t wakeup_state = erts_atomic32_read_nob(&ps->wakeup_state);
+ erts_aint32_t wakeup_state = erts_atomic32_read_acqb(&ps->wakeup_state);
switch (wakeup_state) {
case ERTS_POLL_WOKEN_IO_READY:
res = 0;
@@ -487,9 +487,8 @@ wake_poller(ErtsPollSet ps, int io_ready)
{
erts_aint32_t wakeup_state;
if (io_ready) {
- /* We may set the event multiple times. This is, however, harmless. */
- wakeup_state = erts_atomic32_read_nob(&ps->wakeup_state);
- erts_atomic32_set_relb(&ps->wakeup_state, ERTS_POLL_WOKEN_IO_READY);
+ wakeup_state = erts_atomic32_xchg_relb(&ps->wakeup_state,
+ ERTS_POLL_WOKEN_IO_READY);
}
else {
ERTS_THR_MEMORY_BARRIER;