diff options
author | rpj <rpj> | 2005-05-06 07:27:10 +0000 |
---|---|---|
committer | rpj <rpj> | 2005-05-06 07:27:10 +0000 |
commit | 7523c7c4d75652f67cd31cb123e1268790394c8b (patch) | |
tree | 0920ebf089ccb971e0878542f85486171a541a8a /ptw32_tkAssocDestroy.c | |
parent | cf42850c77554311e62d3780f6a36cbc38e5e002 (diff) |
''
Diffstat (limited to 'ptw32_tkAssocDestroy.c')
-rw-r--r-- | ptw32_tkAssocDestroy.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/ptw32_tkAssocDestroy.c b/ptw32_tkAssocDestroy.c index d80cd3f..f529e3c 100644 --- a/ptw32_tkAssocDestroy.c +++ b/ptw32_tkAssocDestroy.c @@ -56,10 +56,47 @@ ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc) */ { - if ((assoc != NULL) && (assoc->key == NULL && assoc->thread.p == NULL)) + /* + * Both key->keyLock and thread->threadLock are locked on + * entry to this routine. + */ + if (assoc != NULL) { + ThreadKeyAssoc * prev, * next; - pthread_mutex_destroy (&(assoc->lock)); + prev = assoc->prevKey; + next = assoc->nextKey; + if (prev != NULL) + { + prev->nextKey = next; + } + if (next != NULL) + { + next->prevKey = prev; + } + + if (assoc->key->threads == assoc) + { + /* We're at the head of the threads chain */ + assoc->key->threads = next; + } + + prev = assoc->prevThread; + next = assoc->nextThread; + if (prev != NULL) + { + prev->nextThread = next; + } + if (next != NULL) + { + next->prevThread = prev; + } + + if (assoc->thread->keys == assoc) + { + /* We're at the head of the keys chain */ + assoc->thread->keys = next; + } free (assoc); } |