From 7395b1431d5e2160682de273b46252c747ccbf36 Mon Sep 17 00:00:00 2001 From: rpj Date: Sun, 8 May 2005 16:52:50 +0000 Subject: '' --- ptw32_tkAssocDestroy.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'ptw32_tkAssocDestroy.c') diff --git a/ptw32_tkAssocDestroy.c b/ptw32_tkAssocDestroy.c index f529e3c..a7842ea 100644 --- a/ptw32_tkAssocDestroy.c +++ b/ptw32_tkAssocDestroy.c @@ -45,7 +45,7 @@ ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc) * ------------------------------------------------------------------- * This routine releases all resources for the given ThreadKeyAssoc * once it is no longer being referenced - * ie) both the key and thread have stopped referencing it. + * ie) either the key or thread has stopped referencing it. * * Parameters: * assoc @@ -64,6 +64,7 @@ ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc) { ThreadKeyAssoc * prev, * next; + /* Remove assoc from thread's keys chain */ prev = assoc->prevKey; next = assoc->nextKey; if (prev != NULL) @@ -75,12 +76,21 @@ ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc) next->prevKey = prev; } - if (assoc->key->threads == assoc) + if (assoc->thread->keys == assoc) { - /* We're at the head of the threads chain */ - assoc->key->threads = next; + /* We're at the head of the thread's keys chain */ + assoc->thread->keys = next; + } + if (assoc->thread->nextAssoc == assoc) + { + /* + * Thread is exiting and we're deleting the assoc to be processed next. + * Hand thread the assoc after this one. + */ + assoc->thread->nextAssoc = next; } + /* Remove assoc from key's threads chain */ prev = assoc->prevThread; next = assoc->nextThread; if (prev != NULL) @@ -92,10 +102,10 @@ ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc) next->prevThread = prev; } - if (assoc->thread->keys == assoc) + if (assoc->key->threads == assoc) { - /* We're at the head of the keys chain */ - assoc->thread->keys = next; + /* We're at the head of the key's threads chain */ + assoc->key->threads = next; } free (assoc); -- cgit v1.2.3