Changeset 358c28c444e3063246c6d966b0834b1078018fdf

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

[2e7d3d7d1581487800fbdb820e26559b5f43de15]

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

intf_Destroy(): use vlc_object_release() and a destructor instead

While reading this, you will find a bunch of:

while (find (VLC_OBJECT_INTERFACE))

release; release;

These are of course plain BUGS (which are neither introduced nor fixed
by this commit). Imagine, for instance, what happens if two threads run
the code above at the same time... they end up releasing the interface
once too many.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_interface.h

    r9d85c35 r358c28c  
    121121VLC_EXPORT( int,               intf_RunThread,  ( intf_thread_t * ) ); 
    122122VLC_EXPORT( void,              intf_StopThread, ( intf_thread_t * ) ); 
    123 VLC_EXPORT( void,              intf_Destroy,    ( intf_thread_t * ) ); 
    124123 
    125124/* If the interface is in the main thread, it should listen both to 
  • modules/access/vcdx/demux.c

    r6300760 r358c28c  
    130130        vlc_object_detach( p_intf ); 
    131131        vlc_object_release( p_intf ); 
    132         intf_Destroy( p_intf ); 
     132        vlc_object_release( p_intf ); 
    133133    } 
    134134 
  • modules/codec/cmml/cmml.c

    r13ae40b r358c28c  
    190190        vlc_object_detach( p_intf ); 
    191191        vlc_object_release( p_intf ); 
    192         intf_Destroy( p_intf ); 
     192        vlc_object_release( p_intf ); 
    193193    } 
    194194 
  • modules/control/ntservice.c

    r13ae40b r358c28c  
    165165        vlc_object_detach( p_extraintf ); 
    166166        vlc_object_release( p_extraintf ); 
    167         intf_Destroy( p_extraintf ); 
     167        vlc_object_release( p_extraintf ); 
    168168    } 
    169169 
     
    333333            { 
    334334                vlc_object_detach( p_new_intf ); 
    335                 intf_Destroy( p_new_intf ); 
     335                vlc_object_release( p_new_intf ); 
    336336                msg_Err( p_intf, "interface \"%s\" cannot run", psz_temp ); 
    337337            } 
  • modules/control/rc.c

    r13ae40b r358c28c  
    15441544        { 
    15451545            vlc_object_detach( p_newintf ); 
    1546             intf_Destroy( p_newintf ); 
     1546            vlc_object_release( p_newintf ); 
    15471547        } 
    15481548    } 
  • src/interface/interface.c

    r6da90a1 r358c28c  
    5555                            vlc_value_t , vlc_value_t , void * ); 
    5656 
     57/** 
     58 * \brief Destroy the interface after the main loop endeed. 
     59 * 
     60 * \param p_intf the interface thread 
     61 * \return nothing 
     62 */ 
     63static void intf_Destroy( vlc_object_t *obj ) 
     64{ 
     65    intf_thread_t *p_intf = (intf_thread_t *)obj; 
     66 
     67    /* Unlock module if present (a switch may have failed) */ 
     68    if( p_intf->p_module ) 
     69        module_Unneed( p_intf, p_intf->p_module ); 
     70 
     71    free( p_intf->psz_intf ); 
     72    vlc_mutex_destroy( &p_intf->change_lock ); 
     73} 
     74 
    5775/***************************************************************************** 
    5876 * intf_Create: prepare interface before main loop 
     
    115133    /* Attach interface to its parent object */ 
    116134    vlc_object_attach( p_intf, p_this ); 
     135    vlc_object_set_destructor( p_intf, intf_Destroy ); 
    117136 
    118137    return p_intf; 
     
    141160    { 
    142161        RunInterface( p_intf ); 
     162        vlc_object_detach( p_intf ); 
     163        vlc_object_release( p_intf ); 
    143164        return VLC_SUCCESS; 
    144165    } 
     
    172193    } 
    173194} 
    174  
    175 /** 
    176  * \brief Destroy the interface after the main loop endeed. 
    177  * 
    178  * Destroys interfaces and closes output devices 
    179  * \param p_intf the interface thread 
    180  * \return nothing 
    181  */ 
    182 void intf_Destroy( intf_thread_t *p_intf ) 
    183 { 
    184     /* Unlock module if present (a switch may have failed) */ 
    185     if( p_intf->p_module ) 
    186     { 
    187         module_Unneed( p_intf, p_intf->p_module ); 
    188     } 
    189     free( p_intf->psz_intf ); 
    190  
    191     vlc_mutex_destroy( &p_intf->change_lock ); 
    192  
    193     /* Free structure */ 
    194     vlc_object_release( p_intf ); 
    195 } 
    196  
    197195 
    198196/* Following functions are local */ 
     
    284282    { 
    285283        vlc_object_detach( p_intf ); 
    286         intf_Destroy( p_intf ); 
     284        vlc_object_release( p_intf ); 
    287285        return VLC_EGENERIC; 
    288286    } 
  • src/libvlc-common.c

    re9b987f r358c28c  
    937937        intf_StopThread( p_intf ); 
    938938        vlc_object_detach( p_intf ); 
    939         vlc_object_release( p_intf ); 
    940         intf_Destroy( p_intf ); 
    941         p_intf = NULL; 
     939        vlc_object_release( p_intf ); /* for intf_Create() */ 
     940        vlc_object_release( p_intf ); /* for vlc_object_find() */ 
    942941    } 
    943942 
     
    11451144    p_intf->b_play = b_play; 
    11461145    i_err = intf_RunThread( p_intf ); 
    1147     if( i_err || p_intf->b_should_run_on_first_thread
     1146    if( i_err
    11481147    { 
    11491148        vlc_object_detach( p_intf ); 
    1150         intf_Destroy( p_intf ); 
    1151         p_intf = NULL; 
     1149        vlc_object_release( p_intf ); 
    11521150        return i_err; 
    11531151    } 
     
    11621160 
    11631161        vlc_object_detach( p_intf ); 
    1164         intf_Destroy( p_intf ); 
     1162        vlc_object_release( p_intf ); 
    11651163    } 
    11661164 
  • src/libvlccore.sym

    ra5387cb r358c28c  
    148148input_vaControl 
    149149__intf_Create 
    150 intf_Destroy 
    151150__intf_Eject 
    152151__intf_Progress