summaryrefslogtreecommitdiff
path: root/malloc/thread-freeres.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2018-06-26 15:13:54 +0200
committerFlorian Weimer <fweimer@redhat.com>2018-06-26 15:27:12 +0200
commit124e025864bb39732c71fc60c1443d5680881a0a (patch)
tree2af69c84acc461764f9b8873089b3277b22725c0 /malloc/thread-freeres.c
parent935d920e763626dbcbbf655117285d1d270791a1 (diff)
Run thread shutdown functions in an explicit order
This removes the __libc_thread_subfreeres hook in favor of explict calls. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'malloc/thread-freeres.c')
-rw-r--r--malloc/thread-freeres.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/malloc/thread-freeres.c b/malloc/thread-freeres.c
index 53ce41bb78..8902c845bc 100644
--- a/malloc/thread-freeres.c
+++ b/malloc/thread-freeres.c
@@ -16,16 +16,24 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <stdlib.h>
#include <libc-internal.h>
-#include <set-hooks.h>
+#include <malloc-internal.h>
+#include <resolv/resolv-internal.h>
+#include <rpc/rpc.h>
+#include <string.h>
-#ifdef _LIBC_REENTRANT
-DEFINE_HOOK (__libc_thread_subfreeres, (void));
-
-void __attribute__ ((section ("__libc_thread_freeres_fn")))
+/* Thread shutdown function. Note that this function must be called
+ for threads during shutdown for correctness reasons. Unlike
+ __libc_subfreeres, skipping calls to it is not a valid
+ optimization. */
+void
__libc_thread_freeres (void)
{
- RUN_HOOK (__libc_thread_subfreeres, ());
+ call_function_static_weak (__rpc_thread_destroy);
+ call_function_static_weak (__res_thread_freeres);
+ call_function_static_weak (__strerror_thread_freeres);
+
+ /* This should come last because it shuts down malloc for this
+ thread and the other shutdown functions might well call free. */
+ call_function_static_weak (__malloc_arena_thread_freeres);
}
-#endif