Alfred Perlstein wrote: > > * Daniel Eischen <[EMAIL PROTECTED]> [011130 16:17] wrote: > > On Fri, 30 Nov 2001, Louis-Philippe Gagnon wrote: > > > If at first you don't succeed... > > > > > > I've encountered a problem using pthread_cancel, pthread_join and > > > pthread_setcanceltype, I'm hoping someone can shed some light. > > > > > > (in a nutshell : pthread_setcanceltype doesn't seem to work in FreeBSD 4.4) > > > > > > (posted to -current and -hackers; if there's a more appropriate mailing list > > > for this, please let me know) > > > > > > I recently encountered a situation where, after calling pthread_cancel to > > > cancel a thread, the call to pthread_join hangs indefinitely. I quickly figured > > > out that it was because the thread being cancelled was never reaching a > > > cancellation point (in fact it was an infinite loop with no function calls at >all). > > > Sure enough, adding a pthread_testcancel() in the loop allowed > > > pthread_join to return. However this solution isn't acceptable for my >requirements. > > please test the following patch:
There are already cancellation tests when resuming threads whose contexts are not saved as a result of a signal interrupt (ctxtype != CTX_UC). You shouldn't test for cancellation when ctxtype == CTX_UC because you are running on the scheduler stack, not the threads stack. You also have a bug in the way you changed the check for cancellation flags. There only clean way to fix this is to add a return frame to the interrupted context so that it can check for cancellation (and other things) before returning to the threads interrupted context. -- Dan Eischen To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message