thr_cancel.c (212312) | thr_cancel.c (212536) |
---|---|
1/* 2 * Copyright (c) 2005, David Xu <davidxu@freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * | 1/* 2 * Copyright (c) 2005, David Xu <davidxu@freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/lib/libthr/thread/thr_cancel.c 212312 2010-09-08 02:18:20Z davidxu $ | 26 * $FreeBSD: head/lib/libthr/thread/thr_cancel.c 212536 2010-09-13 07:03:01Z davidxu $ |
27 * 28 */ 29 30#include "namespace.h" 31#include <pthread.h> 32#include "un-namespace.h" 33 34#include "thr_private.h" --- 20 unchanged lines hidden (view full) --- 55int 56_pthread_cancel(pthread_t pthread) 57{ 58 struct pthread *curthread = _get_curthread(); 59 int ret; 60 61 /* 62 * POSIX says _pthread_cancel should be async cancellation safe. | 27 * 28 */ 29 30#include "namespace.h" 31#include <pthread.h> 32#include "un-namespace.h" 33 34#include "thr_private.h" --- 20 unchanged lines hidden (view full) --- 55int 56_pthread_cancel(pthread_t pthread) 57{ 58 struct pthread *curthread = _get_curthread(); 59 int ret; 60 61 /* 62 * POSIX says _pthread_cancel should be async cancellation safe. |
63 * _thr_ref_add and _thr_ref_delete will enter and leave critical | 63 * _thr_find_thread and THR_THREAD_UNLOCK will enter and leave critical |
64 * region automatically. 65 */ | 64 * region automatically. 65 */ |
66 if ((ret = _thr_ref_add(curthread, pthread, 0)) == 0) { 67 THR_THREAD_LOCK(curthread, pthread); | 66 if ((ret = _thr_find_thread(curthread, pthread, 0)) == 0) { |
68 if (!pthread->cancel_pending) { 69 pthread->cancel_pending = 1; 70 if (pthread->state != PS_DEAD) 71 _thr_send_sig(pthread, SIGCANCEL); 72 } 73 THR_THREAD_UNLOCK(curthread, pthread); | 67 if (!pthread->cancel_pending) { 68 pthread->cancel_pending = 1; 69 if (pthread->state != PS_DEAD) 70 _thr_send_sig(pthread, SIGCANCEL); 71 } 72 THR_THREAD_UNLOCK(curthread, pthread); |
74 _thr_ref_delete(curthread, pthread); | |
75 } 76 return (ret); 77} 78 79int 80_pthread_setcancelstate(int state, int *oldstate) 81{ 82 struct pthread *curthread = _get_curthread(); --- 85 unchanged lines hidden --- | 73 } 74 return (ret); 75} 76 77int 78_pthread_setcancelstate(int state, int *oldstate) 79{ 80 struct pthread *curthread = _get_curthread(); --- 85 unchanged lines hidden --- |