Changeset ace44bc9f59e2ced98bb8534aa225fce9a479d8b

Show
Ignore:
Timestamp:
15/07/08 09:40:39 (5 months ago)
Author:
Pierre d'Herbemont <pdherbemont@videolan.org>
git-committer:
Pierre d'Herbemont <pdherbemont@videolan.org> 1216107639 +0200
git-parent:

[4d0721f0d1dcafd37dc6116e6b6e44a2d1b500f7]

git-author:
Pierre d'Herbemont <pdherbemont@videolan.org> 1216107639 +0200
Message:

playlist: Use PL_LOCK_IF and PL_UNLOCK_IF to perform some more checks on lock state. And fix a unlocked usage of get_current_status_item().

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/playlist/control.c

    r7f717d6 race44bc  
    6666    int i_result; 
    6767    va_start( args, b_locked ); 
    68     if( !b_locked ) PL_LOCK
     68    PL_LOCK_IF( !b_locked )
    6969    i_result = PlaylistVAControl( p_playlist, i_query, args ); 
    7070    va_end( args ); 
    71     if( !b_locked ) PL_UNLOCK
     71    PL_UNLOCK_IF( !b_locked )
    7272 
    7373    return i_result; 
  • src/playlist/engine.c

    r4d0721f race44bc  
    272272    return p_input; 
    273273} 
    274  
    275274 
    276275/** 
  • src/playlist/item.c

    r7f717d6 race44bc  
    257257{ 
    258258    int i_ret; 
    259     if( !b_locked ) PL_LOCK
     259    PL_LOCK_IF( !b_locked )
    260260    i_ret = DeleteFromInput( p_playlist, i_input_id, 
    261261                             p_root, true ); 
    262     if( !b_locked ) PL_UNLOCK
     262    PL_UNLOCK_IF( !b_locked )
    263263    return i_ret; 
    264264} 
     
    277277{ 
    278278    int i_ret1, i_ret2; 
    279     if( !b_locked ) PL_LOCK
     279    PL_LOCK_IF( !b_locked )
    280280    i_ret1 = DeleteFromInput( p_playlist, i_input_id, 
    281281                             p_playlist->p_root_category, true ); 
    282282    i_ret2 = DeleteFromInput( p_playlist, i_input_id, 
    283283                     p_playlist->p_root_onelevel, true ); 
    284     if( !b_locked ) PL_UNLOCK
     284    PL_UNLOCK_IF( !b_locked )
    285285    return ( i_ret1 == VLC_SUCCESS || i_ret2 == VLC_SUCCESS ) ? 
    286286                            VLC_SUCCESS : VLC_ENOITEM; 
     
    296296void playlist_Clear( playlist_t * p_playlist, bool b_locked ) 
    297297{ 
    298     if( !b_locked ) PL_LOCK
     298    PL_LOCK_IF( !b_locked )
    299299    playlist_NodeEmpty( p_playlist, p_playlist->p_local_category, true ); 
    300300    playlist_NodeEmpty( p_playlist, p_playlist->p_local_onelevel, true ); 
    301     if( !b_locked ) PL_UNLOCK
     301    PL_UNLOCK_IF( !b_locked )
    302302} 
    303303 
     
    404404                                             p_input->psz_uri ); 
    405405 
    406     if( !b_locked ) PL_LOCK
     406    PL_LOCK_IF( !b_locked )
    407407 
    408408    /* Add to ONELEVEL */ 
     
    422422    GoAndPreparse( p_playlist, i_mode, p_item_cat, p_item_one ); 
    423423 
    424     if( !b_locked ) PL_UNLOCK
     424    PL_UNLOCK_IF( !b_locked )
    425425    return VLC_SUCCESS; 
    426426} 
     
    453453    assert( p_input ); 
    454454 
    455     if( !b_locked ) PL_LOCK
     455    PL_LOCK_IF( !b_locked )
    456456 
    457457    if( !vlc_object_alive( p_playlist ) ) 
    458458    { 
    459         if( !b_locked ) PL_UNLOCK
     459        PL_UNLOCK_IF( !b_locked )
    460460        return VLC_EGENERIC; 
    461461    } 
     
    492492    if( i_one ) *i_one = p_item_one->i_id; 
    493493 
    494     if( !b_locked ) PL_UNLOCK
     494    PL_UNLOCK_IF( !b_locked )
    495495    return VLC_SUCCESS; 
    496496} 
     
    521521    if( p_playlist->b_die ) 
    522522        return NULL; 
    523     if( !b_locked ) PL_LOCK
     523    PL_LOCK_IF( !b_locked )
    524524 
    525525    p_item = playlist_ItemNewFromInput( p_playlist, p_input ); 
     
    527527    AddItem( p_playlist, p_item, p_parent, i_mode, i_pos ); 
    528528 
    529     if( !b_locked ) PL_UNLOCK
     529    PL_UNLOCK_IF( !b_locked )
    530530 
    531531    return p_item; 
     
    567567     */ 
    568568 
    569     if( !b_locked ) PL_LOCK
     569    PL_LOCK_IF( !b_locked )
    570570 
    571571    /* Fast track the media library, no time to loose */ 
    572572    if( p_item == p_playlist->p_ml_category ) { 
    573         if( !b_locked ) PL_UNLOCK
     573        PL_UNLOCK_IF( !b_locked )
    574574        return p_item; 
    575575    } 
     
    604604        var_SetInteger( p_playlist, "item-change", p_item_in_category-> 
    605605                                                        p_input->i_id ); 
    606         if( !b_locked ) PL_UNLOCK
     606        PL_UNLOCK_IF( !b_locked )
    607607        return p_item_in_category; 
    608608    } 
     
    610610    { 
    611611        ChangeToNode( p_playlist, p_item ); 
    612         if( !b_locked ) PL_UNLOCK
     612        PL_UNLOCK_IF( !b_locked )
    613613        return NULL; 
    614614    } 
  • src/playlist/playlist_internal.h

    r7f717d6 race44bc  
    144144#define PLI_NAME( p ) p && p->p_input ? p->p_input->psz_name : "null" 
    145145 
    146 #define PL_ASSERT_LOCKED vlc_assert_locked( &(vlc_internals(p_playlist)->lock) ); 
     146#define PL_ASSERT_LOCKED vlc_assert_locked( &(vlc_internals(p_playlist)->lock) ) 
    147147 
     148#define PL_LOCK_IF( cond ) pl_lock_if( p_playlist, cond ) 
     149static inline void pl_lock_if( playlist_t * p_playlist, bool cond ) 
     150{ 
     151    if( cond ) PL_LOCK; else PL_ASSERT_LOCKED; 
     152} 
     153 
     154#define PL_UNLOCK_IF( cond ) pl_unlock_if( p_playlist, cond ) 
     155static inline void pl_unlock_if( playlist_t * p_playlist, bool cond ) 
     156{ 
     157    if( cond ) PL_UNLOCK; 
     158} 
    148159 
    149160#endif /* !__LIBVLC_PLAYLIST_INTERNAL_H */ 
  • src/playlist/search.c

    r7f717d6 race44bc  
    4545{ 
    4646    int i; 
    47     if( !b_locked ) PL_LOCK
     47    PL_LOCK_IF( !b_locked )
    4848    ARRAY_BSEARCH( p_playlist->all_items,->i_id, int, i_id, i ); 
    4949    if( i != -1 ) 
    5050    { 
    51         if( !b_locked ) PL_UNLOCK
     51        PL_UNLOCK_IF( !b_locked )
    5252        return ARRAY_VAL( p_playlist->all_items, i ); 
    5353    } 
    54     if( !b_locked ) PL_UNLOCK
     54    PL_UNLOCK_IF( !b_locked )
    5555    return NULL; 
    5656} 
     
    6868{ 
    6969    int i; 
    70     if( !b_locked ) PL_LOCK
     70    PL_LOCK_IF( !b_locked )
    7171    if( get_current_status_item( p_playlist ) && 
    7272        get_current_status_item( p_playlist )->p_input == p_item ) 
    7373    { 
    74         if( !b_locked ) PL_UNLOCK; 
    75         return get_current_status_item( p_playlist ); 
     74        /* FIXME: this is potentially dangerous, we could destroy 
     75         * p_ret any time soon */ 
     76        input_item_t *p_ret = get_current_status_item( p_playlist ); 
     77        PL_UNLOCK_IF( !b_locked ); 
     78        return p_ret; 
    7679    } 
    7780    /** \todo Check if this is always incremental and whether we can bsearch */ 
     
    8083        if( ARRAY_VAL(p_playlist->all_items, i)->p_input->i_id == p_item->i_id ) 
    8184        { 
    82             if( !b_locked ) PL_UNLOCK
     85            PL_UNLOCK_IF( !b_locked )
    8386            return ARRAY_VAL(p_playlist->all_items, i); 
    8487        } 
    8588    } 
    86     if( !b_locked ) PL_UNLOCK
     89    PL_UNLOCK_IF( !b_locked )
    8790    return NULL; 
    8891}