Ticket #3926: boost_thread.patch

File boost_thread.patch, 1.7 KB (added by dadrus, 11 years ago)

patch for linux and mac

  • once.cpp

    diff -ur old/once.cpp new/once.cpp
    old new  
    88#include <boost/assert.hpp>
    99#include <pthread.h>
    1010#include <stdlib.h>
     11#include <string.h>
    1112
    1213namespace boost
    1314{
     
    2122        {
    2223            pthread_key_t epoch_tss_key;
    2324            pthread_once_t epoch_tss_key_flag=PTHREAD_ONCE_INIT;
     25            const pthread_once_t pthread_once_init_value=PTHREAD_ONCE_INIT;
    2426           
    2527            extern "C" void delete_epoch_tss_data(void* data)
    2628            {
     
    3133            {
    3234                BOOST_VERIFY(!pthread_key_create(&epoch_tss_key,delete_epoch_tss_data));
    3335            }
    34            
     36
     37            void __attribute__((destructor)) delete_epoch_tss_key_on_dlclose()
     38            {
     39                if(memcmp(&epoch_tss_key_flag, &pthread_once_init_value, sizeof(pthread_once_t)))
     40                    pthread_key_delete(epoch_tss_key);
     41            }
    3542        }
    3643       
    3744        boost::uintmax_t& get_once_per_thread_epoch()
  • thread.cpp

    diff -ur old/thread.cpp new/thread.cpp
    old new  
    101101            {
    102102                BOOST_VERIFY(!pthread_key_create(&current_thread_tls_key,&tls_destructor));
    103103            }
     104                       
     105            void __attribute__((destructor)) delete_current_thread_tls_key_on_dlclose()
     106            {
     107                if (current_thread_tls_init_flag.epoch!=BOOST_ONCE_INITIAL_FLAG_VALUE)
     108                    pthread_key_delete(current_thread_tls_key);
     109            }
    104110        }
    105111       
    106112        boost::detail::thread_data_base* get_current_thread_data()