aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-02-18 07:30:25 +0000
committerUlrich Drepper <drepper@redhat.com>2000-02-18 07:30:25 +0000
commit60c4f8eb1ef3b84ab17749e2bf3a8a14baacd1a2 (patch)
tree82a45277c558bf5e42818ef9e5af691323ad2545
parent90ab302088fcc33b44ef20eb036e1f2d5d84c109 (diff)
downloadglibc-60c4f8eb1ef3b84ab17749e2bf3a8a14baacd1a2.tar
glibc-60c4f8eb1ef3b84ab17749e2bf3a8a14baacd1a2.tar.gz
glibc-60c4f8eb1ef3b84ab17749e2bf3a8a14baacd1a2.tar.bz2
glibc-60c4f8eb1ef3b84ab17749e2bf3a8a14baacd1a2.zip
Update.
2000-02-17 Ulrich Drepper <drepper@redhat.com> * nscd/hstcache.c (cache_addhst): Don't cache name->record entries if more than one IP address is available.
-rw-r--r--ChangeLog5
-rw-r--r--nscd/hstcache.c55
2 files changed, 38 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 0344dc1094..9d1c7b0d3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2000-02-17 Ulrich Drepper <drepper@redhat.com>
+
+ * nscd/hstcache.c (cache_addhst): Don't cache name->record entries
+ if more than one IP address is available.
+
2000-02-17 Jakub Jelinek <jakub@redhat.com>
* sysdeps/unix/sysv/linux/sparc/bits/termios.h: Sync with kernel.
diff --git a/nscd/hstcache.c b/nscd/hstcache.c
index 5ac0cee816..253b76c65d 100644
--- a/nscd/hstcache.c
+++ b/nscd/hstcache.c
@@ -211,18 +211,24 @@ cache_addhst (struct database *db, int fd, request_header *req, void *key,
/* Now get the lock to safely insert the records. */
pthread_rwlock_rdlock (&db->lock);
- /* First add all the aliases. */
- for (cnt = 0; cnt < h_aliases_cnt; ++cnt)
- {
- if (addr_list_type == GETHOSTBYADDR)
- cache_add (GETHOSTBYNAME, aliases, h_aliases_len[cnt], data, total,
- data, 0, t, db, owner);
+ /* First add all the aliases. If the record contains more than
+ one IP address (used for load balancing etc) don't cache the
+ entry. This is something the current cache handling cannot
+ handle and it is more than questionable whether it is
+ worthwhile complicating the cache handling just for handling
+ such a special case. */
+ if (hst->h_addr_list[1] == NULL)
+ for (cnt = 0; cnt < h_aliases_cnt; ++cnt)
+ {
+ if (addr_list_type == GETHOSTBYADDR)
+ cache_add (GETHOSTBYNAME, aliases, h_aliases_len[cnt], data,
+ total, data, 0, t, db, owner);
- cache_add (GETHOSTBYNAMEv6, aliases, h_aliases_len[cnt], data, total,
- data, 0, t, db, owner);
+ cache_add (GETHOSTBYNAMEv6, aliases, h_aliases_len[cnt], data,
+ total, data, 0, t, db, owner);
- aliases += h_aliases_len[cnt];
- }
+ aliases += h_aliases_len[cnt];
+ }
/* Next the normal addresses. */
for (cnt = 0; cnt < h_addr_list_cnt; ++cnt)
@@ -241,23 +247,28 @@ cache_addhst (struct database *db, int fd, request_header *req, void *key,
addresses += IN6ADDRSZ;
}
- /* If necessary add the key for this request. */
- if (req->type == GETHOSTBYNAME || req->type == GETHOSTBYNAMEv6)
+ /* Avoid adding names if more than one address is available. See
+ above for more info. */
+ if (hst->h_addr_list[1] == NULL)
{
+ /* If necessary add the key for this request. */
+ if (req->type == GETHOSTBYNAME || req->type == GETHOSTBYNAMEv6)
+ {
+ if (addr_list_type == GETHOSTBYADDR)
+ cache_add (GETHOSTBYNAME, key_copy, req->key_len, data, total,
+ data, 0, t, db, owner);
+ cache_add (GETHOSTBYNAMEv6, key_copy, req->key_len, data,
+ total, data, 0, t, db, owner);
+ }
+
+ /* And finally the name. We mark this as the last entry. */
if (addr_list_type == GETHOSTBYADDR)
- cache_add (GETHOSTBYNAME, key_copy, req->key_len, data, total,
+ cache_add (GETHOSTBYNAME, data->strdata, h_name_len, data, total,
data, 0, t, db, owner);
- cache_add (GETHOSTBYNAMEv6, key_copy, req->key_len, data,
- total, data, 0, t, db, owner);
+ cache_add (GETHOSTBYNAMEv6, data->strdata, h_name_len, data,
+ total, data, 1, t, db, owner);
}
- /* And finally the name. We mark this as the last entry. */
- if (addr_list_type == GETHOSTBYADDR)
- cache_add (GETHOSTBYNAME, data->strdata, h_name_len, data, total, data,
- 0, t, db, owner);
- cache_add (GETHOSTBYNAMEv6, data->strdata, h_name_len, data,
- total, data, 1, t, db, owner);
-
pthread_rwlock_unlock (&db->lock);
}