[AD] race condition in X11

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


I ran my game in X11 this weekend, and it locked up from
time to time. It was always in a mutex lock. I tracked it
down to me doing approximately the following:

acquire_screen();
scare_mouse();
/* blit buffer to screen stuff */
unscare_mouse();
unacquire_screen();

I eventually found some comment in src/gui.c that says this
is a Bad Thing, and why. I didn't delve into why scare_mouse
should call remove_int, I just closed my eyes and backed off
quickly instead :)

Anyway, looking at the code for scare_mouse, it doesn't check
if the screen is locked, though there is a BMP_ID_LOCKED flag
that could be checked. Is there a reason for this, or would
it be alright if I added an assert there ?

Also, another strange thing is that calling acquire twice is
apparently OK (eg, no assert), the second call doesn't seem
to do anything (from memory). It doesn't track the number of
calls, though, so it will screw up the nesting. I think it
ought to assert there (and unacquire (IIRC) should assert the
BITMAP is locked, if it doesn't already.

It'd be nice to have more flags though. clip is a full int,
but it'd break lotsa programs to change it to a flags array
and move things like the locked flag there. Would it break
the binary API to add a flags member to the BITMAP array ?
(eg, bad malloc sizes, etc)


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________




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