summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-09-04 21:28:34 +0000
committerLennart Poettering <lennart@poettering.net>2006-09-04 21:28:34 +0000
commit8e7c2a3b0c2fd67802222b3f216bc67bb2c1fe70 (patch)
tree64e92b3aa09db9dc783dff02d11ab6d5fb5188da /src
parent6db6c835ec450e4e70197f01e2fcf1b9c9d3e222 (diff)
make pa_thread_self() return a sensible pointer on foreign threads
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1368 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src')
-rw-r--r--src/pulsecore/thread-posix.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/pulsecore/thread-posix.c b/src/pulsecore/thread-posix.c
index 2e8d6b68..43ad2d52 100644
--- a/src/pulsecore/thread-posix.c
+++ b/src/pulsecore/thread-posix.c
@@ -117,15 +117,32 @@ int pa_thread_join(pa_thread *t) {
}
pa_thread* pa_thread_self(void) {
+ pa_thread *t;
+
ASSERT_SUCCESS(pthread_once(&thread_tls_once, thread_tls_once_func));
- return pa_tls_get(thread_tls);
+
+ if ((t = pa_tls_get(thread_tls)))
+ return t;
+
+ /* This is a foreign thread, let's create a pthread structure to
+ * make sure that we can always return a sensible pointer */
+
+ t = pa_xnew(pa_thread, 1);
+ t->id = pthread_self();
+ t->thread_func = NULL;
+ t->userdata = NULL;
+ AO_store_full(&t->running, 1);
+
+ pa_tls_set(thread_tls, t);
+
+ return t;
}
void pa_thread_yield(void) {
#ifdef HAVE_PTHREAD_YIELD
pthread_yield();
#else
- sched_yield();
+ ASSERT_SUCCESS(sched_yield());
#endif
}