ldconfig stuff
Andreas Jaeger
aj@suse.de
Sun Sep 24 09:41:00 GMT 2000
>>>>> Ulrich Drepper writes:
> I was looking (admittedly the first time) closely at the ldconfig
> code. There are a few things which I do not really like:
> - in search dir, whenever a directory is seen it is immediately processed.
> This is semantically not necessary and not beneficial for the performance.
> The directories should be queued and then processed once the current
> directory is done.
Here's a patch, I might look later into the other problem.
Ok to commit?
Andreas
2000-09-24 Andreas Jaeger <aj@suse.de>
* elf/ldconfig.c (add_dir): Move logic to add entry to list to new
function add_single_dir.
(add_single_dir): New function.
(search_dir): Use add_single_dir instead of recursing.
============================================================
Index: elf/ldconfig.c
--- elf/ldconfig.c 2000/09/24 16:02:59 1.6
+++ elf/ldconfig.c 2000/09/24 16:36:44
@@ -258,12 +258,42 @@
"Andreas Jaeger");
}
+/* Add a single directory entry. */
+static void
+add_single_dir (struct dir_entry *entry, int verbose)
+{
+ struct dir_entry *ptr, *prev;
+
+ ptr = dir_entries;
+ prev = ptr;
+ while (ptr != NULL)
+ {
+ /* Check for duplicates. */
+ if (strcmp (ptr->path, entry->path) == 0)
+ {
+ if (opt_verbose && verbose)
+ error (0, 0, _("Path `%s' given more than once"), entry->path);
+ /* Use the newer information. */
+ ptr->flag = entry->flag;
+ free (entry);
+ break;
+ }
+ prev = ptr;
+ ptr = ptr->next;
+ }
+ /* Is this the first entry? */
+ if (ptr == NULL && dir_entries == NULL)
+ dir_entries = entry;
+ else if (ptr == NULL)
+ prev->next = entry;
+}
+
/* Add one directory to the list of directories to process. */
static void
add_dir (const char *line)
{
char *equal_sign;
- struct dir_entry *entry, *ptr, *prev;
+ struct dir_entry *entry;
unsigned int i;
entry = xmalloc (sizeof (struct dir_entry));
@@ -299,28 +329,7 @@
--i;
}
- ptr = dir_entries;
- prev = ptr;
- while (ptr != NULL)
- {
- /* Check for duplicates. */
- if (strcmp (ptr->path, entry->path) == 0)
- {
- if (opt_verbose)
- error (0, 0, _("Path `%s' given more than once"), entry->path);
- /* Use the newer information. */
- ptr->flag = entry->flag;
- free (entry);
- break;
- }
- prev = ptr;
- ptr = ptr->next;
- }
- /* Is this the first entry? */
- if (ptr == NULL && dir_entries == NULL)
- dir_entries = entry;
- else if (ptr == NULL)
- prev->next = entry;
+ add_single_dir (entry, 1);
}
@@ -571,12 +580,15 @@
if (S_ISDIR (stat_buf.st_mode) && is_hwcap (direntry->d_name))
{
- /* Handle subdirectory also, make a recursive call. */
- struct dir_entry new_entry;
- new_entry.path = buf;
- new_entry.flag = entry->flag;
- new_entry.next = NULL;
- search_dir (&new_entry);
+ /* Handle subdirectory later. */
+ struct dir_entry *new_entry;
+
+ new_entry = xmalloc (sizeof (struct dir_entry));
+
+ new_entry->path = buf;
+ new_entry->flag = entry->flag;
+ new_entry->next = NULL;
+ add_single_dir (new_entry, 0);
continue;
}
else if (!S_ISREG (stat_buf.st_mode) && !S_ISLNK (stat_buf.st_mode))
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
More information about the Libc-hacker
mailing list