summaryrefslogtreecommitdiff
path: root/cleanup.c
diff options
context:
space:
mode:
authorrpj <rpj>1998-07-31 05:27:17 +0000
committerrpj <rpj>1998-07-31 05:27:17 +0000
commit73809519e368dcfe41ad403fec70ac73534ee3f1 (patch)
treec04ce409576d6fafa5e7ccf67d67538a4d7523b0 /cleanup.c
parentb164b0f0bff12369fa19118f7b87c18d7871095f (diff)
Fri Jul 31 14:00:29 1998 Ross Johnson <rpj@swan.canberra.edu.au>
* cleanup.c (_pthread_destructor_pop): Implement. Removes destructors associated with a key without executing them. (_pthread_destructor_pop_all): Add FIXME comment. * tsd.c (pthread_key_delete): Add call to _pthread_destructor_pop().
Diffstat (limited to 'cleanup.c')
-rw-r--r--cleanup.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/cleanup.c b/cleanup.c
index d869ee3..d0daaf1 100644
--- a/cleanup.c
+++ b/cleanup.c
@@ -117,6 +117,7 @@ _pthread_handler_pop_all(int stack, int execute)
}
}
+
int
_pthread_destructor_push(void (* routine)(void *), pthread_key_t key)
{
@@ -126,6 +127,48 @@ _pthread_destructor_push(void (* routine)(void *), pthread_key_t key)
key);
}
+
+/* Remove all of the destructors associated with the key. */
+void
+_pthread_destructor_pop(pthread_key_t key)
+{
+ _pthread_handler_node_t ** head;
+ _pthread_handler_node_t * current;
+ _pthread_handler_node_t * next;
+
+ head = _PTHREAD_STACK(_PTHREAD_DESTRUCTOR_STACK);
+ current = *head;
+
+ while (current != NULL)
+ {
+ next = current->next;
+
+ /* The destructors associated key is in current->arg. */
+ if (current->arg == key)
+ {
+ if (current == *head)
+ {
+ *head = next;
+ }
+ free(current);
+ }
+ current = next;
+ }
+}
+
+
+/* Run destructors for all non-NULL key values.
+
+ FIXME: Currently we only run the destructors on the calling
+ thread's key values. The way I interpret POSIX semantics is that,
+ for each key that the calling thread has a destructor for, we need
+ to look at the key values of every thread and run the destructor on
+ it if the key value is non-NULL.
+
+ The question is: how do we access the key associated values which
+ are private to other threads?
+
+ */
void
_pthread_destructor_pop_all()
{