Date: Sun, 16 Jan 2005 00:56:51 GMT From: David Xu <davidxu@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 69095 for review Message-ID: <200501160056.j0G0upZc014495@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=69095 Change 69095 by davidxu@davidxu_tiger on 2005/01/16 00:56:47 Make pthread_cancel async cancellation safe. Affected files ... .. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_cancel.c#7 edit Differences ... ==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_cancel.c#7 (text+ko) ==== @@ -35,15 +35,25 @@ __weak_reference(_pthread_setcanceltype, pthread_setcanceltype); __weak_reference(_pthread_testcancel, pthread_testcancel); +int _pthread_setcanceltype(int type, int *oldtype); + int _pthread_cancel(pthread_t pthread) { struct pthread *curthread = _get_curthread(); int oldval, newval = 0; + int oldtype; int ret; - if ((ret = _thr_ref_add(curthread, pthread, 0)) != 0) + /* + * POSIX says _pthread_cancel should be async cancellation safe, + * so we temporarily disable async cancellation. + */ + _pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype); + if ((ret = _thr_ref_add(curthread, pthread, 0)) != 0) { + _pthread_setcanceltype(oldtype, NULL); return (ret); + } do { oldval = pthread->cancelflags; @@ -56,6 +66,7 @@ thr_kill(pthread->tid, SIGCANCEL); _thr_ref_delete(curthread, pthread); + _pthread_setcanceltype(oldtype, NULL); return (0); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200501160056.j0G0upZc014495>