Deleted Added
full compact
26c26
< * $FreeBSD: head/lib/libthr/thread/thr_sig.c 209933 2010-07-12 10:15:33Z kib $
---
> * $FreeBSD: head/lib/libthr/thread/thr_sig.c 211524 2010-08-20 05:15:39Z davidxu $
70,71d69
< if (curthread->cancel_defer && curthread->cancel_pending)
< thr_wake(curthread->tid);
80,85c78,115
< if (!THR_IN_CRITICAL(curthread)) {
< _thr_testcancel(curthread);
< if (__predict_false((curthread->flags &
< (THR_FLAGS_NEED_SUSPEND | THR_FLAGS_SUSPENDED))
< == THR_FLAGS_NEED_SUSPEND))
< _thr_suspend_check(curthread);
---
>
> if (THR_IN_CRITICAL(curthread))
> return;
>
> if (curthread->cancel_pending && curthread->cancel_enable
> && !curthread->cancelling) {
> if (curthread->cancel_async) {
> /*
> * asynchronous cancellation mode, act upon
> * immediately.
> */
> _pthread_exit(PTHREAD_CANCELED);
> } else {
> /*
> * Otherwise, we are in defer mode, and we are at
> * cancel point, tell kernel to not block the current
> * thread on next cancelable system call.
> *
> * There are two cases we should call thr_wake() to
> * turn on TDP_WAKEUP in kernel:
> * 1) we are going to call a cancelable system call,
> * non-zero cancel_point means we are already in
> * cancelable state, next system call is cancelable.
> * 2) because _thr_ast() may be called by
> * THR_CRITICAL_LEAVE() which is used by rtld rwlock
> * and any libthr internal locks, when rtld rwlock
> * is used, it is mostly caused my an unresolved PLT.
> * those routines may clear the TDP_WAKEUP flag by
> * invoking some system calls, in those cases, we
> * also should reenable the flag.
> */
> if (curthread->cancel_point) {
> if (curthread->cancel_defer)
> thr_wake(curthread->tid);
> else
> _pthread_exit(PTHREAD_CANCELED);
> }
> }
86a117,121
>
> if (__predict_false((curthread->flags &
> (THR_FLAGS_NEED_SUSPEND | THR_FLAGS_SUSPENDED))
> == THR_FLAGS_NEED_SUSPEND))
> _thr_suspend_check(curthread);
298a334,338
> /*
> * Cancellation behavior:
> * Thread may be canceled at start, if thread got signal,
> * it is not canceled.
> */
314c354
< _thr_cancel_enter(curthread);
---
> _thr_cancel_enter_defer(curthread, 1);
316c356
< _thr_cancel_leave(curthread);
---
> _thr_cancel_leave_defer(curthread, (ret == -1));
337a378,382
> /*
> * Cancellation behavior:
> * Thread may be canceled at start, if thread got signal,
> * it is not canceled.
> */
353c398
< _thr_cancel_enter(curthread);
---
> _thr_cancel_enter_defer(curthread, 1);
355c400
< _thr_cancel_leave(curthread);
---
> _thr_cancel_leave_defer(curthread, ret == -1);
376a422,426
> /*
> * Cancellation behavior:
> * Thread may be canceled at start, if thread got signal,
> * it is not canceled.
> */
392c442
< _thr_cancel_enter(curthread);
---
> _thr_cancel_enter_defer(curthread, 1);
394c444
< _thr_cancel_leave(curthread);
---
> _thr_cancel_leave_defer(curthread, (ret != 0));