diff packages/compat/posix/current/src/pthread.cxx @ 1375:8a5eb4ab7bf5

* src/mqueue.cxx: Fix problem with mq_timedsend() and mq_timedreceive() timing out with zero timeouts even when there is room in the queue. * src/pthread.cxx (pthread_exit): Added code to disable cancellation requests during thread exit. This allows thread cleanup handlers to issue system calls when cleaning up thread resources.
author nickg
date Fri, 21 Nov 2003 10:53:11 +0000
parents 999c4261716b
children
line wrap: on
line diff
--- a/packages/compat/posix/current/src/pthread.cxx
+++ b/packages/compat/posix/current/src/pthread.cxx
@@ -699,6 +699,13 @@ externC void pthread_exit (void *retval)
     
     pthread_info *self = pthread_self_info();
 
+    // Disable cancellation requests for this thread.  If cleanup
+    // handlers exist, they will generally be issuing system calls
+    // to clean up resources.  We want these system calls to run
+    // without cancelling, and we also want to prevent being
+    // re-cancelled.
+    pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+
     // Call cancellation handlers. We eat up the buffers as we go in
     // case any of the routines calls pthread_exit() itself.
     while( self->cancelbuffer != NULL )