summaryrefslogtreecommitdiff
path: root/libexec/ld.so/dlfcn.c
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2005-09-28 15:41:07 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2005-09-28 15:41:07 +0000
commit533868b989d82a44d3c5e1688d5635d60f71f04c (patch)
treefb39e76ef4b4865627e8d70805d63a6fa597ffb4 /libexec/ld.so/dlfcn.c
parentb1bb0e421389e910c2bdbed4619cf53056269631 (diff)
keep track of opencounts for dlopened objects, so that they
get unloaded the right number of times on exit.
Diffstat (limited to 'libexec/ld.so/dlfcn.c')
-rw-r--r--libexec/ld.so/dlfcn.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libexec/ld.so/dlfcn.c b/libexec/ld.so/dlfcn.c
index 81f44af0b0b..e700b516088 100644
--- a/libexec/ld.so/dlfcn.c
+++ b/libexec/ld.so/dlfcn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dlfcn.c,v 1.55 2005/09/28 15:24:22 kurt Exp $ */
+/* $OpenBSD: dlfcn.c,v 1.56 2005/09/28 15:41:06 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -145,6 +145,9 @@ dlopen(const char *libname, int flags)
}
loaded:
+ if (failed == 0)
+ object->opencount++;
+
if (_dl_debug_map->r_brk) {
_dl_debug_map->r_state = RT_ADD;
(*((void (*)(void))_dl_debug_map->r_brk))();
@@ -279,10 +282,10 @@ _dl_real_close(void *handle)
return (1);
}
-
_dl_notify_unload_shlib(object);
_dl_run_all_dtors();
- _dl_unlink_dlopen(object);
+ if(--object->opencount == 0)
+ _dl_unlink_dlopen(object);
_dl_unload_shlib(object);
return (0);
}