Re: [AD] timer_mutex again

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


> On the debug, C-only, X11 port of Allegro I can easily get a deadlock
> when grabber starts up.  At some stage, show_mouse(NULL) is called,
> which calls remove_int(), which locks the timer_mutex in timer.c, but
> the timer_mutex is already locked by _handle_timer_tick() while it tries
> to fire off timer callback functions.  Sound familiar?

Why does it deadlock in the end?

> I think _handle_timer_tick() doesn't actually need to lock the
> timer_mutex for its duration.  As far as I can tell, it's only to
> prevent install_int() and remove_int() calls from messing about with the
> _timer_queue global structure (which contains the list of registered
> timer callbacks) that could, e.g. cause _handle_timer_tick() to
> derefence a NULL pointer.

I'm not so sure.  IIRC I added the timer mutex because of the following 
situation:

void callback(void)
{
  /* dereference pointer p */
}

remove_int (callback);
p = NULL;

The idea was to make sure that all callbacks have completed before remove_int 
returns.  Does your proposed change still guarantee that?

-- 
Eric Botcazou




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