summaryrefslogtreecommitdiff
path: root/libexec/ld.so/library_subr.c
diff options
context:
space:
mode:
authorKurt Miller <kurt@cvs.openbsd.org>2005-10-03 19:48:25 +0000
committerKurt Miller <kurt@cvs.openbsd.org>2005-10-03 19:48:25 +0000
commitf0ec10f99ceed98f7aca872885d459d0b94f085b (patch)
tree58b09869d6b5e51c92af23da6035bb0faf4d674c /libexec/ld.so/library_subr.c
parentdc1076a067eafa18a3b9c5f0ca9732efc6e5856b (diff)
refcount corrections: count common dep libs once and centralize dep lib
refcount increments to _dl_link_sub. adjust _dl_notify_unload_shlib to match new refcount method. ok drahn@
Diffstat (limited to 'libexec/ld.so/library_subr.c')
-rw-r--r--libexec/ld.so/library_subr.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/libexec/ld.so/library_subr.c b/libexec/ld.so/library_subr.c
index 2fab10ca73b..44e9a30b178 100644
--- a/libexec/ld.so/library_subr.c
+++ b/libexec/ld.so/library_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: library_subr.c,v 1.14 2005/10/01 19:32:22 drahn Exp $ */
+/* $OpenBSD: library_subr.c,v 1.15 2005/10/03 19:48:24 kurt Exp $ */
/*
* Copyright (c) 2002 Dale Rahn
@@ -353,10 +353,17 @@ _dl_notify_unload_shlib(elf_object_t *object)
{
struct dep_node *n;
- object->refcount--;
-
- TAILQ_FOREACH(n, &object->child_list, next_sib)
- n->data->refcount--;
+ /*
+ * if this is the last ref, then decrement refcount
+ * on self and all dloaded deps, otherwise just decrement
+ * self.
+ */
+ if (object->refcount == 1) {
+ TAILQ_FOREACH(n, &object->dload_list, next_sib)
+ n->data->refcount--;
+ } else {
+ object->refcount--;
+ }
}
void
@@ -401,6 +408,7 @@ _dl_link_sub(elf_object_t *dep, elf_object_t *p)
_dl_exit(8);
n->data = dep;
TAILQ_INSERT_TAIL(&_dl_loading_object->dload_list, n, next_sib);
+ dep->refcount++;
DL_DEB(("linking dep %s as child of %s\n", dep->load_name,
p->load_name));