aboutsummaryrefslogtreecommitdiff
path: root/lib/libthr
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2015-09-08 08:41:07 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2015-09-08 08:41:07 +0000
commit3e7e67c08d3e91752a1d49b8efc66989d234cf11 (patch)
tree820f4cc538ed756d4f9dec308bc6d438e55f1e03 /lib/libthr
parent599acbbcd85d2abd47c7746f8e5b7d5b4c7b1883 (diff)
Notes
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/thread/thr_once.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libthr/thread/thr_once.c b/lib/libthr/thread/thr_once.c
index 4f7037416c259..4a6b4d7a7cbb1 100644
--- a/lib/libthr/thread/thr_once.c
+++ b/lib/libthr/thread/thr_once.c
@@ -68,13 +68,15 @@ _pthread_once(pthread_once_t *once_control, void (*init_routine) (void))
for (;;) {
state = once_control->state;
- if (state == ONCE_DONE)
+ if (state == ONCE_DONE) {
+ atomic_thread_fence_acq();
return (0);
+ }
if (state == ONCE_NEVER_DONE) {
- if (atomic_cmpset_acq_int(&once_control->state, state, ONCE_IN_PROGRESS))
+ if (atomic_cmpset_int(&once_control->state, state, ONCE_IN_PROGRESS))
break;
} else if (state == ONCE_IN_PROGRESS) {
- if (atomic_cmpset_acq_int(&once_control->state, state, ONCE_WAIT))
+ if (atomic_cmpset_int(&once_control->state, state, ONCE_WAIT))
_thr_umtx_wait_uint(&once_control->state, ONCE_WAIT, NULL, 0);
} else if (state == ONCE_WAIT) {
_thr_umtx_wait_uint(&once_control->state, state, NULL, 0);