[pulseaudio-commits] r1368 - /trunk/src/pulsecore/thread-posix.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Mon Sep 4 14:28:36 PDT 2006


Author: lennart
Date: Mon Sep  4 23:28:34 2006
New Revision: 1368

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1368&root=pulseaudio&view=rev
Log:
make pa_thread_self() return a sensible pointer on foreign threads

Modified:
    trunk/src/pulsecore/thread-posix.c

Modified: trunk/src/pulsecore/thread-posix.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/thread-posix.c?rev=1368&root=pulseaudio&r1=1367&r2=1368&view=diff
==============================================================================
--- trunk/src/pulsecore/thread-posix.c (original)
+++ trunk/src/pulsecore/thread-posix.c Mon Sep  4 23:28:34 2006
@@ -117,15 +117,32 @@
 }
 
 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
 }
 




More information about the pulseaudio-commits mailing list