diff options
author | rpj <rpj> | 2005-05-08 16:55:02 +0000 |
---|---|---|
committer | rpj <rpj> | 2005-05-08 16:55:02 +0000 |
commit | ac8e3d247fa03af61b5411f92508481e7c3f49f8 (patch) | |
tree | f5d9c2a8bc58a2e6135e8aa2b207daab23de14a7 /ptw32_tkAssocDestroy.c | |
parent | 7523c7c4d75652f67cd31cb123e1268790394c8b (diff) |
''
Diffstat (limited to 'ptw32_tkAssocDestroy.c')
-rw-r--r-- | ptw32_tkAssocDestroy.c | 24 |
1 files changed, 17 insertions, 7 deletions
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); |