diff options
| author | David Xu <davidxu@FreeBSD.org> | 2003-07-07 04:28:23 +0000 |
|---|---|---|
| committer | David Xu <davidxu@FreeBSD.org> | 2003-07-07 04:28:23 +0000 |
| commit | 91f7616affad4527d0f1b0f39c5b330d3cda68e2 (patch) | |
| tree | 6539674ba4c0ff3018faf64006ac81eb9090ec5f /lib/libpthread/thread/thr_cancel.c | |
| parent | dce6e6518b85561495cff38a3074a69d29d58a55 (diff) | |
Notes
Diffstat (limited to 'lib/libpthread/thread/thr_cancel.c')
| -rw-r--r-- | lib/libpthread/thread/thr_cancel.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/libpthread/thread/thr_cancel.c b/lib/libpthread/thread/thr_cancel.c index 085f34943a0a..905891c8c252 100644 --- a/lib/libpthread/thread/thr_cancel.c +++ b/lib/libpthread/thread/thr_cancel.c @@ -146,16 +146,12 @@ _pthread_setcancelstate(int state, int *oldstate) switch (state) { case PTHREAD_CANCEL_ENABLE: - if (oldstate != NULL) - *oldstate = ostate; curthread->cancelflags &= ~PTHREAD_CANCEL_DISABLE; if ((curthread->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS) != 0) need_exit = checkcancel(curthread); ret = 0; break; case PTHREAD_CANCEL_DISABLE: - if (oldstate != NULL) - *oldstate = ostate; curthread->cancelflags |= PTHREAD_CANCEL_DISABLE; ret = 0; break; @@ -169,6 +165,9 @@ _pthread_setcancelstate(int state, int *oldstate) pthread_exit(PTHREAD_CANCELED); PANIC("cancel"); } + if (ret == 0 && oldstate != NULL) + *oldstate = ostate; + return (ret); } @@ -186,15 +185,11 @@ _pthread_setcanceltype(int type, int *oldtype) otype = curthread->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS; switch (type) { case PTHREAD_CANCEL_ASYNCHRONOUS: - if (oldtype != NULL) - *oldtype = otype; curthread->cancelflags |= PTHREAD_CANCEL_ASYNCHRONOUS; need_exit = checkcancel(curthread); ret = 0; break; case PTHREAD_CANCEL_DEFERRED: - if (oldtype != NULL) - *oldtype = otype; curthread->cancelflags &= ~PTHREAD_CANCEL_ASYNCHRONOUS; ret = 0; break; @@ -208,6 +203,9 @@ _pthread_setcanceltype(int type, int *oldtype) pthread_exit(PTHREAD_CANCELED); PANIC("cancel"); } + if (ret == 0 && oldtype != NULL) + *oldtype = otype; + return (ret); } |
