[AD] timer_thread_mutex

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Is there a reason timer_thread_mutex is not initialized in
al_install_system? The current implementation seems to have a race
condition where if many timers are started in many threads with
al_start_timer, several of them will think they are the first thread and
new_size below will be 1 for multiple ones:

      if (new_size == 1) {
         _al_mutex_init(&timer_thread_mutex);
         _al_thread_create(&timer_thread, timer_thread_proc, NULL);
      }

Then each one will execute this and hilarity ensues... :P As I said the
fix would be very simple, just moving the _al_mutex_init line into
al_install_system - but want to confirm this is the problem before
making a patch (as I have a hard time re-producing it now).

-- 
Elias Pschernig <elias.pschernig@xxxxxxxxxx>





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/