summaryrefslogtreecommitdiff
path: root/source3/nmbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-06-29 00:48:44 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:19:07 -0500
commitd88926f6b4c11ba60200d7a7574b14fd04ab8a8f (patch)
treecce56df5c1aaa4a4251a87a1dd089d8d30cbdbe2 /source3/nmbd
parent124cd3c6043900be696148bb3c416f8c7c098cc9 (diff)
downloadsamba-d88926f6b4c11ba60200d7a7574b14fd04ab8a8f.tar.gz
samba-d88926f6b4c11ba60200d7a7574b14fd04ab8a8f.tar.bz2
samba-d88926f6b4c11ba60200d7a7574b14fd04ab8a8f.zip
r16665: Fix a couple of bugs I discovered now I've looked
closer at the wins server code. Firstly, it needs to do the searches on the SELF_NAMES correctly, secondly it needs to flush the in-memory cache out before returning the 1b names - else it might get duplicates returned if many 1b queries are done in quick succession. Jerry, I hate to say this but you might want to consider this for 3.0.23.... Jeremy. (This used to be commit b36b9befbbc4ac318168b7788d3722710ecbf10f)
Diffstat (limited to 'source3/nmbd')
-rw-r--r--source3/nmbd/nmbd_namelistdb.c2
-rw-r--r--source3/nmbd/nmbd_winsserver.c42
2 files changed, 33 insertions, 11 deletions
diff --git a/source3/nmbd/nmbd_namelistdb.c b/source3/nmbd/nmbd_namelistdb.c
index fb32ce1aad..d71eb5479a 100644
--- a/source3/nmbd/nmbd_namelistdb.c
+++ b/source3/nmbd/nmbd_namelistdb.c
@@ -120,7 +120,7 @@ struct name_record *find_name_on_subnet(struct subnet_record *subrec,
if( self_only && (name_ret->data.source != SELF_NAME) && (name_ret->data.source != PERMANENT_NAME) ) {
DEBUG( 9, ( "find_name_on_subnet: on subnet %s - self name %s NOT FOUND\n",
subrec->subnet_name, nmb_namestr(nmbname) ) );
- return False;
+ return NULL;
}
DEBUG( 9, ("find_name_on_subnet: on subnet %s - found name %s source=%d\n",
diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c
index 86f7fd5850..75841414bc 100644
--- a/source3/nmbd/nmbd_winsserver.c
+++ b/source3/nmbd/nmbd_winsserver.c
@@ -35,6 +35,24 @@
TDB_CONTEXT *wins_tdb;
/****************************************************************************
+ Delete all the temporary name records on the in-memory linked list.
+*****************************************************************************/
+
+static void wins_delete_all_tmp_in_memory_records(void)
+{
+ struct name_record *nr = NULL;
+ struct name_record *nrnext = NULL;
+
+ /* Delete all temporary name records on the wins subnet linked list. */
+ for( nr = wins_server_subnet->namelist; nr; nr = nrnext) {
+ nrnext = nr->next;
+ DLIST_REMOVE(wins_server_subnet->namelist, nr);
+ SAFE_FREE(nr->data.ip);
+ SAFE_FREE(nr);
+ }
+}
+
+/****************************************************************************
Convert a wins.tdb record to a struct name_record. Add in our global_scope().
*****************************************************************************/
@@ -217,6 +235,14 @@ struct name_record *find_name_on_wins_subnet(const struct nmb_name *nmbname, BOO
return NULL;
}
+ /* Self names only - these include permanent names. */
+ if( self_only && (namerec->data.source != SELF_NAME) && (namerec->data.source != PERMANENT_NAME) ) {
+ DEBUG( 9, ( "find_name_on_wins_subnet: self name %s NOT FOUND\n", nmb_namestr(nmbname) ) );
+ SAFE_FREE(namerec->data.ip);
+ SAFE_FREE(namerec);
+ return NULL;
+ }
+
/* Search for this name record on the list. Replace it if found. */
for( nr = wins_server_subnet->namelist; nr; nr = nr->next) {
@@ -1739,6 +1765,11 @@ static void process_wins_dmb_query_request(struct subnet_record *subrec,
num_ips = 0;
+ /* First, clear the in memory list - we're going to re-populate
+ it with the tdb_traversal in fetch_all_active_wins_1b_names. */
+
+ wins_delete_all_tmp_in_memory_records();
+
fetch_all_active_wins_1b_names();
for( namerec = subrec->namelist; namerec; namerec = namerec->next ) {
@@ -2176,8 +2207,6 @@ we are not the wins owner !\n", nmb_namestr(&namerec->name)));
void initiate_wins_processing(time_t t)
{
static time_t lasttime = 0;
- struct name_record *nr = NULL;
- struct name_record *nrnext = NULL;
if (!lasttime) {
lasttime = t;
@@ -2193,14 +2222,7 @@ void initiate_wins_processing(time_t t)
tdb_traverse(wins_tdb, wins_processing_traverse_fn, &t);
-
- /* Delete all temporary name records on the wins subnet linked list. */
- for( nr = wins_server_subnet->namelist; nr; nr = nrnext) {
- nrnext = nr->next;
- DLIST_REMOVE(wins_server_subnet->namelist, nr);
- SAFE_FREE(nr->data.ip);
- SAFE_FREE(nr);
- }
+ wins_delete_all_tmp_in_memory_records();
wins_write_database(t, True);