summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pulsecore/once.c11
-rw-r--r--src/pulsecore/once.h2
2 files changed, 7 insertions, 6 deletions
diff --git a/src/pulsecore/once.c b/src/pulsecore/once.c
index 989741dc..3d4543cb 100644
--- a/src/pulsecore/once.c
+++ b/src/pulsecore/once.c
@@ -28,13 +28,13 @@
#include "once.h"
-int pa_once_begin(pa_once *control) {
+pa_bool_t pa_once_begin(pa_once *control) {
pa_mutex *m;
pa_assert(control);
if (pa_atomic_load(&control->done))
- return 0;
+ return FALSE;
pa_atomic_inc(&control->ref);
@@ -50,15 +50,17 @@ int pa_once_begin(pa_once *control) {
* wait until it is unlocked */
pa_mutex_lock(m);
+ pa_assert(pa_atomic_load(&control->done));
+
pa_once_end(control);
- return 0;
+ return FALSE;
}
pa_assert_se(m = pa_mutex_new(FALSE, FALSE));
pa_mutex_lock(m);
if (pa_atomic_ptr_cmpxchg(&control->mutex, NULL, m))
- return 1;
+ return TRUE;
pa_mutex_unlock(m);
pa_mutex_free(m);
@@ -91,4 +93,3 @@ void pa_run_once(pa_once *control, pa_once_func_t func) {
pa_once_end(control);
}
}
-
diff --git a/src/pulsecore/once.h b/src/pulsecore/once.h
index 576d40fa..c0191ef0 100644
--- a/src/pulsecore/once.h
+++ b/src/pulsecore/once.h
@@ -38,7 +38,7 @@ typedef struct pa_once {
}
/* Not to be called directly, use the macros defined below instead */
-int pa_once_begin(pa_once *o);
+pa_bool_t pa_once_begin(pa_once *o);
void pa_once_end(pa_once *o);
#define PA_ONCE_BEGIN \