Date: Tue, 18 Jun 2013 17:34:28 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Kohji Okuno <okuno.kohji@jp.panasonic.com> Cc: freebsd-current@FreeBSD.org Subject: Re: Are pthread_setcancelstate() and pthread_setcanceltype() cancellation points? Message-ID: <20130618143428.GV91021@kib.kiev.ua> In-Reply-To: <20130618.181556.452619654831646148.okuno.kohji@jp.panasonic.com> References: <20130618.174849.1772987860003116966.okuno.kohji@jp.panasonic.com> <20130618.181556.452619654831646148.okuno.kohji@jp.panasonic.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--Pe/WPRK8yIcEP0xy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 18, 2013 at 06:15:56PM +0900, Kohji Okuno wrote: > Hi, >=20 > This is newer document. >=20 > http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#= tag_15_09_05_02 >=20 > > Hi, > >=20 > > I have a question. > >=20 > > Are pthread_setcancelstate() and pthread_setcanceltype() cancellation > > points? > >=20 > > I refered to the following URL. > >=20 > > http://pubs.opengroup.org/onlinepubs/7908799/xsh/threads.html > >=20 > > This document shows that cancellation points in the pthread library > > are only pthread_cond_timedwait(), pthread_cond_wait(), pthread_join() > > and pthread_testcancel(). > >=20 > > But, current implementation in FreeBSD is the following. > > (Please take notice of "(*)" marks). > >=20 > > 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 --- a/lib/libthr/thread/thr_cancel.c +++ b/lib/libthr/thread/thr_cancel.c @@ -87,7 +87,8 @@ _pthread_setcancelstate(int state, int *oldstate) break; case PTHREAD_CANCEL_ENABLE: curthread->cancel_enable =3D 1; - testcancel(curthread); + if (curthread->cancel_async) + testcancel(curthread); break; default: return (EINVAL); --Pe/WPRK8yIcEP0xy Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (FreeBSD) iQIcBAEBAgAGBQJRwG/zAAoJEJDCuSvBvK1BP6QP/1etba3gnVLst9yoh4stg0Ls IN8vyjYi1TFjeVL8h77o28RipH481sDt9p3Nqcy8AOg7DRAhUZXcR3ms33bfiuUF xz8ZP+0qYXynX1PJZ1LF1fvcBcZY4EWEIp0J57zuoCfd87p8AKK8xGsMVrC3wVDU 2z7+zehF9zpnWZuZrBwj6f5y48mo1gMvm1H1jthoxTWmckUqnyb4Ys/X+HInHfSX 6aKdzs3SV3fXcYzQjKVoTL4KEs0QL7/FjyPHjVHGp+BvQeAHR2Xw51I64TtYf3Gz axENhEtSg3DnK6SVzn+zwVBF2QZxUfuUylDjE0wbixEQlsUSy5M1f4aaL2DLNinv 3VOT2WIHoFmXk24YHs+2P7ATV0WRBaJYkl7kWaXF2DjFF8Qy8pX0A2ZR3OUfwKuy hN5xGRSDgqk9w2L9Ug/MjLDPIP4zj4Ff1giySu2MvQ1GNfKa8mViVTO/2097qpA8 P7RP8GGTPMI5vUe5JOXfWbYenvMigwlFyaHphiDQwWK5sWfAvFg4s5fmD6s0kUen cHJknczaaSZ0uh6AFMjgvu7LlKNvYN4PndftB1D1/q06cFQkFHStIIchRe6SYo0M 5VAFglLFnN9KHTO9R4Tc8ljIpEUzc5Wbncwkn+ARnpzv24jA+RTLra7OUjAMH7CE lTSSZ7iSw8mKQV3pf+9G =53PI -----END PGP SIGNATURE----- --Pe/WPRK8yIcEP0xy--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130618143428.GV91021>