1 /*****************************************************************************
2 * threads.c : threads implementation for the VideoLAN client
3 *****************************************************************************
4 * Copyright (C) 1999-2008 the VideoLAN team
7 * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
8 * Samuel Hocevar <sam@zoy.org>
9 * Gildas Bazin <gbazin@netcourrier.com>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
31 #include <vlc_common.h>
41 #define VLC_THREADS_UNINITIALIZED 0
42 #define VLC_THREADS_PENDING 1
43 #define VLC_THREADS_ERROR 2
44 #define VLC_THREADS_READY 3
46 /*****************************************************************************
47 * Global mutex for lazy initialization of the threads system
48 *****************************************************************************/
49 static volatile unsigned i_initializations = 0;
51 #if defined( LIBVLC_USE_PTHREAD )
54 static pthread_mutex_t once_mutex = PTHREAD_MUTEX_INITIALIZER;
56 static vlc_threadvar_t cancel_key;
60 * Global process-wide VLC object.
61 * Contains inter-instance data, such as the module cache and global mutexes.
63 static libvlc_global_data_t *p_root;
65 libvlc_global_data_t *vlc_global( void )
67 assert( i_initializations > 0 );
71 #ifdef HAVE_EXECINFO_H
72 # include <execinfo.h>
76 * Print a backtrace to the standard error for debugging purpose.
78 void vlc_trace (const char *fn, const char *file, unsigned line)
80 fprintf (stderr, "at %s:%u in %s\n", file, line, fn);
81 fflush (stderr); /* needed before switch to low-level I/O */
84 int len = backtrace (stack, sizeof (stack) / sizeof (stack[0]));
85 backtrace_symbols_fd (stack, len, 2);
92 static inline unsigned long vlc_threadid (void)
94 #if defined(LIBVLC_USE_PTHREAD)
95 union { pthread_t th; unsigned long int i; } v = { };
96 v.th = pthread_self ();
100 return GetCurrentThreadId ();
108 /*****************************************************************************
109 * vlc_thread_fatal: Report an error from the threading layer
110 *****************************************************************************
111 * This is mostly meant for debugging.
112 *****************************************************************************/
113 void vlc_thread_fatal (const char *action, int error, const char *function,
114 const char *file, unsigned line)
116 fprintf (stderr, "LibVLC fatal error %s (%d) in thread %lu ",
117 action, error, vlc_threadid ());
118 vlc_trace (function, file, line);
120 /* Sometimes strerror_r() crashes too, so make sure we print an error
121 * message before we invoke it */
123 /* Avoid the strerror_r() prototype brain damage in glibc */
125 fprintf (stderr, " Error message: %m at:\n");
126 #elif !defined (WIN32)
130 switch (strerror_r (error, buf, sizeof (buf)))
135 case ERANGE: /* should never happen */
136 msg = "unknwon (too big to display)";
139 msg = "unknown (invalid error number)";
142 fprintf (stderr, " Error message: %s\n", msg);
150 * Per-thread cancellation data
152 #ifndef LIBVLC_USE_PTHREAD_CANCEL
153 typedef struct vlc_cancel_t
155 vlc_cleanup_t *cleaners;
160 # define VLC_CANCEL_INIT { NULL, false, true }
163 /*****************************************************************************
164 * vlc_threads_init: initialize threads system
165 *****************************************************************************
166 * This function requires lazy initialization of a global lock in order to
167 * keep the library really thread-safe. Some architectures don't support this
168 * and thus do not guarantee the complete reentrancy.
169 *****************************************************************************/
170 int vlc_threads_init( void )
172 int i_ret = VLC_SUCCESS;
174 /* If we have lazy mutex initialization, use it. Otherwise, we just
175 * hope nothing wrong happens. */
176 #if defined( LIBVLC_USE_PTHREAD )
177 pthread_mutex_lock( &once_mutex );
180 if( i_initializations == 0 )
182 p_root = vlc_custom_create( (vlc_object_t *)NULL, sizeof( *p_root ),
183 VLC_OBJECT_GENERIC, "root" );
190 /* We should be safe now. Do all the initialization stuff we want. */
191 #ifndef LIBVLC_USE_PTHREAD_CANCEL
192 vlc_threadvar_create( &cancel_key, free );
198 /* If we have lazy mutex initialization support, unlock the mutex.
199 * Otherwize, we are screwed. */
200 #if defined( LIBVLC_USE_PTHREAD )
201 pthread_mutex_unlock( &once_mutex );
207 /*****************************************************************************
208 * vlc_threads_end: stop threads system
209 *****************************************************************************
210 * FIXME: This function is far from being threadsafe.
211 *****************************************************************************/
212 void vlc_threads_end( void )
214 #if defined( LIBVLC_USE_PTHREAD )
215 pthread_mutex_lock( &once_mutex );
218 assert( i_initializations > 0 );
220 if( i_initializations == 1 )
222 vlc_object_release( p_root );
223 #ifndef LIBVLC_USE_PTHREAD
224 vlc_threadvar_delete( &cancel_key );
229 #if defined( LIBVLC_USE_PTHREAD )
230 pthread_mutex_unlock( &once_mutex );
234 #if defined (__GLIBC__) && (__GLIBC_MINOR__ < 6)
235 /* This is not prototyped under glibc, though it exists. */
236 int pthread_mutexattr_setkind_np( pthread_mutexattr_t *attr, int kind );
239 /*****************************************************************************
240 * vlc_mutex_init: initialize a mutex
241 *****************************************************************************/
242 int vlc_mutex_init( vlc_mutex_t *p_mutex )
244 #if defined( LIBVLC_USE_PTHREAD )
245 pthread_mutexattr_t attr;
248 pthread_mutexattr_init( &attr );
251 /* Create error-checking mutex to detect problems more easily. */
252 # if defined (__GLIBC__) && (__GLIBC_MINOR__ < 6)
253 pthread_mutexattr_setkind_np( &attr, PTHREAD_MUTEX_ERRORCHECK_NP );
255 pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_ERRORCHECK );
258 i_result = pthread_mutex_init( p_mutex, &attr );
259 pthread_mutexattr_destroy( &attr );
261 #elif defined( UNDER_CE )
262 InitializeCriticalSection( &p_mutex->csection );
265 #elif defined( WIN32 )
266 *p_mutex = CreateMutex( 0, FALSE, 0 );
267 return (*p_mutex != NULL) ? 0 : ENOMEM;
269 #elif defined( HAVE_KERNEL_SCHEDULER_H )
270 /* check the arguments and whether it's already been initialized */
271 if( p_mutex == NULL )
276 if( p_mutex->init == 9999 )
281 p_mutex->lock = create_sem( 1, "BeMutex" );
282 if( p_mutex->lock < B_NO_ERROR )
287 p_mutex->init = 9999;
293 /*****************************************************************************
294 * vlc_mutex_init: initialize a recursive mutex (Do not use)
295 *****************************************************************************/
296 int vlc_mutex_init_recursive( vlc_mutex_t *p_mutex )
298 #if defined( LIBVLC_USE_PTHREAD )
299 pthread_mutexattr_t attr;
302 pthread_mutexattr_init( &attr );
303 # if defined (__GLIBC__) && (__GLIBC_MINOR__ < 6)
304 pthread_mutexattr_setkind_np( &attr, PTHREAD_MUTEX_RECURSIVE_NP );
306 pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE );
308 i_result = pthread_mutex_init( p_mutex, &attr );
309 pthread_mutexattr_destroy( &attr );
311 #elif defined( WIN32 )
312 /* Create mutex returns a recursive mutex */
313 *p_mutex = CreateMutex( 0, FALSE, 0 );
314 return (*p_mutex != NULL) ? 0 : ENOMEM;
316 # error Unimplemented!
321 /*****************************************************************************
322 * vlc_mutex_destroy: destroy a mutex, inner version
323 *****************************************************************************/
324 void __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mutex )
326 #if defined( LIBVLC_USE_PTHREAD )
327 int val = pthread_mutex_destroy( p_mutex );
328 VLC_THREAD_ASSERT ("destroying mutex");
330 #elif defined( UNDER_CE )
331 VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
333 DeleteCriticalSection( &p_mutex->csection );
335 #elif defined( WIN32 )
336 VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
338 CloseHandle( *p_mutex );
340 #elif defined( HAVE_KERNEL_SCHEDULER_H )
341 if( p_mutex->init == 9999 )
342 delete_sem( p_mutex->lock );
349 /*****************************************************************************
350 * vlc_cond_init: initialize a condition
351 *****************************************************************************/
352 int __vlc_cond_init( vlc_cond_t *p_condvar )
354 #if defined( LIBVLC_USE_PTHREAD )
355 pthread_condattr_t attr;
358 ret = pthread_condattr_init (&attr);
362 # if !defined (_POSIX_CLOCK_SELECTION)
363 /* Fairly outdated POSIX support (that was defined in 2001) */
364 # define _POSIX_CLOCK_SELECTION (-1)
366 # if (_POSIX_CLOCK_SELECTION >= 0)
367 /* NOTE: This must be the same clock as the one in mtime.c */
368 pthread_condattr_setclock (&attr, CLOCK_MONOTONIC);
371 ret = pthread_cond_init (p_condvar, &attr);
372 pthread_condattr_destroy (&attr);
375 #elif defined( UNDER_CE ) || defined( WIN32 )
376 /* Create an auto-reset event. */
377 *p_condvar = CreateEvent( NULL, /* no security */
378 FALSE, /* auto-reset event */
379 FALSE, /* start non-signaled */
380 NULL ); /* unnamed */
381 return *p_condvar ? 0 : ENOMEM;
383 #elif defined( HAVE_KERNEL_SCHEDULER_H )
389 if( p_condvar->init == 9999 )
394 p_condvar->thread = -1;
395 p_condvar->init = 9999;
401 /*****************************************************************************
402 * vlc_cond_destroy: destroy a condition, inner version
403 *****************************************************************************/
404 void __vlc_cond_destroy( const char * psz_file, int i_line, vlc_cond_t *p_condvar )
406 #if defined( LIBVLC_USE_PTHREAD )
407 int val = pthread_cond_destroy( p_condvar );
408 VLC_THREAD_ASSERT ("destroying condition");
410 #elif defined( UNDER_CE ) || defined( WIN32 )
411 VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
413 CloseHandle( *p_condvar );
415 #elif defined( HAVE_KERNEL_SCHEDULER_H )
421 /*****************************************************************************
422 * vlc_tls_create: create a thread-local variable
423 *****************************************************************************/
424 int vlc_threadvar_create( vlc_threadvar_t *p_tls, void (*destr) (void *) )
428 #if defined( LIBVLC_USE_PTHREAD )
429 i_ret = pthread_key_create( p_tls, destr );
430 #elif defined( UNDER_CE )
432 #elif defined( WIN32 )
433 /* FIXME: remember/use the destr() callback and stop leaking whatever */
435 i_ret = (*p_tls == TLS_OUT_OF_INDEXES) ? EAGAIN : 0;
437 # error Unimplemented!
442 void vlc_threadvar_delete (vlc_threadvar_t *p_tls)
444 #if defined( LIBVLC_USE_PTHREAD )
445 pthread_key_delete (*p_tls);
446 #elif defined( UNDER_CE )
447 #elif defined( WIN32 )
450 # error Unimplemented!
454 #if defined (LIBVLC_USE_PTHREAD)
455 #elif defined (WIN32)
456 static unsigned __stdcall vlc_entry (void *data)
458 vlc_cancel_t cancel_data = VLC_CANCEL_INIT;
459 vlc_thread_t self = data;
461 vlc_threadvar_set (&cancel_key, &cancel_data);
462 self->data = self->entry (self->data);
468 * Creates and starts new thread.
470 * @param p_handle [OUT] pointer to write the handle of the created thread to
471 * @param entry entry point for the thread
472 * @param data data parameter given to the entry point
473 * @param priority thread priority value
474 * @return 0 on success, a standard error code on error.
476 int vlc_clone (vlc_thread_t *p_handle, void * (*entry) (void *), void *data,
481 #if defined( LIBVLC_USE_PTHREAD )
483 pthread_attr_init (&attr);
485 /* Block the signals that signals interface plugin handles.
486 * If the LibVLC caller wants to handle some signals by itself, it should
487 * block these before whenever invoking LibVLC. And it must obviously not
488 * start the VLC signals interface plugin.
490 * LibVLC will normally ignore any interruption caused by an asynchronous
491 * signal during a system call. But there may well be some buggy cases
492 * where it fails to handle EINTR (bug reports welcome). Some underlying
493 * libraries might also not handle EINTR properly.
499 sigdelset (&set, SIGHUP);
500 sigaddset (&set, SIGINT);
501 sigaddset (&set, SIGQUIT);
502 sigaddset (&set, SIGTERM);
504 sigaddset (&set, SIGPIPE); /* We don't want this one, really! */
505 pthread_sigmask (SIG_BLOCK, &set, &oldset);
508 struct sched_param sp = { .sched_priority = priority, };
511 if (sp.sched_priority <= 0)
512 sp.sched_priority += sched_get_priority_max (policy = SCHED_OTHER);
514 sp.sched_priority += sched_get_priority_min (policy = SCHED_RR);
516 pthread_attr_setschedpolicy (&attr, policy);
517 pthread_attr_setschedparam (&attr, &sp);
520 ret = pthread_create (p_handle, &attr, entry, data);
521 pthread_sigmask (SIG_SETMASK, &oldset, NULL);
522 pthread_attr_destroy (&attr);
524 #elif defined( WIN32 ) || defined( UNDER_CE )
525 /* When using the MSVCRT C library you have to use the _beginthreadex
526 * function instead of CreateThread, otherwise you'll end up with
527 * memory leaks and the signal functions not working (see Microsoft
528 * Knowledge Base, article 104641) */
530 vlc_thread_t th = malloc (sizeof (*th));
537 #if defined( UNDER_CE )
538 hThread = CreateThread (NULL, 0, vlc_entry, th, CREATE_SUSPENDED, NULL);
540 hThread = (HANDLE)(uintptr_t)
541 _beginthreadex (NULL, 0, vlc_entry, th, CREATE_SUSPENDED, NULL);
546 /* Thread closes the handle when exiting, duplicate it here
547 * to be on the safe side when joining. */
548 if (!DuplicateHandle (GetCurrentProcess (), hThread,
549 GetCurrentProcess (), &th->handle, 0, FALSE,
550 DUPLICATE_SAME_ACCESS))
552 CloseHandle (hThread);
557 ResumeThread (hThread);
559 SetThreadPriority (hThread, priority);
570 #elif defined( HAVE_KERNEL_SCHEDULER_H )
571 *p_handle = spawn_thread( entry, psz_name, priority, data );
572 ret = resume_thread( *p_handle );
579 /* APC procedure for thread cancellation */
580 static void CALLBACK vlc_cancel_self (ULONG_PTR dummy)
583 vlc_control_cancel (VLC_DO_CANCEL);
588 * Marks a thread as cancelled. Next time the target thread reaches a
589 * cancellation point (while not having disabled cancellation), it will
590 * run its cancellation cleanup handler, the thread variable destructors, and
591 * terminate. vlc_join() must be used afterward regardless of a thread being
594 void vlc_cancel (vlc_thread_t thread_id)
596 #if defined (LIBVLC_USE_PTHREAD_CANCEL)
597 pthread_cancel (thread_id);
598 #elif defined (WIN32)
599 QueueUserAPC (vlc_cancel_self, thread_id->handle, 0);
601 # warning vlc_cancel is not implemented!
606 * Waits for a thread to complete (if needed), and destroys it.
607 * This is a cancellation point; in case of cancellation, the join does _not_
610 * @param handle thread handle
611 * @param p_result [OUT] pointer to write the thread return value or NULL
612 * @return 0 on success, a standard error code otherwise.
614 void vlc_join (vlc_thread_t handle, void **result)
616 #if defined( LIBVLC_USE_PTHREAD )
617 int val = pthread_join (handle, result);
619 vlc_thread_fatal ("joining thread", val, __func__, __FILE__, __LINE__);
621 #elif defined( UNDER_CE ) || defined( WIN32 )
624 while (WaitForSingleObjectEx (handle->handle, INFINITE, TRUE)
625 == WAIT_IO_COMPLETION);
627 CloseHandle (handle->handle);
629 *result = handle->data;
632 #elif defined( HAVE_KERNEL_SCHEDULER_H )
634 int val = (B_OK == wait_for_thread( p_priv->thread_id, &exit_value ));
636 *result = (void *)exit_value;
642 struct vlc_thread_boot
644 void * (*entry) (vlc_object_t *);
645 vlc_object_t *object;
648 static void *thread_entry (void *data)
650 vlc_object_t *obj = ((struct vlc_thread_boot *)data)->object;
651 void *(*func) (vlc_object_t *) = ((struct vlc_thread_boot *)data)->entry;
654 msg_Dbg (obj, "thread started");
656 msg_Dbg (obj, "thread ended");
661 /*****************************************************************************
662 * vlc_thread_create: create a thread, inner version
663 *****************************************************************************
664 * Note that i_priority is only taken into account on platforms supporting
665 * userland real-time priority threads.
666 *****************************************************************************/
667 int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line,
668 const char *psz_name, void * ( *func ) ( vlc_object_t * ),
669 int i_priority, bool b_wait )
672 vlc_object_internals_t *p_priv = vlc_internals( p_this );
674 struct vlc_thread_boot *boot = malloc (sizeof (*boot));
678 boot->object = p_this;
680 vlc_object_lock( p_this );
682 /* Make sure we don't re-create a thread if the object has already one */
683 assert( !p_priv->b_thread );
685 #if defined( LIBVLC_USE_PTHREAD )
687 if( config_GetInt( p_this, "rt-priority" ) > 0 )
690 /* Hack to avoid error msg */
691 if( config_GetType( p_this, "rt-offset" ) )
692 i_priority += config_GetInt( p_this, "rt-offset" );
696 i_ret = vlc_clone( &p_priv->thread_id, thread_entry, boot, i_priority );
701 msg_Dbg( p_this, "waiting for thread initialization" );
702 vlc_object_wait( p_this );
705 p_priv->b_thread = true;
706 msg_Dbg( p_this, "thread %lu (%s) created at priority %d (%s:%d)",
707 (unsigned long)p_priv->thread_id, psz_name, i_priority,
713 msg_Err( p_this, "%s thread could not be created at %s:%d (%m)",
714 psz_name, psz_file, i_line );
717 vlc_object_unlock( p_this );
721 /*****************************************************************************
722 * vlc_thread_set_priority: set the priority of the current thread when we
723 * couldn't set it in vlc_thread_create (for instance for the main thread)
724 *****************************************************************************/
725 int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
726 int i_line, int i_priority )
728 vlc_object_internals_t *p_priv = vlc_internals( p_this );
730 if( !p_priv->b_thread )
732 msg_Err( p_this, "couldn't set priority of non-existent thread" );
736 #if defined( LIBVLC_USE_PTHREAD )
738 if( config_GetInt( p_this, "rt-priority" ) > 0 )
741 int i_error, i_policy;
742 struct sched_param param;
744 memset( ¶m, 0, sizeof(struct sched_param) );
745 if( config_GetType( p_this, "rt-offset" ) )
746 i_priority += config_GetInt( p_this, "rt-offset" );
747 if( i_priority <= 0 )
749 param.sched_priority = (-1) * i_priority;
750 i_policy = SCHED_OTHER;
754 param.sched_priority = i_priority;
757 if( (i_error = pthread_setschedparam( p_priv->thread_id,
758 i_policy, ¶m )) )
761 msg_Warn( p_this, "couldn't set thread priority (%s:%d): %m",
767 #elif defined( WIN32 ) || defined( UNDER_CE )
768 VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
770 if( !SetThreadPriority(p_priv->thread_id->handle, i_priority) )
772 msg_Warn( p_this, "couldn't set a faster priority" );
781 /*****************************************************************************
782 * vlc_thread_join: wait until a thread exits, inner version
783 *****************************************************************************/
784 void __vlc_thread_join( vlc_object_t *p_this )
786 vlc_object_internals_t *p_priv = vlc_internals( p_this );
788 #if defined( LIBVLC_USE_PTHREAD )
789 vlc_join (p_priv->thread_id, NULL);
791 #elif defined( UNDER_CE ) || defined( WIN32 )
793 FILETIME create_ft, exit_ft, kernel_ft, user_ft;
794 int64_t real_time, kernel_time, user_time;
796 if( ! DuplicateHandle(GetCurrentProcess(),
797 p_priv->thread_id->handle,
802 DUPLICATE_SAME_ACCESS) )
804 p_priv->b_thread = false;
805 return; /* We have a problem! */
808 vlc_join( p_priv->thread_id, NULL );
810 if( GetThreadTimes( hThread, &create_ft, &exit_ft, &kernel_ft, &user_ft ) )
813 ((((int64_t)exit_ft.dwHighDateTime)<<32)| exit_ft.dwLowDateTime) -
814 ((((int64_t)create_ft.dwHighDateTime)<<32)| create_ft.dwLowDateTime);
818 ((((int64_t)kernel_ft.dwHighDateTime)<<32)|
819 kernel_ft.dwLowDateTime) / 10;
822 ((((int64_t)user_ft.dwHighDateTime)<<32)|
823 user_ft.dwLowDateTime) / 10;
825 msg_Dbg( p_this, "thread times: "
826 "real %"PRId64"m%fs, kernel %"PRId64"m%fs, user %"PRId64"m%fs",
827 real_time/60/1000000,
828 (double)((real_time%(60*1000000))/1000000.0),
829 kernel_time/60/1000000,
830 (double)((kernel_time%(60*1000000))/1000000.0),
831 user_time/60/1000000,
832 (double)((user_time%(60*1000000))/1000000.0) );
834 CloseHandle( hThread );
837 vlc_join( p_priv->thread_id, NULL );
841 p_priv->b_thread = false;
844 void vlc_thread_cancel (vlc_object_t *obj)
846 vlc_object_internals_t *priv = vlc_internals (obj);
849 vlc_cancel (priv->thread_id);
852 void vlc_control_cancel (int cmd, ...)
854 /* NOTE: This function only modifies thread-specific data, so there is no
855 * need to lock anything. */
856 #ifdef LIBVLC_USE_PTHREAD_CANCEL
864 vlc_cancel_t *nfo = vlc_threadvar_get (&cancel_key);
868 /* Main thread - cannot be cancelled anyway */
871 nfo = malloc (sizeof (*nfo));
873 return; /* Uho! Expect problems! */
874 *nfo = VLC_CANCEL_INIT;
875 vlc_threadvar_set (&cancel_key, nfo);
881 case VLC_SAVE_CANCEL:
883 int *p_state = va_arg (ap, int *);
884 *p_state = nfo->killable;
885 nfo->killable = false;
889 case VLC_RESTORE_CANCEL:
891 int state = va_arg (ap, int);
892 nfo->killable = state != 0;
896 case VLC_TEST_CANCEL:
897 if (nfo->killable && nfo->killed)
899 for (vlc_cleanup_t *p = nfo->cleaners; p != NULL; p = p->next)
902 #if defined (LIBVLC_USE_PTHREAD)
903 pthread_exit (PTHREAD_CANCELLED);
904 #elif defined (WIN32)
907 # error Not implemented!
916 case VLC_CLEANUP_PUSH:
918 /* cleaner is a pointer to the caller stack, no need to allocate
919 * and copy anything. As a nice side effect, this cannot fail. */
920 vlc_cleanup_t *cleaner = va_arg (ap, vlc_cleanup_t *);
921 cleaner->next = nfo->cleaners;
922 nfo->cleaners = cleaner;
926 case VLC_CLEANUP_POP:
928 nfo->cleaners = nfo->cleaners->next;