aboutsummaryrefslogtreecommitdiff
path: root/elf/dl-close.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-06-20 03:19:13 +0000
committerUlrich Drepper <drepper@redhat.com>2007-06-20 03:19:13 +0000
commite4eb675d0caf19581b69fd41e9fa29ecc7f22d23 (patch)
tree9e9ffe1d6e2c3a6f9f5dd93838e99cc29fbe81a3 /elf/dl-close.c
parent9be09e060fcb211d3e53fc93098f57b74df2cb67 (diff)
downloadglibc-e4eb675d0caf19581b69fd41e9fa29ecc7f22d23.tar
glibc-e4eb675d0caf19581b69fd41e9fa29ecc7f22d23.tar.gz
glibc-e4eb675d0caf19581b69fd41e9fa29ecc7f22d23.tar.bz2
glibc-e4eb675d0caf19581b69fd41e9fa29ecc7f22d23.zip
* elf/dl-close.c (free_mem): Free _dl_scope_free_list.
2007-06-13 Jakub Jelinek <jakub@redhat.com> * include/link.h: Don't include rtld-lowlevel.h. (struct link_map): Remove l_scope_lock. * sysdeps/generic/ldsodefs.h: Don't include rtld-lowlevel.h. (_dl_scope_free_list): New field (variable) in _rtld_global. (DL_LOOKUP_SCOPE_LOCK): Remove. (_dl_scope_free): New prototype. * elf/dl-runtime.c (_dl_fixup): Don't use __rtld_mrlock_*lock. Don't pass DL_LOOKUP_SCOPE_LOCK to _dl_lookup_symbol_x. (_dl_profile_fixup): Likewise. * elf/dl-sym.c (do_sym): Likewise. Use wrapped _dl_lookup_symbol_x whenever !RTLD_SINGLE_THREAD_P, use THREAD_GSCOPE_SET_FLAG and THREAD_GSCOPE_RESET_FLAG around it. * elf/dl-close.c (_dl_close_worker): Don't use __rtld_mrlock_{change,done}. Call _dl_scope_free on the old scope. Make sure THREAD_GSCOPE_WAIT () happens if any old scopes were queued or if l_scope_mem has been abandoned. * elf/dl-open.c (_dl_scope_free): New function. (dl_open_worker): Use it. Don't use __rtld_mrlock_{change,done}. * elf/dl-support.c (_dl_scope_free_list): New variable. * elf/dl-lookup.c (add_dependency): Remove flags argument. Remove DL_LOOKUP_SCOPE_LOCK handling. (_dl_lookup_symbol_x): Adjust caller. Remove DL_LOOKUP_SCOPE_LOCK handling. * elf/dl-object.c (_dl_new_object): Don't use __rtld_mrlock_initialize. 2007-06-19 Ulrich Drepper <drepper@redhat.com>
Diffstat (limited to 'elf/dl-close.c')
-rw-r--r--elf/dl-close.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/elf/dl-close.c b/elf/dl-close.c
index 2c2b3b6163..67188bb6c1 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -229,6 +229,7 @@ _dl_close_worker (struct link_map *map)
bool do_audit = GLRO(dl_naudit) > 0 && !ns->_ns_loaded->l_auditing;
#endif
bool unload_any = false;
+ bool scope_mem_left = false;
unsigned int unload_global = 0;
unsigned int first_loaded = ~0;
for (unsigned int i = 0; i < nloaded; ++i)
@@ -405,18 +406,18 @@ _dl_close_worker (struct link_map *map)
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;
/* No user anymore, we can free it now. */
if (old != imap->l_scope_mem)
- free (old);
+ {
+ if (_dl_scope_free (old))
+ /* If _dl_scope_free used THREAD_GSCOPE_WAIT (),
+ no need to repeat it. */
+ scope_mem_left = false;
+ }
+ else
+ scope_mem_left = true;
imap->l_scope_max = new_size;
}
@@ -485,9 +486,21 @@ _dl_close_worker (struct link_map *map)
j++;
}
ns_msl->r_nlist = j;
+ }
- if (!RTLD_SINGLE_THREAD_P)
- THREAD_GSCOPE_WAIT ();
+ if (!RTLD_SINGLE_THREAD_P
+ && (unload_global
+ || scope_mem_left
+ || (GL(dl_scope_free_list) != NULL
+ && GL(dl_scope_free_list)->count)))
+ {
+ THREAD_GSCOPE_WAIT ();
+
+ /* Now we can free any queued old scopes. */
+ struct dl_scope_free_list *fsl = GL(dl_scope_free_list);
+ if (fsl != NULL)
+ while (fsl->count > 0)
+ free (fsl->list[--fsl->count]);
}
size_t tls_free_start;
@@ -786,4 +799,8 @@ libc_freeres_fn (free_mem)
malloc), and in the static library it's in .bss space. */
free_slotinfo (&GL(dl_tls_dtv_slotinfo_list)->next);
}
+
+ void *scope_free_list = GL(dl_scope_free_list);
+ GL(dl_scope_free_list) = NULL;
+ free (scope_free_list);
}