[AD] freeze on exit in windows

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


The old problem.. should be fixed by the attached patch. It does 2
things: Enables the timer mutexes, and replaces the INFINITE when
waiting for the thread with a loop. Why the loop is necessary, I don't
know. but the MSDN docs tell you to not use INFINITE when calling
CoInitialize (which we do), and their example uses a loop like this as
well.

(I also remember now, someone already pointed out that the
WaitForSingleObject line was the problem, but couldn't reproduce it
anymore when I started investigating.. and at that time, I couldn't
reproduce it myself, since HT was disabled in windows.)
Index: src/timer.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/timer.c,v
retrieving revision 1.22
diff -u -p -r1.22 timer.c
--- src/timer.c	24 Apr 2005 08:06:00 -0000	1.22
+++ src/timer.c	27 Apr 2005 14:42:15 -0000
@@ -26,10 +26,6 @@
 /* Only tested with X11 so far. Can remove completely once it is tested with
  * other platforms.
  */
-#ifndef ALLEGRO_WITH_XWINDOWS
-#undef ALLEGRO_MULTITHREADED  /* FIXME */
-#endif
-
 
 TIMER_DRIVER *timer_driver = NULL;        /* the active driver */
 
Index: src/win/wtimer.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wtimer.c,v
retrieving revision 1.17
diff -u -p -r1.17 wtimer.c
--- src/win/wtimer.c	14 Mar 2005 11:29:15 -0000	1.17
+++ src/win/wtimer.c	27 Apr 2005 14:42:15 -0000
@@ -245,7 +245,7 @@ static void tim_win32_exit(void)
    SetEvent(timer_stop_event);
 
    /* wait until thread has ended */
-   WaitForSingleObject(timer_thread, INFINITE);
+   while (WaitForSingleObject(timer_thread, 100) == WAIT_TIMEOUT);
 
    /* thread has ended, now we can release all resources */
    CloseHandle(timer_stop_event);


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