Commit da9b4d4d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vlc_thread_join: cannot join current thread

vlc_join will cause the assertion failure with pthread.
On -unchanged- Windows, it (supposedly) deadlocks as it used to.
parent 0965ae7d
...@@ -175,7 +175,7 @@ VLC_EXPORT( int, vlc_threadvar_create, (vlc_threadvar_t * , void (*) (void *) ) ...@@ -175,7 +175,7 @@ VLC_EXPORT( int, vlc_threadvar_create, (vlc_threadvar_t * , void (*) (void *) )
VLC_EXPORT( void, vlc_threadvar_delete, (vlc_threadvar_t *) ); VLC_EXPORT( void, vlc_threadvar_delete, (vlc_threadvar_t *) );
VLC_EXPORT( int, __vlc_thread_create, ( vlc_object_t *, const char *, int, const char *, void * ( * ) ( vlc_object_t * ), int, bool ) ); VLC_EXPORT( int, __vlc_thread_create, ( vlc_object_t *, const char *, int, const char *, void * ( * ) ( vlc_object_t * ), int, bool ) );
VLC_EXPORT( int, __vlc_thread_set_priority, ( vlc_object_t *, const char *, int, int ) ); VLC_EXPORT( int, __vlc_thread_set_priority, ( vlc_object_t *, const char *, int, int ) );
VLC_EXPORT( void, __vlc_thread_join, ( vlc_object_t *, const char *, int ) ); VLC_EXPORT( void, __vlc_thread_join, ( vlc_object_t * ) );
VLC_EXPORT( int, vlc_clone, (vlc_thread_t *, void * (*) (void *), void *, int) ); VLC_EXPORT( int, vlc_clone, (vlc_thread_t *, void * (*) (void *), void *, int) );
VLC_EXPORT( void, vlc_cancel, (vlc_thread_t) ); VLC_EXPORT( void, vlc_cancel, (vlc_thread_t) );
...@@ -727,6 +727,6 @@ static inline void barrier (void) ...@@ -727,6 +727,6 @@ static inline void barrier (void)
* vlc_thread_join: wait until a thread exits * vlc_thread_join: wait until a thread exits
*****************************************************************************/ *****************************************************************************/
#define vlc_thread_join( P_THIS ) \ #define vlc_thread_join( P_THIS ) \
__vlc_thread_join( VLC_OBJECT(P_THIS), __FILE__, __LINE__ ) __vlc_thread_join( VLC_OBJECT(P_THIS) )
#endif /* !_VLC_THREADS_H */ #endif /* !_VLC_THREADS_H */
...@@ -794,21 +794,12 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file, ...@@ -794,21 +794,12 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
/***************************************************************************** /*****************************************************************************
* vlc_thread_join: wait until a thread exits, inner version * vlc_thread_join: wait until a thread exits, inner version
*****************************************************************************/ *****************************************************************************/
void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line ) void __vlc_thread_join( vlc_object_t *p_this )
{ {
vlc_object_internals_t *p_priv = vlc_internals( p_this ); vlc_object_internals_t *p_priv = vlc_internals( p_this );
int i_ret = 0;
#if defined( LIBVLC_USE_PTHREAD ) #if defined( LIBVLC_USE_PTHREAD )
/* Make sure we do return if we are calling vlc_thread_join() vlc_join (p_priv->thread_id, NULL);
* from the joined thread */
if (pthread_equal (pthread_self (), p_priv->thread_id))
{
msg_Warn (p_this, "joining the active thread (VLC might crash)");
i_ret = pthread_detach (p_priv->thread_id);
}
else
i_ret = vlc_join (p_priv->thread_id, NULL);
#elif defined( UNDER_CE ) || defined( WIN32 ) #elif defined( UNDER_CE ) || defined( WIN32 )
HANDLE hThread; HANDLE hThread;
...@@ -824,8 +815,7 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line ...@@ -824,8 +815,7 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line
DUPLICATE_SAME_ACCESS) ) DUPLICATE_SAME_ACCESS) )
{ {
p_priv->b_thread = false; p_priv->b_thread = false;
i_ret = GetLastError(); return; /* We have a problem! */
goto error;
} }
vlc_join( p_priv->thread_id, NULL ); vlc_join( p_priv->thread_id, NULL );
...@@ -855,23 +845,12 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line ...@@ -855,23 +845,12 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line
(double)((user_time%(60*1000000))/1000000.0) ); (double)((user_time%(60*1000000))/1000000.0) );
} }
CloseHandle( hThread ); CloseHandle( hThread );
error:
#else #else
i_ret = vlc_join( p_priv->thread_id, NULL ); vlc_join( p_priv->thread_id, NULL );
#endif #endif
if( i_ret )
{
errno = i_ret;
msg_Err( p_this, "thread_join(%lu) failed at %s:%d (%m)",
(unsigned long)p_priv->thread_id, psz_file, i_line );
}
else
msg_Dbg( p_this, "thread %lu joined (%s:%d)",
(unsigned long)p_priv->thread_id, psz_file, i_line );
p_priv->b_thread = false; p_priv->b_thread = false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment