Commit a60541d1 authored by Gildas Bazin's avatar Gildas Bazin

* modules/misc/logger/logger.c: fixed initialization bugs.
* src/misc/objects.c: in vlc_object_destroy() there's no need to lock structure_lock if
we are the root object (structure_lock has already been destroyed anyway).
parent 33913b06
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* logger.c : file logging plugin for vlc * logger.c : file logging plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: logger.c,v 1.1 2002/08/04 17:23:43 sam Exp $ * $Id: logger.c,v 1.2 2002/08/24 17:04:36 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -160,18 +160,15 @@ static int Open( vlc_object_t *p_this ) ...@@ -160,18 +160,15 @@ static int Open( vlc_object_t *p_this )
/* Open the log file and remove any buffering for the stream */ /* Open the log file and remove any buffering for the stream */
msg_Dbg( p_intf, "opening logfile `%s'", psz_file ); msg_Dbg( p_intf, "opening logfile `%s'", psz_file );
p_intf->p_sys->p_file = fopen( psz_file, "wt" ); p_intf->p_sys->p_file = fopen( psz_file, "wt" );
setvbuf( p_intf->p_sys->p_file, NULL, _IONBF, 0 );
p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
if( p_intf->p_sys->p_file == NULL ) if( p_intf->p_sys->p_file == NULL )
{ {
msg_Err( p_intf, "error opening logfile `%s'", psz_file ); msg_Err( p_intf, "error opening logfile `%s'", psz_file );
free( p_intf->p_sys ); free( p_intf->p_sys );
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
free( psz_file ); free( psz_file );
return -1; return -1;
} }
setvbuf( p_intf->p_sys->p_file, NULL, _IONBF, 0 );
p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
free( psz_file ); free( psz_file );
...@@ -186,6 +183,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -186,6 +183,8 @@ static int Open( vlc_object_t *p_this )
break; break;
} }
p_intf->pf_run = Run;
return 0; return 0;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* objects.c: vlc_object_t handling * objects.c: vlc_object_t handling
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: objects.c,v 1.19 2002/08/15 12:11:15 sam Exp $ * $Id: objects.c,v 1.20 2002/08/24 17:04:36 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -226,13 +226,15 @@ void __vlc_object_destroy( vlc_object_t *p_this ) ...@@ -226,13 +226,15 @@ void __vlc_object_destroy( vlc_object_t *p_this )
msleep( 100000 ); msleep( 100000 );
} }
vlc_mutex_lock( &p_this->p_vlc->structure_lock );
/* Wooohaa! If *this* fails, we're in serious trouble! Anyway it's /* Wooohaa! If *this* fails, we're in serious trouble! Anyway it's
* useless to try and recover anything if pp_objects gets smashed. */ * useless to try and recover anything if pp_objects gets smashed. */
if( p_this->p_vlc->i_objects > 1 ) if( p_this->i_object_type != VLC_OBJECT_ROOT )
{ {
int i_index = FindIndex( p_this, p_this->p_vlc->pp_objects, int i_index;
vlc_mutex_lock( &p_this->p_vlc->structure_lock );
i_index = FindIndex( p_this, p_this->p_vlc->pp_objects,
p_this->p_vlc->i_objects ); p_this->p_vlc->i_objects );
memmove( p_this->p_vlc->pp_objects + i_index, memmove( p_this->p_vlc->pp_objects + i_index,
p_this->p_vlc->pp_objects + i_index + 1, p_this->p_vlc->pp_objects + i_index + 1,
...@@ -242,17 +244,18 @@ void __vlc_object_destroy( vlc_object_t *p_this ) ...@@ -242,17 +244,18 @@ void __vlc_object_destroy( vlc_object_t *p_this )
p_this->p_vlc->pp_objects = p_this->p_vlc->pp_objects =
realloc( p_this->p_vlc->pp_objects, realloc( p_this->p_vlc->pp_objects,
(p_this->p_vlc->i_objects - 1) * sizeof(vlc_object_t *) ); (p_this->p_vlc->i_objects - 1) * sizeof(vlc_object_t *) );
vlc_mutex_unlock( &p_this->p_vlc->structure_lock );
} }
else else
{ {
/* We are the root object ... no need to lock. */
free( p_this->p_vlc->pp_objects ); free( p_this->p_vlc->pp_objects );
p_this->p_vlc->pp_objects = NULL; p_this->p_vlc->pp_objects = NULL;
} }
p_this->p_vlc->i_objects--; p_this->p_vlc->i_objects--;
vlc_mutex_unlock( &p_this->p_vlc->structure_lock );
vlc_mutex_destroy( &p_this->object_lock ); vlc_mutex_destroy( &p_this->object_lock );
vlc_cond_destroy( &p_this->object_wait ); vlc_cond_destroy( &p_this->object_wait );
......
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