diff options
author | Tim Potter <tpot@samba.org> | 2002-08-16 00:25:48 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2002-08-16 00:25:48 +0000 |
commit | 88d321becdcff10f52a629946fb300d158fcc2fa (patch) | |
tree | 520edef8ca504853959f756e086dc0cd80044291 /source3/libsmb/namequery.c | |
parent | 298f956eaf7cbd362be8494f315a49d126a2c0ea (diff) | |
download | samba-88d321becdcff10f52a629946fb300d158fcc2fa.tar.gz samba-88d321becdcff10f52a629946fb300d158fcc2fa.tar.bz2 samba-88d321becdcff10f52a629946fb300d158fcc2fa.zip |
Merge of netbios namecache code from APPLIANCE_HEAD.
Tridge suggested a generic caching mechanism for Samba to avoid the
proliferation of little cache files hanging around limpet like in the
locks directory. Someone should probably implement this at some
stage.
(This used to be commit dad31483b3bd1790356ef1e40ac62624a403bce8)
Diffstat (limited to 'source3/libsmb/namequery.c')
-rw-r--r-- | source3/libsmb/namequery.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 3382ce4f4a..40a353fa8b 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -783,7 +783,7 @@ static BOOL resolve_hosts(const char *name, *********************************************************/ static BOOL internal_resolve_name(const char *name, int name_type, - struct in_addr **return_iplist, int *return_count) + struct in_addr **return_iplist, int *return_count) { pstring name_resolve_list; fstring tok; @@ -816,6 +816,15 @@ static BOOL internal_resolve_name(const char *name, int name_type, return True; } + /* Check netbios name cache */ + + if (namecache_fetch(name, name_type, return_iplist, return_count)) { + + /* This could be a negative response */ + + return (*return_count > 0); + } + pstrcpy(name_resolve_list, lp_name_resolve_order()); ptr = name_resolve_list; if (!ptr || !*ptr) @@ -823,9 +832,16 @@ static BOOL internal_resolve_name(const char *name, int name_type, while (next_token(&ptr, tok, LIST_SEP, sizeof(tok))) { if((strequal(tok, "host") || strequal(tok, "hosts"))) { - if (name_type == 0x20 && resolve_hosts(name, return_iplist, return_count)) { - result = True; - goto done; + if (name_type == 0x20) { + if (resolve_hosts(name, return_iplist, return_count)) { + result = True; + goto done; + } else { + + /* Store negative lookup result */ + + namecache_store(name, name_type, 0, NULL); + } } } else if(strequal( tok, "lmhosts")) { if (resolve_lmhosts(name, name_type, return_iplist, return_count)) { @@ -897,6 +913,10 @@ static BOOL internal_resolve_name(const char *name, int name_type, *return_iplist = nodupes_iplist; *return_count = nodupes_count; } + + /* Save in name cache */ + + namecache_store(name, name_type, *return_count, *return_iplist); /* Display some debugging info */ |