]> git.sesse.net Git - vlc/commitdiff
* modules/misc/logger/logger.c: fixed initialization bugs.
authorGildas Bazin <gbazin@videolan.org>
Sat, 24 Aug 2002 17:04:36 +0000 (17:04 +0000)
committerGildas Bazin <gbazin@videolan.org>
Sat, 24 Aug 2002 17:04:36 +0000 (17:04 +0000)
* 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).

modules/misc/logger/logger.c
src/misc/objects.c

index c17d6ac9eed73d7afed9dea5a1f3f19a9cc86ab0..1e30ceffc912e4b388c0814e24aec5aa32cdf582 100644 (file)
@@ -2,7 +2,7 @@
  * logger.c : file logging plugin for vlc
  *****************************************************************************
  * 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>
  *
@@ -160,18 +160,15 @@ static int Open( vlc_object_t *p_this )
     /* Open the log file and remove any buffering for the stream */
     msg_Dbg( p_intf, "opening logfile `%s'", psz_file );
     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 )
     {
         msg_Err( p_intf, "error opening logfile `%s'", psz_file );
         free( p_intf->p_sys );
-        msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
         free( psz_file );
         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 );
 
@@ -186,6 +183,8 @@ static int Open( vlc_object_t *p_this )
         break;
     }
 
+    p_intf->pf_run = Run;
+
     return 0;
 }
 
index f89b048f2edc4c30b4ba40a9e1d12034869c5f0f..8980a63ebf0eb57956ec3911985432b9e84706cb 100644 (file)
@@ -2,7 +2,7 @@
  * objects.c: vlc_object_t handling
  *****************************************************************************
  * 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>
  *
@@ -226,14 +226,16 @@ void __vlc_object_destroy( vlc_object_t *p_this )
         msleep( 100000 );
     }
 
-    vlc_mutex_lock( &p_this->p_vlc->structure_lock );
-
     /* Wooohaa! If *this* fails, we're in serious trouble! Anyway it's
      * 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,
-                                         p_this->p_vlc->i_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 );
         memmove( p_this->p_vlc->pp_objects + i_index,
                  p_this->p_vlc->pp_objects + i_index + 1,
                  (p_this->p_vlc->i_objects - i_index - 1)
@@ -242,17 +244,18 @@ void __vlc_object_destroy( vlc_object_t *p_this )
         p_this->p_vlc->pp_objects =
             realloc( p_this->p_vlc->pp_objects,
                      (p_this->p_vlc->i_objects - 1) * sizeof(vlc_object_t *) );
+
+        vlc_mutex_unlock( &p_this->p_vlc->structure_lock );
     }
     else
     {
+        /* We are the root object ... no need to lock. */
         free( p_this->p_vlc->pp_objects );
         p_this->p_vlc->pp_objects = NULL;
     }
 
     p_this->p_vlc->i_objects--;
 
-    vlc_mutex_unlock( &p_this->p_vlc->structure_lock );
-
     vlc_mutex_destroy( &p_this->object_lock );
     vlc_cond_destroy( &p_this->object_wait );