diff options
author | Andrew Tridgell <tridge@samba.org> | 1998-08-31 06:59:23 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1998-08-31 06:59:23 +0000 |
commit | 685f4ef2e1f83ab39e91229cf53a61eecb6181eb (patch) | |
tree | f66afb06093fb7deec8f27648c0b868880a0ed07 /source/nmbd | |
parent | d7e50f0111f6c65b9d6f8654684e7fc5a1e7ea32 (diff) | |
download | samba-685f4ef2e1f83ab39e91229cf53a61eecb6181eb.tar.gz samba-685f4ef2e1f83ab39e91229cf53a61eecb6181eb.tar.xz samba-685f4ef2e1f83ab39e91229cf53a61eecb6181eb.zip |
I realised that my DMB<->DMB sync code has the property that the
amount of network traffic grows as the square of the number of
workgroups. It probably wouldn't have caused problems but to be safe I
changed the code to use random() to decrease the probability of a
DMB<->DMB sync in proportion to the number of known workgroups. This
keeps the nice browse connectivity while making the traffic rise only
linearly with the number of workgroups.
Diffstat (limited to 'source/nmbd')
-rw-r--r-- | source/nmbd/nmbd.c | 2 | ||||
-rw-r--r-- | source/nmbd/nmbd_browsesync.c | 20 |
2 files changed, 20 insertions, 2 deletions
diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c index feb9c2420e3..72cc9408d51 100644 --- a/source/nmbd/nmbd.c +++ b/source/nmbd/nmbd.c @@ -567,6 +567,8 @@ int main(int argc,char *argv[]) StartupTime = time(NULL); + srandom(time(NULL) ^ getpid()); + TimeInit(); pstrcpy( debugf, NMBLOGFILE ); diff --git a/source/nmbd/nmbd_browsesync.c b/source/nmbd/nmbd_browsesync.c index 8136568c6aa..b1fb4e631fd 100644 --- a/source/nmbd/nmbd_browsesync.c +++ b/source/nmbd/nmbd_browsesync.c @@ -556,12 +556,17 @@ void collect_all_workgroup_names_from_wins_server(time_t t) /**************************************************************************** If we are a domain master browser on the unicast subnet, do a regular sync - with all other DMBs that we know of on that subnet + with all other DMBs that we know of on that subnet. + +To prevent exponential network traffic with large numbers of workgroups +we use a randomised system where sync probability is inversely proportional +to the number of known workgroups **************************************************************************/ void sync_all_dmbs(time_t t) { static time_t lastrun = 0; struct work_record *work; + int count=0; /* Only do this if we are using a WINS server. */ if(we_are_a_wins_client() == False) @@ -575,13 +580,24 @@ void sync_all_dmbs(time_t t) if (!AM_DOMAIN_MASTER_BROWSER(work)) return; - if ((lastrun != 0) && (t < lastrun + (15 * 60))) + if ((lastrun != 0) && (t < lastrun + (5 * 60))) return; + /* count how many syncs we might need to do */ + for (work=unicast_subnet->workgrouplist; work; work = work->next) { + if (strcmp(global_myworkgroup, work->work_group) && + !ip_equal(work->dmb_addr, ipzero)) { + count++; + } + } + /* sync with a probability of 1/count */ for (work=unicast_subnet->workgrouplist; work; work = work->next) { if (strcmp(global_myworkgroup, work->work_group) && !ip_equal(work->dmb_addr, ipzero)) { + + if (((unsigned)random()) % count != 0) continue; + lastrun = t; DEBUG(3,("initiating DMB<->DMB sync with %s(%s)\n", |