summaryrefslogtreecommitdiff
path: root/source3/nameservreply.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1997-10-22 11:02:00 +0000
committerAndrew Tridgell <tridge@samba.org>1997-10-22 11:02:00 +0000
commite5c319186d079eeef55a7ee62fac2a993e932938 (patch)
treec8f01f398f801ecfa5a3a97ff5ca45ece501f459 /source3/nameservreply.c
parentbda8cac802414eb15122cc7ad2f0082bcca177d5 (diff)
downloadsamba-e5c319186d079eeef55a7ee62fac2a993e932938.tar.gz
samba-e5c319186d079eeef55a7ee62fac2a993e932938.tar.bz2
samba-e5c319186d079eeef55a7ee62fac2a993e932938.zip
Implemented asynchronous DNS lookups in nmbd.
I realised this afternoon just how easy it is to add this, so I thought I'd implement it while the idea was fresh. nmbd forks at startup and uses a pipe to talk to its child. The child does the DNS lookups and the file descriptor of the child is added to the main select loop. While I was doing this I discovered a bug in nmbd that explains why the dns proxy option has been so expensive. The DNS cache entries in the WINS list were never being checked, which means we always did a DNS lookup even if we have done it before and it is in cache. I'm sure this used to work (I tested the DNS cache when I added it) so someone broke it :-( Anyway, the async DNS gets rid of the problem completely. I'll commit just the fix to the DNS cache bug to the 1.9.17 tree. You can disable async DNS by adding -DSYNC_DNS to the compile flags. (This used to be commit 178e27de0791c1ff3268cb456ed5c5efc9ac2a01)
Diffstat (limited to 'source3/nameservreply.c')
-rw-r--r--source3/nameservreply.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/source3/nameservreply.c b/source3/nameservreply.c
index c901059f9b..6585a02261 100644
--- a/source3/nameservreply.c
+++ b/source3/nameservreply.c
@@ -569,23 +569,31 @@ void reply_name_query(struct packet_struct *p)
/* look up the name in the cache */
n = find_name_search(&d, question, FIND_LOCAL, p->ip);
+ /* check for a previous DNS lookup */
+ if (!n && (n = find_name_search(&d, question, FIND_WINS, p->ip))) {
+ if (n->source != DNS && n->source != DNSFAIL) {
+ n = NULL;
+ } else {
+ DEBUG(5,("Found DNS cache entry %s\n", namestr(&n->name)));
+ }
+ }
+
/* it is a name that already failed DNS lookup or it's expired */
if (n && (n->source == DNSFAIL ||
- (n->death_time && n->death_time < p->timestamp)))
- {
- success = False;
+ (n->death_time && n->death_time < p->timestamp))) {
+ DEBUG(5,("expired name %s\n", namestr(&n->name)));
+ success = False;
}
+
/* do we want to do dns lookups? */
- /* XXXX this DELAYS nmbd while it does a search. lp_dns_proxy()
- can be switched off, to ensure that the blocking doesn't occur.
- a better solution would be to fork, but this will require a
- mechanism to carry on processing after the query is resolved
- (similar to the netbios queue).
- */
- if (success && !n && (lp_dns_proxy() || !bcast))
- {
- n = dns_name_search(question, p->timestamp);
+ if (success && !n && (lp_dns_proxy() || !bcast)) {
+ BOOL dns_type = (name_type == 0x20 || name_type == 0);
+ if (dns_type && wins_subnet) {
+ /* add it to the dns name query queue */
+ if (queue_dns_query(p, question, &n))
+ return;
+ }
}
}