diff options
author | Ulrich Drepper <drepper@redhat.com> | 1998-05-04 13:19:20 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1998-05-04 13:19:20 +0000 |
commit | eb4063467c4ef625c1687b4c158bacf475821363 (patch) | |
tree | 9f47ace87d060f54a05b1315b741acb8ae3f5728 /malloc/malloc.c | |
parent | 15f32e7b7912df66ff5e1d337e4f621157504058 (diff) | |
download | glibc-eb4063467c4ef625c1687b4c158bacf475821363.zip glibc-eb4063467c4ef625c1687b4c158bacf475821363.tar.gz glibc-eb4063467c4ef625c1687b4c158bacf475821363.tar.bz2 |
Update.
1998-05-04 12:40 Ulrich Drepper <drepper@cygnus.com>
* malloc/malloc.c (ptmalloc_init_all): New function. Similar to
ptmalloc_unlock_all, but re-initializes the mutexes instead.
(ptmalloc_init): Use new function in thread_at_fork call.
(thread_atfork_static): Likewise.
Suggested by Wolfram Gloger and Xavier Leroy.
Diffstat (limited to 'malloc/malloc.c')
-rw-r--r-- | malloc/malloc.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c index 3d4933c..4a65f52 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -1,5 +1,5 @@ /* Malloc implementation for multiple threads without lock contention. - Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Wolfram Gloger <wmglo@dent.med.uni-muenchen.de> and Doug Lea <dl@cs.oswego.edu>, 1996. @@ -1579,6 +1579,24 @@ ptmalloc_unlock_all __MALLOC_P((void)) (void)mutex_unlock(&list_lock); } +static void +ptmalloc_init_all __MALLOC_P((void)) +{ + arena *ar_ptr; + +#if defined _LIBC || defined MALLOC_HOOKS + tsd_setspecific(arena_key, save_arena); + __malloc_hook = save_malloc_hook; + __free_hook = save_free_hook; +#endif + for(ar_ptr = &main_arena;;) { + (void)mutex_init(&ar_ptr->mutex); + ar_ptr = ar_ptr->next; + if(ar_ptr == &main_arena) break; + } + (void)mutex_init(&list_lock); +} + /* Initialization routine. */ #if defined(_LIBC) #if 0 @@ -1617,7 +1635,7 @@ ptmalloc_init __MALLOC_P((void)) mutex_init(&list_lock); tsd_key_create(&arena_key, NULL); tsd_setspecific(arena_key, (Void_t *)&main_arena); - thread_atfork(ptmalloc_lock_all, ptmalloc_unlock_all, ptmalloc_unlock_all); + thread_atfork(ptmalloc_lock_all, ptmalloc_unlock_all, ptmalloc_init_all); #endif #if defined _LIBC || defined MALLOC_HOOKS if((s = getenv("MALLOC_TRIM_THRESHOLD_"))) @@ -1644,7 +1662,7 @@ ptmalloc_init __MALLOC_P((void)) /* There are platforms (e.g. Hurd) with a link-time hook mechanism. */ #ifdef thread_atfork_static thread_atfork_static(ptmalloc_lock_all, ptmalloc_unlock_all, \ - ptmalloc_unlock_all) + ptmalloc_init_all) #endif #if defined _LIBC || defined MALLOC_HOOKS |