1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

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)
This commit is contained in:
Andrew Tridgell 1998-08-31 06:59:23 +00:00
parent 36bbc13fcd
commit f8ad53aa03
2 changed files with 21 additions and 3 deletions

View File

@ -567,6 +567,8 @@ int main(int argc,char *argv[])
StartupTime = time(NULL);
srandom(time(NULL) ^ getpid());
TimeInit();
pstrcpy( debugf, NMBLOGFILE );

View File

@ -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",