From 73809519e368dcfe41ad403fec70ac73534ee3f1 Mon Sep 17 00:00:00 2001 From: rpj Date: Fri, 31 Jul 1998 05:27:17 +0000 Subject: Fri Jul 31 14:00:29 1998 Ross Johnson * 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(). --- cleanup.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'cleanup.c') 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() { -- cgit v1.2.3