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

remoteosd: fix update thread leak

parent b3282523
...@@ -570,11 +570,24 @@ static int write_update_request(filter_t *p_filter, bool incremental) ...@@ -570,11 +570,24 @@ static int write_update_request(filter_t *p_filter, bool incremental)
return w; return w;
} }
static void update_thread_cleanup( void *p )
{
vlc_thread_t *th = p;
vlc_cancel( *th );
vlc_join( *th, NULL );
}
static void dummy_cleanup( void *p )
{
(void) p;
}
static void* vnc_worker_thread( void *obj ) static void* vnc_worker_thread( void *obj )
{ {
filter_t* p_filter = (filter_t*)obj; filter_t* p_filter = (filter_t*)obj;
filter_sys_t *p_sys = p_filter->p_sys; filter_sys_t *p_sys = p_filter->p_sys;
vlc_thread_t update_request_thread_handle; vlc_thread_t update_thread;
int canc = vlc_savecancel (); int canc = vlc_savecancel ();
msg_Dbg( p_filter, "VNC worker thread started" ); msg_Dbg( p_filter, "VNC worker thread started" );
...@@ -607,13 +620,16 @@ static void* vnc_worker_thread( void *obj ) ...@@ -607,13 +620,16 @@ static void* vnc_worker_thread( void *obj )
/* create the update request thread */ /* create the update request thread */
bool polling = var_InheritBool( p_filter, RMTOSD_CFG "vnc-polling" ); bool polling = var_InheritBool( p_filter, RMTOSD_CFG "vnc-polling" );
if( polling if( polling
&& vlc_clone( &update_request_thread_handle, update_request_thread, && vlc_clone( &update_thread, update_request_thread,
p_filter, VLC_THREAD_PRIORITY_LOW ) ) p_filter, VLC_THREAD_PRIORITY_LOW ) )
{ {
msg_Err( p_filter, "cannot spawn VNC update request thread" ); msg_Err( p_filter, "cannot spawn VNC update request thread" );
polling = false; polling = false;
} }
vlc_cleanup_push( polling ? update_thread_cleanup : dummy_cleanup,
&update_thread );
/* connection is initialized, now read and handle server messages */ /* connection is initialized, now read and handle server messages */
for( ;; ) for( ;; )
{ {
...@@ -668,11 +684,9 @@ static void* vnc_worker_thread( void *obj ) ...@@ -668,11 +684,9 @@ static void* vnc_worker_thread( void *obj )
process_server_message( p_filter, &msg); process_server_message( p_filter, &msg);
} }
vlc_cleanup_pop();
if( polling ) if( polling )
{ update_thread_cleanup( &update_thread );
vlc_cancel( update_request_thread_handle );
vlc_join( update_request_thread_handle, NULL );
}
msg_Dbg( p_filter, "VNC message reader thread ended" ); msg_Dbg( p_filter, "VNC message reader thread ended" );
vlc_restorecancel (canc); vlc_restorecancel (canc);
......
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