1/* 2 * David Leonard <d@openbsd.org>, 1999. Public domain. |
3 * $FreeBSD: head/lib/libkse/thread/thr_cancel.c 81750 2001-08-16 06:31:32Z jasone $ |
4 */ 5#include <sys/errno.h> 6#include <pthread.h> 7#include "pthread_private.h" 8 9static void finish_cancellation(void *arg); 10 11__weak_reference(_pthread_cancel, pthread_cancel); --- 47 unchanged lines hidden (view full) --- 59 case PS_SIGWAIT: 60 /* Interrupt and resume: */ 61 pthread->interrupted = 1; 62 pthread->cancelflags |= PTHREAD_CANCELLING; 63 PTHREAD_NEW_STATE(pthread,PS_RUNNING); 64 break; 65 66 case PS_JOIN: |
67 /* 68 * Disconnect the thread from the joinee and 69 * detach: 70 */ 71 if (pthread->data.thread != NULL) { 72 pthread->data.thread->joiner = NULL; 73 pthread_detach((pthread_t) 74 pthread->data.thread); 75 } 76 pthread->cancelflags |= PTHREAD_CANCELLING; 77 PTHREAD_NEW_STATE(pthread, PS_RUNNING); 78 break; 79 |
80 case PS_SUSPENDED: 81 if (pthread->suspended == SUSP_NO || 82 pthread->suspended == SUSP_YES || |
83 pthread->suspended == SUSP_JOIN || |
84 pthread->suspended == SUSP_NOWAIT) { 85 /* 86 * This thread isn't in any scheduling 87 * queues; just change it's state: 88 */ 89 pthread->cancelflags |= 90 PTHREAD_CANCELLING; 91 PTHREAD_SET_STATE(pthread, PS_RUNNING); --- 106 unchanged lines hidden (view full) --- 198 ((curthread->cancelflags & PTHREAD_CANCELLING) != 0)) { 199 /* 200 * It is possible for this thread to be swapped out 201 * while performing cancellation; do not allow it 202 * to be cancelled again. 203 */ 204 curthread->cancelflags &= ~PTHREAD_CANCELLING; 205 _thread_exit_cleanup(); |
206 pthread_exit(PTHREAD_CANCELED); 207 PANIC("cancel"); 208 } 209} 210 211void 212_thread_enter_cancellation_point(void) 213{ --- 20 unchanged lines hidden (view full) --- 234 struct pthread *curthread = _get_curthread(); 235 236 curthread->continuation = NULL; 237 curthread->interrupted = 0; 238 239 if ((curthread->cancelflags & PTHREAD_CANCEL_NEEDED) != 0) { 240 curthread->cancelflags &= ~PTHREAD_CANCEL_NEEDED; 241 _thread_exit_cleanup(); |
242 pthread_exit(PTHREAD_CANCELED); 243 } 244} |