[AD] small bug in uthreads.c

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


As this thread http://www.allegro.cc/forums/view_thread.php?_id=433516
shows, there is a bug in uthreads.c. It tries to close the background
thread, even if it failed creating it. (I'm puzzled though how the
creation of the thread can fail.)


-- 
Elias Pschernig
Index: src/unix/uthreads.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/unix/uthreads.c,v
retrieving revision 1.18
diff -u -p -r1.18 uthreads.c
--- src/unix/uthreads.c	29 Jul 2004 08:27:35 -0000	1.18
+++ src/unix/uthreads.c	26 Nov 2004 13:12:45 -0000
@@ -42,6 +42,8 @@ static pthread_mutex_t cli_mutex;
 static pthread_cond_t cli_cond;
 static int cli_count;
 
+static int active = 0;
+
 
 
 /* block_all_signals:
@@ -137,6 +139,8 @@ static int bg_man_pthreads_init(void)
       return -1;
    }
 
+   active = 1;
+
    return 0;
 }
 
@@ -147,6 +151,8 @@ static int bg_man_pthreads_init(void)
  */
 static void bg_man_pthreads_exit(void)
 {
+   if (!active)
+      return;
    pthread_cancel(thread);
    pthread_join(thread, NULL);
    pthread_mutex_destroy(&cli_mutex);


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