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

Inline all remaining calls to vlc_cleanup_run()

The code size saving in vlc_cleanup_run() is marginal and premature
optimization. In practice, vlc_cleanup_run() makes the source code
harder to follow/read, confuses static analyzers and generates false
positive clobber warnings (on some OSes due to long jumps).

It did exercise some of the cleanup code paths though.
parent 79014d08
......@@ -457,7 +457,8 @@ VLC_API void vlc_cond_broadcast(vlc_cond_t *);
// -- foobar is now true, do something about it here --
vlc_cleanup_run(); // release the mutex
vlc_cleanup_pop();
vlc_mutex_unlock(&lock);
@endcode
*
* \note This function is a cancellation point. In case of thread cancellation,
......
......@@ -428,7 +428,8 @@ static void* Run( void *data )
vlc_mutex_lock( &p_ext->p_sys->command_lock );
}
vlc_cleanup_run( );
vlc_cleanup_pop( );
vlc_mutex_unlock( &p_ext->p_sys->command_lock );
msg_Dbg( p_mgr, "Extension thread end: '%s'", p_ext->psz_title );
// Note: At this point, the extension should be deactivated
......
......@@ -169,7 +169,12 @@ static void *Thread (void *data)
break;
}
}
vlc_cleanup_run (); /* free (buf) */
vlc_cleanup_pop ();
#ifdef HAVE_VMSPLICE
munmap (buf, bufsize);
#else
free (buf);
#endif
}
while (!error);
......
......@@ -807,7 +807,8 @@ static void* update_request_thread( void *obj )
break;
}
}
vlc_cleanup_run();
vlc_cleanup_pop();
p_filter->p_sys->b_continue = false;
}
else
{
......
......@@ -323,11 +323,11 @@ int vlc_cond_timedwait (vlc_cond_t *condvar, vlc_mutex_t *p_mutex,
/* pthread */
static void clean_detached_thread(void *data)
{
struct vlc_thread *thread = data;
struct vlc_thread *th = data;
/* release thread handle */
vlc_mutex_destroy(&thread->lock);
free(thread);
vlc_mutex_destroy(&th->lock);
free(th);
}
static void *detached_thread(void *data)
......@@ -336,9 +336,11 @@ static void *detached_thread(void *data)
thread = th;
vlc_cleanup_push(clean_detached_thread, data);
vlc_cleanup_push(clean_detached_thread, th);
th->entry(th->data);
vlc_cleanup_run();
vlc_cleanup_pop();
vlc_mutex_destroy(&th->lock);
free(th);
return NULL;
}
......@@ -358,7 +360,8 @@ static void *joinable_thread(void *data)
vlc_cleanup_push(finish_joinable_thread, th);
thread = th;
ret = th->entry(th->data);
vlc_cleanup_run();
vlc_cleanup_pop();
vlc_sem_post(&th->finished);
return ret;
}
......@@ -531,7 +534,8 @@ void mwait (mtime_t deadline)
vlc_mutex_lock (&lock);
mutex_cleanup_push (&lock);
while (!vlc_cond_timedwait (&wait, &lock, deadline));
vlc_cleanup_run ();
vlc_cleanup_pop ();
vlc_mutex_unlock (&lock);
vlc_cond_destroy (&wait);
vlc_mutex_destroy (&lock);
......
......@@ -1435,7 +1435,8 @@ static void *DecoderThread( void *p_data )
}
p_block = vlc_fifo_DequeueUnlocked( p_owner->p_fifo );
vlc_cleanup_run();
vlc_cleanup_pop();
vlc_fifo_Unlock( p_owner->p_fifo );
int canc = vlc_savecancel();
DecoderProcess( p_dec, p_block );
......
......@@ -1011,7 +1011,8 @@ static void *TsRun( void *p_data )
}
i_deadline = cmd.i_date + p_ts->i_cmd_delay + p_ts->i_rate_delay + p_ts->i_buffering_delay;
vlc_cleanup_run();
vlc_cleanup_pop();
vlc_mutex_unlock( &p_ts->lock );
/* Regulate the speed of command processing to the same one than
* reading */
......
......@@ -412,7 +412,8 @@ static void* Manage( void* p_object )
vlc_cond_wait( &vlm->wait_manage, &vlm->lock_manage );
}
vlm->input_state_changed = false;
vlc_cleanup_run( );
vlc_cleanup_pop( );
vlc_mutex_unlock( &vlm->lock_manage );
int canc = vlc_savecancel ();
/* destroy the inputs that wants to die, and launch the next input */
......
......@@ -336,7 +336,8 @@ static void *FinderThread( void *p_data )
}
psz_uri = p_manager->p_priv->finder.uris.p_elems[0];
ARRAY_REMOVE( p_manager->p_priv->finder.uris, 0 );
vlc_cleanup_run();
vlc_cleanup_pop();
vlc_mutex_unlock( &p_manager->p_priv->finder.lock );
addons_finder_t *p_finder =
vlc_custom_create( p_manager->p_priv->p_parent, sizeof( *p_finder ), "entries finder" );
......
......@@ -169,6 +169,7 @@ void vlc_sem_wait (vlc_sem_t *sem)
while (!sem->value)
vlc_cond_wait (&sem->wait, &sem->lock);
sem->value--;
vlc_cleanup_run ();
vlc_cleanup_pop ();
vlc_mutex_unlock (&sem->lock);
}
#endif /* LIBVLC_NEED_SEMAPHORE */
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