[AD] Potential uthreads hang on cleanup?

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


As detailed here:
http://www.allegro.cc/forums/view_thread.php?_id=438553#target

it seems pthread_cancel has some problems shutting down on some systems. The poster says it returns what resolves to "Resource temporarily unavailable", although my man pages say pthread_cancel can only fail if the requested thread doesn't exist, so I'm not really sure what's going on or what the right way to deal with it is. In either case, I attached a simple patch that fixes his issue.
Index: src/unix/uthreads.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/unix/uthreads.c,v
retrieving revision 1.19
diff -u -r1.19 uthreads.c
--- src/unix/uthreads.c	29 Nov 2004 07:58:34 -0000	1.19
+++ src/unix/uthreads.c	10 Dec 2004 05:45:36 -0000
@@ -151,7 +151,8 @@
 static void bg_man_pthreads_exit(void)
 {
    if (thread) {
-      pthread_cancel(thread);
+      while(pthread_cancel(thread))
+	 ;
       pthread_join(thread, NULL);
       pthread_mutex_destroy(&cli_mutex);
       pthread_cond_destroy(&cli_cond);


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