Skip to content
Snippets Groups Projects
Commit 66a5bc1b authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf Committed by Anton Mitrofanov
Browse files

lookahead: Keep b_exit_thread under ifbuf.mutex

The lookahead_thread main loop checks b_exit_thread and exits if it is set.
That flag is set by x264_lookahead_delete, which uses ifbuf.mutex to guard accessing it.
However, the read in the while-loop condition of lookahead_thread is not guarded,
and so TSAN sometimes reports a data race.
parent d2907f67
No related branches found
No related tags found
No related merge requests found
......@@ -89,9 +89,14 @@ static void lookahead_slicetype_decide( x264_t *h )
REALIGN_STACK static void *lookahead_thread( x264_t *h )
{
while( !h->lookahead->b_exit_thread )
while( 1 )
{
x264_pthread_mutex_lock( &h->lookahead->ifbuf.mutex );
if( h->lookahead->b_exit_thread )
{
x264_pthread_mutex_unlock( &h->lookahead->ifbuf.mutex );
break;
}
x264_pthread_mutex_lock( &h->lookahead->next.mutex );
int shift = X264_MIN( h->lookahead->next.i_max_size - h->lookahead->next.i_size, h->lookahead->ifbuf.i_size );
lookahead_shift( &h->lookahead->next, &h->lookahead->ifbuf, shift );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment