[vlc-devel] commit: threads: Make sure we vlc_thread_join() won' t block when run from joined thread using the pthread implementation. ( Pierre d'Herbemont )
git version control
git at videolan.org
Wed Mar 26 17:36:12 CET 2008
vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Wed Mar 26 00:39:59 2008 +0100| [8bf64ccc76a40c0ba7c2089ed5e08f58a5f405f3]
threads: Make sure we vlc_thread_join() won't block when run from joined thread using the pthread implementation.
Signed-off-by: Rémi Denis-Courmont
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8bf64ccc76a40c0ba7c2089ed5e08f58a5f405f3
---
src/misc/threads.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/misc/threads.c b/src/misc/threads.c
index 23dcf71..633e063 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -834,8 +834,12 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line
i_ret = (B_OK == wait_for_thread( p_priv->thread_id, &exit_value ));
#elif defined( LIBVLC_USE_PTHREAD )
- i_ret = pthread_join( p_priv->thread_id, NULL );
-
+ /* Make sure we do return if we are calling vlc_thread_join()
+ * from the joined thread */
+ if (pthread_equal (pthread_self (), p_priv->thread_id))
+ i_ret = pthread_detach (p_priv->thread_id);
+ else
+ i_ret = pthread_join (p_priv->thread_id, NULL);
#endif
if( i_ret )
More information about the vlc-devel
mailing list