summaryrefslogtreecommitdiff
path: root/ptw32_tkAssocDestroy.c
diff options
context:
space:
mode:
authorrpj <rpj>2005-05-06 07:31:28 +0000
committerrpj <rpj>2005-05-06 07:31:28 +0000
commit78f83cfa240ec14874b22c7302ff8d306c130aaf (patch)
treebf29a117aecb99e9ecb2d30bad398d8b20392b49 /ptw32_tkAssocDestroy.c
parente3845d9b6b0a18ffdfdf0cefd811a17fce62f1ac (diff)
''
Diffstat (limited to 'ptw32_tkAssocDestroy.c')
-rw-r--r--ptw32_tkAssocDestroy.c41
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);
}