summaryrefslogtreecommitdiff
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
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().
-rw-r--r--ChangeLog8
-rw-r--r--cleanup.c43
-rw-r--r--tsd.c3
3 files changed, 53 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 3e7956e..e92e60a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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().
+
Fri Jul 31 00:05:45 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* tsd.c (pthread_key_create): Update to properly associate
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()
{
diff --git a/tsd.c b/tsd.c
index e573d3d..d1d2deb 100644
--- a/tsd.c
+++ b/tsd.c
@@ -44,7 +44,8 @@ pthread_getspecific(pthread_key_t key)
int
pthread_key_delete(pthread_key_t key)
{
- /* FIXME: We must remove any associated destructors here. */
+ /* Remove this key's destructors. */
+ _pthread_destructor_pop(key);
return (TlsFree(key) == FALSE) ? EINVAL : 0;
}