Changeset b187d11b4c62350735a452f6b523b642cb37b4ab

Show
Ignore:
Timestamp:
05/14/08 19:15:31 (2 months ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1210785331 +0300
git-parent:

[58a1d71baee1aac656ff54356104261d780e4a6d]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1210785331 +0300
Message:

Detach dying objects atomically, so FIND_CHILDREN is safe

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/misc/objects.c

    r58a1d71 rb187d11  
    8484 
    8585static void vlc_object_destroy( vlc_object_t *p_this ); 
     86static void vlc_object_detach_unlocked (vlc_object_t *p_this); 
    8687 
    8788/***************************************************************************** 
     
    316317    vlc_object_internals_t *p_priv = vlc_internals( p_this ); 
    317318 
    318     /* Automatically detach the object from its parent */ 
    319     if( p_this->p_parent ) vlc_object_detach( p_this ); 
    320  
     319    /* Objects are always detached beforehand */ 
     320    assert( !p_this->p_parent ); 
    321321 
    322322    /* Send a kill to the object's thread if applicable */ 
     
    885885        REMOVE_ELEM( p_libvlc_global->pp_objects, 
    886886                     p_libvlc_global->i_objects, i_index ); 
     887        if (p_this->p_parent) 
     888            vlc_object_detach_unlocked (p_this); 
    887889    } 
    888890 
     
    922924} 
    923925 
     926 
     927static void vlc_object_detach_unlocked (vlc_object_t *p_this) 
     928{ 
     929    assert (p_this->p_parent); 
     930 
     931    /* Climb up the tree to see whether we are connected with the root */ 
     932    if( vlc_internals( p_this->p_parent )->b_attached ) 
     933        SetAttachment( p_this, false ); 
     934 
     935    DetachObject( p_this ); 
     936} 
     937 
     938 
    924939/** 
    925940 **************************************************************************** 
     
    941956    } 
    942957 
    943     /* Climb up the tree to see whether we are connected with the root */ 
    944     if( vlc_internals( p_this->p_parent )->b_attached ) 
    945     { 
    946         SetAttachment( p_this, false ); 
    947     } 
    948  
    949     DetachObject( p_this ); 
     958    vlc_object_detach_unlocked( p_this ); 
    950959    vlc_mutex_unlock( &structure_lock ); 
    951     p_this = NULL; 
    952960} 
    953961