summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-08-31 06:59:23 +0000
committerAndrew Tridgell <tridge@samba.org>1998-08-31 06:59:23 +0000
commitf8ad53aa037b362b37592ca04b160cb81ccdecc8 (patch)
tree2d4ae0e94e6b39f85c90d9e28f0e2ae3fa0397c2
parent36bbc13fcdfafee3d9d8dd15a9ea84a55d444bdc (diff)
downloadsamba-f8ad53aa037b362b37592ca04b160cb81ccdecc8.tar.gz
samba-f8ad53aa037b362b37592ca04b160cb81ccdecc8.tar.bz2
samba-f8ad53aa037b362b37592ca04b160cb81ccdecc8.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. (This used to be commit 685f4ef2e1f83ab39e91229cf53a61eecb6181eb)
-rw-r--r--source3/nmbd/nmbd.c2
-rw-r--r--source3/nmbd/nmbd_browsesync.c20
2 files changed, 20 insertions, 2 deletions
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index feb9c2420e..72cc9408d5 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/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/source3/nmbd/nmbd_browsesync.c b/source3/nmbd/nmbd_browsesync.c
index 8136568c6a..b1fb4e631f 100644
--- a/source3/nmbd/nmbd_browsesync.c
+++ b/source3/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",