Changeset fb7f7d22b070fbe51775f102cc66bd84b04e44b4

Show
Ignore:
Timestamp:
05/10/08 22:22:19 (6 days ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1210450939 +0300
git-parent:

[7793bdcbd3a77917c4dec40c737a8b04017430c5]

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

The TLS also needs to be cleaned up... should fix #1576

Files:

Legend:

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

    r9a719ad rfb7f7d2  
    171171VLC_EXPORT( int,  __vlc_cond_init,     ( vlc_cond_t * ) ); 
    172172VLC_EXPORT( void,  __vlc_cond_destroy,  ( const char *, int, vlc_cond_t * ) ); 
    173 VLC_EXPORT( int, __vlc_threadvar_create, (vlc_threadvar_t * ) ); 
     173VLC_EXPORT( int, vlc_threadvar_create, (vlc_threadvar_t * , void (*) (void *) ) ); 
     174VLC_EXPORT( void, vlc_threadvar_delete, (vlc_threadvar_t *) ); 
    174175VLC_EXPORT( int,  __vlc_thread_create, ( vlc_object_t *, const char *, int, const char *, void * ( * ) ( void * ), int, bool ) ); 
    175176VLC_EXPORT( int,  __vlc_thread_set_priority, ( vlc_object_t *, const char *, int, int ) ); 
     
    435436 
    436437/***************************************************************************** 
    437  * vlc_threadvar_create: create a thread-local variable 
    438  *****************************************************************************/ 
    439 #define vlc_threadvar_create( PTHIS, P_TLS )                                 \ 
    440    __vlc_threadvar_create( P_TLS ) 
    441  
    442 /***************************************************************************** 
    443438 * vlc_threadvar_set: create: set the value of a thread-local variable 
    444439 *****************************************************************************/ 
  • src/libvlc.h

    rcdd5175 rfb7f7d2  
    4747void vlc_threads_end( void ); 
    4848 
     49/* 
     50 * CPU capabilities 
     51 */ 
     52extern uint32_t cpu_flags; 
     53uint32_t CPUCapabilities( void ); 
     54 
     55/* 
     56 * Message/logging stuff 
     57 */ 
     58 
     59typedef struct msg_queue_t 
     60{ 
     61    /** Message queue lock */ 
     62    vlc_mutex_t             lock; 
     63    bool              b_overflow; 
     64 
     65    /* Message queue */ 
     66    msg_item_t              msg[VLC_MSG_QSIZE];           /**< message queue */ 
     67    int i_start; 
     68    int i_stop; 
     69 
     70    /* Subscribers */ 
     71    int i_sub; 
     72    msg_subscription_t **pp_sub; 
     73 
     74    /* Logfile for WinCE */ 
     75#ifdef UNDER_CE 
     76    FILE *logfile; 
     77#endif 
     78} msg_queue_t; 
     79 
     80/** 
     81 * Store all data required by messages interfaces. 
     82 */ 
     83typedef struct msg_bank_t 
     84{ 
     85    vlc_mutex_t             lock; 
     86    msg_queue_t             queue; 
     87} msg_bank_t; 
     88 
     89void msg_Create  (libvlc_int_t *); 
     90void msg_Flush   (libvlc_int_t *); 
     91void msg_Destroy (libvlc_int_t *); 
     92 
     93/** Internal message stack context */ 
     94typedef struct 
     95{ 
     96    int i_code; 
     97    char * psz_message; 
     98} msg_context_t; 
     99 
     100void msg_StackSet ( int, const char*, ... ); 
     101void msg_StackAdd ( const char*, ... ); 
     102const char* msg_StackMsg ( void ); 
    49103/** The global thread var for msg stack context 
    50104 *  We store this as a static global variable so we don't need a vlc_object_t 
     
    53107 *  the very beginning of the universe */ 
    54108extern vlc_threadvar_t msg_context_global_key; 
    55  
    56 /* 
    57  * CPU capabilities 
    58  */ 
    59 extern uint32_t cpu_flags; 
    60 uint32_t CPUCapabilities( void ); 
    61  
    62 /* 
    63  * Message/logging stuff 
    64  */ 
    65  
    66 typedef struct msg_queue_t 
    67 
    68     /** Message queue lock */ 
    69     vlc_mutex_t             lock; 
    70     bool              b_overflow; 
    71  
    72     /* Message queue */ 
    73     msg_item_t              msg[VLC_MSG_QSIZE];           /**< message queue */ 
    74     int i_start; 
    75     int i_stop; 
    76  
    77     /* Subscribers */ 
    78     int i_sub; 
    79     msg_subscription_t **pp_sub; 
    80  
    81     /* Logfile for WinCE */ 
    82 #ifdef UNDER_CE 
    83     FILE *logfile; 
    84 #endif 
    85 } msg_queue_t; 
    86  
    87 /** 
    88  * Store all data required by messages interfaces. 
    89  */ 
    90 typedef struct msg_bank_t 
    91 
    92     vlc_mutex_t             lock; 
    93     msg_queue_t             queue; 
    94 } msg_bank_t; 
    95  
    96 void msg_Create  (libvlc_int_t *); 
    97 void msg_Flush   (libvlc_int_t *); 
    98 void msg_Destroy (libvlc_int_t *); 
    99  
    100 /** Internal message stack context */ 
    101 typedef struct 
    102 
    103     int i_code; 
    104     char * psz_message; 
    105 } msg_context_t; 
    106  
    107 void msg_StackSet ( int, const char*, ... ); 
    108 void msg_StackAdd ( const char*, ... ); 
    109 const char* msg_StackMsg ( void ); 
     109void msg_StackDestroy (void *); 
    110110 
    111111/* 
  • src/libvlc.sym

    r62ba576 rfb7f7d2  
    456456__vlc_thread_ready 
    457457__vlc_thread_set_priority 
    458 __vlc_threadvar_create 
     458vlc_threadvar_create 
     459vlc_threadvar_delete 
    459460vlc_ureduce 
    460461vlc_vasprintf 
  • src/misc/messages.c

    r7793bdc rfb7f7d2  
    615615} 
    616616 
     617void msg_StackDestroy (void *data) 
     618{ 
     619    msg_context_t *p_ctx = data; 
     620 
     621    free (p_ctx->psz_message); 
     622    free (p_ctx); 
     623} 
     624 
    617625void msg_StackSet( int i_code, const char *psz_message, ... ) 
    618626{ 
     
    622630    if( p_ctx == NULL ) 
    623631        return; 
     632    free( p_ctx->psz_message ); 
    624633 
    625634    va_start( ap, psz_message ); 
    626     free( p_ctx->psz_message ); 
    627  
    628635    if( vasprintf( &p_ctx->psz_message, psz_message, ap ) == -1 ) 
    629636        p_ctx->psz_message = NULL; 
  • src/misc/threads.c

    r9a719ad rfb7f7d2  
    146146 
    147147        /* We should be safe now. Do all the initialization stuff we want. */ 
    148         vlc_threadvar_create( p_root, &msg_context_global_key ); 
     148        vlc_threadvar_create( &msg_context_global_key, msg_StackDestroy ); 
    149149    } 
    150150    i_initializations++; 
     
    174174 
    175175    if( i_initializations == 1 ) 
     176    { 
    176177        vlc_object_release( p_root ); 
     178        vlc_threadvar_delete( &msg_context_global_key ); 
     179    } 
    177180    i_initializations--; 
    178181 
     
    375378 * vlc_tls_create: create a thread-local variable 
    376379 *****************************************************************************/ 
    377 int __vlc_threadvar_create( vlc_threadvar_t *p_tls
    378 { 
    379     int i_ret = -1
    380  
    381 #if defined( LIBVLC_USE_PTHREAD ) 
    382     i_ret =  pthread_key_create( p_tls, NULL ); 
     380int vlc_threadvar_create( vlc_threadvar_t *p_tls, void (*destr) (void *)
     381{ 
     382    int i_ret
     383 
     384#if defined( LIBVLC_USE_PTHREAD ) 
     385    i_ret =  pthread_key_create( p_tls, destr ); 
    383386#elif defined( UNDER_CE ) 
     387    i_ret = ENOSYS; 
    384388#elif defined( WIN32 ) 
    385389    *p_tls = TlsAlloc(); 
     
    389393#endif 
    390394    return i_ret; 
     395} 
     396 
     397void vlc_threadvar_delete (vlc_threadvar_t *p_tls) 
     398{ 
     399#if defined( LIBVLC_USE_PTHREAD ) 
     400    pthread_key_delete (p_tls); 
     401#elif defined( UNDER_CE ) 
     402#elif defined( WIN32 ) 
     403    TlsFree (*p_tls); 
     404#else 
     405# error Unimplemented! 
     406#endif 
    391407} 
    392408