diff options
| author | junyoung <junyoung@NetBSD.org> | 2002-10-01 14:16:53 +0000 |
|---|---|---|
| committer | junyoung <junyoung@NetBSD.org> | 2002-10-01 14:16:53 +0000 |
| commit | a189aa3eba35673088227d41b4f0b2b124a04415 (patch) | |
| tree | 82bb0794ca7bca3ee993d51bb28d58cc1c6e84d0 /libexec | |
| parent | 11a0f4d42d5b07b61ebefa6505158570fa5656fd (diff) | |
Store pathnames of shared objects not found in search paths in cache
and utilize it. This greatly reduces the number of calls to open(2) and
malloc(3) for programs like mozilla that depend on many shared objects
while it doesn't affect performance of small programs.
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/ld.elf_so/search.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/libexec/ld.elf_so/search.c b/libexec/ld.elf_so/search.c index 0410c546ce6..0bde692cd4f 100644 --- a/libexec/ld.elf_so/search.c +++ b/libexec/ld.elf_so/search.c @@ -1,4 +1,4 @@ -/* $NetBSD: search.c,v 1.13 2002/09/24 12:52:20 mycroft Exp $ */ +/* $NetBSD: search.c,v 1.14 2002/10/01 14:16:53 junyoung Exp $ */ /* * Copyright 1996 Matt Thomas <matt@3am-software.com> @@ -55,6 +55,8 @@ /* * Data declarations. */ +Search_Path *_rtld_invalid_paths; + static Obj_Entry *_rtld_search_library_path __P((const char *, size_t, const char *, size_t, int)); @@ -67,17 +69,36 @@ _rtld_search_library_path(name, namelen, dir, dirlen, mode) int mode; { char *pathname; + size_t pathnamelen; Obj_Entry *obj; + Search_Path *sp; + + pathnamelen = dirlen + 1 + namelen; + + for (sp = _rtld_invalid_paths; sp != NULL; sp = sp->sp_next) { + if (sp->sp_pathlen == pathnamelen && + !strncmp(name, sp->sp_path + dirlen + 1, namelen) && + !strncmp(dir, sp->sp_path, dirlen)) { + return NULL; + } + } - pathname = xmalloc(dirlen + 1 + namelen + 1); + pathname = xmalloc(pathnamelen + 1); (void)strncpy(pathname, dir, dirlen); pathname[dirlen] = '/'; strcpy(pathname + dirlen + 1, name); dbg((" Trying \"%s\"", pathname)); obj = _rtld_load_object(pathname, mode); - if (obj == NULL) - free(pathname); + if (obj == NULL) { + Search_Path *path; + + path = NEW(Search_Path); + path->sp_pathlen = pathnamelen; + path->sp_path = pathname; + path->sp_next = _rtld_invalid_paths; + _rtld_invalid_paths = path; + } return obj; } |
