mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
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>
This commit is contained in:
@ -941,8 +941,8 @@ arena_get_retry (mstate ar_ptr, size_t bytes)
|
||||
return ar_ptr;
|
||||
}
|
||||
|
||||
static void __attribute__ ((section ("__libc_thread_freeres_fn")))
|
||||
arena_thread_freeres (void)
|
||||
void
|
||||
__malloc_arena_thread_freeres (void)
|
||||
{
|
||||
/* Shut down the thread cache first. This could deallocate data for
|
||||
the thread arena, so do this before we put the arena on the free
|
||||
@ -966,7 +966,6 @@ arena_thread_freeres (void)
|
||||
__libc_lock_unlock (free_list_lock);
|
||||
}
|
||||
}
|
||||
text_set_element (__libc_thread_subfreeres, arena_thread_freeres);
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
|
@ -71,6 +71,9 @@ void __malloc_fork_unlock_parent (void) attribute_hidden;
|
||||
/* Called in the child process after a fork. */
|
||||
void __malloc_fork_unlock_child (void) attribute_hidden;
|
||||
|
||||
/* Called as part of the thread shutdown sequence. */
|
||||
void __malloc_arena_thread_freeres (void) attribute_hidden;
|
||||
|
||||
/* Set *RESULT to LEFT * RIGHT. Return true if the multiplication
|
||||
overflowed. */
|
||||
static inline bool
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user