Are pthread_setcancelstate() and pthread_setcanceltype() cancellation points?
kostikbel at gmail.com
Tue Jun 18 14:34:38 UTC 2013
On Tue, Jun 18, 2013 at 06:15:56PM +0900, Kohji Okuno wrote:
> This is newer document.
> > Hi,
> > I have a question.
> > Are pthread_setcancelstate() and pthread_setcanceltype() cancellation
> > points?
> > I refered to the following URL.
> > http://pubs.opengroup.org/onlinepubs/7908799/xsh/threads.html
> > This document shows that cancellation points in the pthread library
> > are only pthread_cond_timedwait(), pthread_cond_wait(), pthread_join()
> > and pthread_testcancel().
> > But, current implementation in FreeBSD is the following.
> > (Please take notice of "(*)" marks).
> > Would you check this?
The reason for the testcancel() calls there is that async cancellation
is defined as to be acted upon at any time after the cancellation is
enabled. If we have pending cancellation request, the async cancellation
must proceed after the pthread_setcancelstate(PTHREAD_CANCEL_ENABLE).
I see a bug there, namely, we should not process the cancellation if
the type is deferred. Is this is real issue you are concerned with ?
diff --git a/lib/libthr/thread/thr_cancel.c b/lib/libthr/thread/thr_cancel.c
index 89f0ee1..beae707 100644
@@ -87,7 +87,8 @@ _pthread_setcancelstate(int state, int *oldstate)
curthread->cancel_enable = 1;
+ if (curthread->cancel_async)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 834 bytes
Desc: not available
More information about the freebsd-current