summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrpj <rpj>1998-07-31 02:16:34 +0000
committerrpj <rpj>1998-07-31 02:16:34 +0000
commitcc1a70f50a246ad33ecbc8f73d0bbc67ea89f1a7 (patch)
treec5126bec2ab25c271ce68abd52542e6a7ad2e6ae
parent0bc99fb6243a64c6f9a4d503382e9125adeb85a0 (diff)
Fri Jul 31 00:05:45 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* tsd.c (pthread_key_create): Update to properly associate the destructor routine with the key. * exit.c (_pthread_vacuum): Add call to _pthread_destructor_pop_all().
-rw-r--r--ChangeLog6
-rw-r--r--exit.c4
-rw-r--r--tsd.c14
3 files changed, 13 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 5e97b1c..34eabe4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
Fri Jul 31 00:05:45 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
+ * tsd.c (pthread_key_create): Update to properly associate
+ the destructor routine with the key.
+
+ * exit.c (_pthread_vacuum): Add call to
+ _pthread_destructor_pop_all().
+
* implement.h (_pthread_handler_pop_all): Add prototype.
(_pthread_destructor_pop_all): Ditto.
diff --git a/exit.c b/exit.c
index 93d8a0b..c66c9d4 100644
--- a/exit.c
+++ b/exit.c
@@ -16,8 +16,8 @@ _pthread_vacuum(void)
_pthread_handler_pop_all(_PTHREAD_CLEANUP_STACK,
_PTHREAD_HANDLER_EXECUTE);
- _pthread_handler_pop_all(_PTHREAD_DESTRUCTOR_STACK,
- _PTHREAD_HANDLER_EXECUTE);
+ /* Run all TSD key destructors. */
+ _pthread_destructor_pop_all();
/* Pop any atfork handlers without executing them. */
_pthread_handler_pop_all(_PTHREAD_FORKPREPARE_STACK,
diff --git a/tsd.c b/tsd.c
index 611ed5f..4a83fd9 100644
--- a/tsd.c
+++ b/tsd.c
@@ -12,15 +12,6 @@ pthread_key_create(pthread_key_t *key, void (*destructor)(void *))
{
DWORD index;
- /* FIXME: the destructor function is ignored for now. This needs to
- be managed via the same cleanup handler mechanism as user-define
- cleanup handlers during a thread exit. */
-
- if (destructor != NULL)
- {
- return EINVAL;
- }
-
index = TlsAlloc();
if (index == 0xFFFFFFFF)
{
@@ -30,6 +21,11 @@ pthread_key_create(pthread_key_t *key, void (*destructor)(void *))
/* Only modify the `key' parameter if allocation was successful. */
*key = index;
+ if (destructor != NULL)
+ {
+ return (_pthread_destructor_push(destructor, *key));
+ }
+
return 0;
}