diff options
Diffstat (limited to 'elf/dl-open.c')
-rw-r--r-- | elf/dl-open.c | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/elf/dl-open.c b/elf/dl-open.c index 2000f580c3..fda3219ae2 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -165,6 +165,40 @@ add_to_global (struct link_map *new) return 0; } +int +_dl_scope_free (struct r_scope_elem **old) +{ + struct dl_scope_free_list *fsl; +#define DL_SCOPE_FREE_LIST_SIZE (sizeof (fsl->list) / sizeof (fsl->list[0])) + + if (RTLD_SINGLE_THREAD_P) + free (old); + else if ((fsl = GL(dl_scope_free_list)) == NULL) + { + GL(dl_scope_free_list) = fsl = malloc (sizeof (*fsl)); + if (fsl == NULL) + { + THREAD_GSCOPE_WAIT (); + free (old); + return 1; + } + else + { + fsl->list[0] = old; + fsl->count = 1; + } + } + else if (fsl->count < DL_SCOPE_FREE_LIST_SIZE) + fsl->list[fsl->count++] = old; + else + { + THREAD_GSCOPE_WAIT (); + while (fsl->count > 0) + free (fsl->list[--fsl->count]); + return 1; + } + return 0; +} static void dl_open_worker (void *a) @@ -429,17 +463,10 @@ dl_open_worker (void *a) memcpy (newp, imap->l_scope, cnt * sizeof (imap->l_scope[0])); struct r_scope_elem **old = imap->l_scope; - if (RTLD_SINGLE_THREAD_P) - imap->l_scope = newp; - else - { - __rtld_mrlock_change (imap->l_scope_lock); - imap->l_scope = newp; - __rtld_mrlock_done (imap->l_scope_lock); - } + imap->l_scope = newp; if (old != imap->l_scope_mem) - free (old); + _dl_scope_free (old); imap->l_scope_max = new_size; } |