summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2003-06-28 09:39:35 +0000
committerdavidxu <davidxu@FreeBSD.org>2003-06-28 09:39:35 +0000
commitcec78b1ad335596a8e70ad8c0d3b619749a57656 (patch)
tree3556df33f6e22515a4326c7736a5ed85e5c3aa05
parent96d5411913b53996217bc5657defd02e8efc2005 (diff)
downloadFreeBSD-src-cec78b1ad335596a8e70ad8c0d3b619749a57656.zip
FreeBSD-src-cec78b1ad335596a8e70ad8c0d3b619749a57656.tar.gz
if thread is exiting, just returns. kse_thr_interrupt interface
was changed, it needs signal parameter, pass -1 to it, it indicates to interrupt syscall. Reviewed by: deischen
-rw-r--r--lib/libkse/thread/thr_cancel.c8
-rw-r--r--lib/libpthread/thread/thr_cancel.c8
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/libkse/thread/thr_cancel.c b/lib/libkse/thread/thr_cancel.c
index 064e422..57cefa2 100644
--- a/lib/libkse/thread/thr_cancel.c
+++ b/lib/libkse/thread/thr_cancel.c
@@ -27,7 +27,11 @@ _pthread_cancel(pthread_t pthread)
* Take the scheduling lock while we change the cancel flags.
*/
THR_SCHED_LOCK(curthread, pthread);
-
+ if (pthread->flags & THR_FLAGS_EXITING) {
+ THR_SCHED_UNLOCK(curthread, pthread);
+ _thr_ref_delete(curthread, pthread);
+ return (ESRCH);
+ }
if (((pthread->cancelflags & PTHREAD_CANCEL_DISABLE) != 0) ||
(((pthread->cancelflags & THR_AT_CANCEL_POINT) == 0) &&
((pthread->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS) == 0)))
@@ -105,7 +109,7 @@ _pthread_cancel(pthread_t pthread)
}
if ((pthread->blocked != 0) &&
((pthread->cancelflags & THR_AT_CANCEL_POINT) != 0))
- kse_thr_interrupt(&pthread->tmbx);
+ kse_thr_interrupt(&pthread->tmbx, -1);
}
/*
diff --git a/lib/libpthread/thread/thr_cancel.c b/lib/libpthread/thread/thr_cancel.c
index 064e422..57cefa2 100644
--- a/lib/libpthread/thread/thr_cancel.c
+++ b/lib/libpthread/thread/thr_cancel.c
@@ -27,7 +27,11 @@ _pthread_cancel(pthread_t pthread)
* Take the scheduling lock while we change the cancel flags.
*/
THR_SCHED_LOCK(curthread, pthread);
-
+ if (pthread->flags & THR_FLAGS_EXITING) {
+ THR_SCHED_UNLOCK(curthread, pthread);
+ _thr_ref_delete(curthread, pthread);
+ return (ESRCH);
+ }
if (((pthread->cancelflags & PTHREAD_CANCEL_DISABLE) != 0) ||
(((pthread->cancelflags & THR_AT_CANCEL_POINT) == 0) &&
((pthread->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS) == 0)))
@@ -105,7 +109,7 @@ _pthread_cancel(pthread_t pthread)
}
if ((pthread->blocked != 0) &&
((pthread->cancelflags & THR_AT_CANCEL_POINT) != 0))
- kse_thr_interrupt(&pthread->tmbx);
+ kse_thr_interrupt(&pthread->tmbx, -1);
}
/*
OpenPOWER on IntegriCloud