When cancelling a thread while in a join operation, do not detach

the target thread of the join operation.  This allows the cancelled
thread to detach the target thread in its cancellation handler.
This bug was found by Butenhof's cancel_subcontract test.

Reviewed by:	jasone
This commit is contained in:
Daniel Eischen 2001-12-16 13:26:44 +00:00
parent b4db911dc6
commit 320bfcf3f1
3 changed files with 3 additions and 12 deletions

View file

@ -65,14 +65,11 @@ _pthread_cancel(pthread_t pthread)
case PS_JOIN:
/*
* Disconnect the thread from the joinee and
* detach:
* Disconnect the thread from the joinee:
*/
if (pthread->join_status.thread != NULL) {
pthread->join_status.thread->joiner
= NULL;
pthread_detach((pthread_t)
pthread->join_status.thread);
}
pthread->cancelflags |= PTHREAD_CANCELLING;
PTHREAD_NEW_STATE(pthread, PS_RUNNING);

View file

@ -65,14 +65,11 @@ _pthread_cancel(pthread_t pthread)
case PS_JOIN:
/*
* Disconnect the thread from the joinee and
* detach:
* Disconnect the thread from the joinee:
*/
if (pthread->join_status.thread != NULL) {
pthread->join_status.thread->joiner
= NULL;
pthread_detach((pthread_t)
pthread->join_status.thread);
}
pthread->cancelflags |= PTHREAD_CANCELLING;
PTHREAD_NEW_STATE(pthread, PS_RUNNING);

View file

@ -65,14 +65,11 @@ _pthread_cancel(pthread_t pthread)
case PS_JOIN:
/*
* Disconnect the thread from the joinee and
* detach:
* Disconnect the thread from the joinee:
*/
if (pthread->join_status.thread != NULL) {
pthread->join_status.thread->joiner
= NULL;
pthread_detach((pthread_t)
pthread->join_status.thread);
}
pthread->cancelflags |= PTHREAD_CANCELLING;
PTHREAD_NEW_STATE(pthread, PS_RUNNING);