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

RTP output: avoid vlc_thread_create()

This triggers a race condition and ultimately a crash when the input
kills all its children.
parent bc612f60
...@@ -244,7 +244,7 @@ static int MuxSend( sout_stream_t *, sout_stream_id_t *, ...@@ -244,7 +244,7 @@ static int MuxSend( sout_stream_t *, sout_stream_id_t *,
block_t* ); block_t* );
static sout_access_out_t *GrabberCreate( sout_stream_t *p_sout ); static sout_access_out_t *GrabberCreate( sout_stream_t *p_sout );
static void* ThreadSend( vlc_object_t *p_this ); static void* ThreadSend( void * );
static void *rtp_listen_thread( void * ); static void *rtp_listen_thread( void * );
static void SDPHandleUrl( sout_stream_t *, const char * ); static void SDPHandleUrl( sout_stream_t *, const char * );
...@@ -341,6 +341,7 @@ struct sout_stream_id_t ...@@ -341,6 +341,7 @@ struct sout_stream_id_t
pf_rtp_packetizer_t pf_packetize; pf_rtp_packetizer_t pf_packetize;
/* Packets sinks */ /* Packets sinks */
vlc_thread_t thread;
vlc_mutex_t lock_sink; vlc_mutex_t lock_sink;
int sinkc; int sinkc;
rtp_sink_t *sinkv; rtp_sink_t *sinkv;
...@@ -1346,9 +1347,14 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -1346,9 +1347,14 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
p_sys->i_ttl, id->i_port, id->i_port + 1 ); p_sys->i_ttl, id->i_port, id->i_port + 1 );
id->p_fifo = block_FifoNew(); id->p_fifo = block_FifoNew();
if( vlc_thread_create( id, "RTP send thread", ThreadSend, if( unlikely(id->p_fifo == NULL) )
VLC_THREAD_PRIORITY_HIGHEST ) ) goto error;
if( vlc_clone( &id->thread, ThreadSend, id, VLC_THREAD_PRIORITY_HIGHEST ) )
{
block_FifoRelease( id->p_fifo );
id->p_fifo = NULL;
goto error; goto error;
}
/* Update p_sys context */ /* Update p_sys context */
vlc_mutex_lock( &p_sys->lock_es ); vlc_mutex_lock( &p_sys->lock_es );
...@@ -1379,17 +1385,17 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -1379,17 +1385,17 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
{ {
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
if( id->p_fifo != NULL )
{
vlc_object_kill( id );
vlc_thread_join( id );
block_FifoRelease( id->p_fifo );
}
vlc_mutex_lock( &p_sys->lock_es ); vlc_mutex_lock( &p_sys->lock_es );
TAB_REMOVE( p_sys->i_es, p_sys->es, id ); TAB_REMOVE( p_sys->i_es, p_sys->es, id );
vlc_mutex_unlock( &p_sys->lock_es ); vlc_mutex_unlock( &p_sys->lock_es );
if( likely(id->p_fifo != NULL) )
{
vlc_cancel( id->thread );
vlc_join( id->thread, NULL );
block_FifoRelease( id->p_fifo );
}
/* Release dynamic payload type */ /* Release dynamic payload type */
if (id->i_payload_type >= 96) if (id->i_payload_type >= 96)
p_sys->payload_bitmap |= 1 << (127 - id->i_payload_type); p_sys->payload_bitmap |= 1 << (127 - id->i_payload_type);
...@@ -1550,7 +1556,7 @@ static int HttpCallback( httpd_file_sys_t *p_args, ...@@ -1550,7 +1556,7 @@ static int HttpCallback( httpd_file_sys_t *p_args,
/**************************************************************************** /****************************************************************************
* RTP send * RTP send
****************************************************************************/ ****************************************************************************/
static void* ThreadSend( vlc_object_t *p_this ) static void* ThreadSend( void *data )
{ {
#ifdef WIN32 #ifdef WIN32
# define ECONNREFUSED WSAECONNREFUSED # define ECONNREFUSED WSAECONNREFUSED
...@@ -1562,7 +1568,7 @@ static void* ThreadSend( vlc_object_t *p_this ) ...@@ -1562,7 +1568,7 @@ static void* ThreadSend( vlc_object_t *p_this )
# define EAGAIN WSAEWOULDBLOCK # define EAGAIN WSAEWOULDBLOCK
# define EWOULDBLOCK WSAEWOULDBLOCK # define EWOULDBLOCK WSAEWOULDBLOCK
#endif #endif
sout_stream_id_t *id = (sout_stream_id_t *)p_this; sout_stream_id_t *id = data;
unsigned i_caching = id->i_caching; unsigned i_caching = id->i_caching;
for (;;) for (;;)
......
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