thr_cancel.c (76909) | thr_cancel.c (81750) |
---|---|
1/* 2 * David Leonard <d@openbsd.org>, 1999. Public domain. | 1/* 2 * David Leonard <d@openbsd.org>, 1999. Public domain. |
3 * $FreeBSD: head/lib/libkse/thread/thr_cancel.c 76909 2001-05-20 23:08:33Z jasone $ | 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: | 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 |
|
67 case PS_SUSPENDED: 68 if (pthread->suspended == SUSP_NO || 69 pthread->suspended == SUSP_YES || | 80 case PS_SUSPENDED: 81 if (pthread->suspended == SUSP_NO || 82 pthread->suspended == SUSP_YES || |
83 pthread->suspended == SUSP_JOIN || |
|
70 pthread->suspended == SUSP_NOWAIT) { 71 /* 72 * This thread isn't in any scheduling 73 * queues; just change it's state: 74 */ 75 pthread->cancelflags |= 76 PTHREAD_CANCELLING; 77 PTHREAD_SET_STATE(pthread, PS_RUNNING); --- 106 unchanged lines hidden (view full) --- 184 ((curthread->cancelflags & PTHREAD_CANCELLING) != 0)) { 185 /* 186 * It is possible for this thread to be swapped out 187 * while performing cancellation; do not allow it 188 * to be cancelled again. 189 */ 190 curthread->cancelflags &= ~PTHREAD_CANCELLING; 191 _thread_exit_cleanup(); | 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(); |
192 pthread_detach((pthread_t)curthread); | |
193 pthread_exit(PTHREAD_CANCELED); 194 PANIC("cancel"); 195 } 196} 197 198void 199_thread_enter_cancellation_point(void) 200{ --- 20 unchanged lines hidden (view full) --- 221 struct pthread *curthread = _get_curthread(); 222 223 curthread->continuation = NULL; 224 curthread->interrupted = 0; 225 226 if ((curthread->cancelflags & PTHREAD_CANCEL_NEEDED) != 0) { 227 curthread->cancelflags &= ~PTHREAD_CANCEL_NEEDED; 228 _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(); |
229 pthread_detach((pthread_t)curthread); | |
230 pthread_exit(PTHREAD_CANCELED); 231 } 232} | 242 pthread_exit(PTHREAD_CANCELED); 243 } 244} |