Fix pthread cleanup logic
Don't delete the key in the pthread_key_create destructor. The key isn't specific to instances of values.
diff --git a/src/core/lib/support/cpu_posix.cc b/src/core/lib/support/cpu_posix.cc
index c9dbc0d..bca14a0 100644
--- a/src/core/lib/support/cpu_posix.cc
+++ b/src/core/lib/support/cpu_posix.cc
@@ -49,15 +49,14 @@
return (unsigned)ncpus;
}
-static void delete_thread_id_key(void* value) {
+static void delete_thread_id(void* value) {
if (value) {
gpr_free(value);
}
- pthread_key_delete(thread_id_key);
}
static void init_thread_id_key(void) {
- pthread_key_create(&thread_id_key, delete_thread_id_key);
+ pthread_key_create(&thread_id_key, delete_thread_id);
}
unsigned gpr_cpu_current_cpu(void) {