2 Unix SMB/Netbios implementation.
4 NBT netbios routines and daemon - version 2
5 Copyright (C) Andrew Tridgell 1994-1997
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 Module name: nameelect.c
25 14 jan 96: lkcl@pires.co.uk
26 added multiple workgroup domain master support
28 04 jul 96: lkcl@pires.co.uk
29 added system to become a master browser by stages.
37 extern int ClientDGRAM
;
39 extern int DEBUGLEVEL
;
42 extern pstring myname
;
43 extern fstring myworkgroup
;
44 extern struct in_addr ipzero
;
45 extern struct in_addr wins_ip
;
47 /* here are my election parameters */
49 extern time_t StartupTime
;
51 extern struct subnet_record
*subnetlist
;
53 extern uint16 nb_type
; /* samba's NetBIOS name type */
56 /*******************************************************************
57 occasionally check to see if the master browser is around
58 ******************************************************************/
59 void check_master_browser(time_t t
)
61 static time_t lastrun
=0;
62 struct subnet_record
*d
;
64 if (!lastrun
) lastrun
= t
;
65 if (t
< lastrun
+ CHECK_TIME_MST_BROWSE
* 60) return;
71 for (d
= FIRST_SUBNET
; d
; d
= NEXT_SUBNET_EXCLUDING_WINS(d
))
73 struct work_record
*work
;
75 for (work
= d
->workgrouplist
; work
; work
= work
->next
)
77 if (strequal(work
->work_group
, myworkgroup
) && !AM_MASTER(work
))
79 if (lp_local_master() && lp_preferred_master())
81 /* potential master browser - not a master browser. force
82 becoming a master browser, hence the log message.
85 DEBUG(2,("%s potential master for %s %s - force election\n",
86 timestring(), work
->work_group
,
87 inet_ntoa(d
->bcast_ip
)));
89 browser_gone(work
->work_group
, d
->bcast_ip
);
93 /* if we are not the browse master of a workgroup,
94 and we can't find a browser on the subnet, do
98 queue_netbios_packet(d
,ClientNMB
,NMB_QUERY
,NAME_QUERY_MST_CHK
,
99 work
->work_group
,0x1d,0,0,0,NULL
,NULL
,
100 True
,False
,d
->bcast_ip
,d
->bcast_ip
, 0);
108 /*******************************************************************
109 what to do if a master browser DOESN't exist.
111 option 1: force an election, and participate in it
112 option 2: force an election, and let everyone else participate.
114 ******************************************************************/
115 void browser_gone(char *work_name
, struct in_addr ip
)
117 struct subnet_record
*d
= find_subnet(ip
);
118 struct work_record
*work
= find_workgroupstruct(d
, work_name
, False
);
120 /* i don't know about this workgroup, therefore i don't care */
121 if (!work
|| !d
) return;
123 /* don't do election stuff on the WINS subnet */
124 if (ip_equal(d
->bcast_ip
,wins_ip
))
127 if (strequal(work
->work_group
, myworkgroup
))
130 if (lp_local_master())
132 /* we have discovered that there is no local master
133 browser, and we are configured to initiate
134 an election under exactly such circumstances.
136 DEBUG(2,("Forcing election on %s %s\n",
137 work
->work_group
,inet_ntoa(d
->bcast_ip
)));
139 /* we can attempt to become master browser */
140 work
->needelection
= True
;
144 /* we need to force an election, because we are configured
145 not to _become_ the local master, but we still _need_ one,
146 having detected that one doesn't exist.
149 /* local interfaces: force an election */
150 send_election(d
, work
->work_group
, 0, 0, myname
);
152 /* only removes workgroup completely on a local interface
153 persistent lmhosts entries on a local interface _will_ be removed).
155 remove_workgroup(d
, work
,True
);
156 add_workgroup_to_subnet(d
, work
->work_group
);
162 /****************************************************************************
163 send an election packet
164 **************************************************************************/
165 void send_election(struct subnet_record
*d
, char *group
,uint32 criterion
,
166 int timeup
,char *name
)
173 DEBUG(2,("Sending election to %s for workgroup %s\n",
174 inet_ntoa(d
->bcast_ip
),group
));
176 bzero(outbuf
,sizeof(outbuf
));
178 CVAL(p
,0) = ANN_Election
; /* election */
181 CVAL(p
,0) = (criterion
== 0 && timeup
== 0) ? 0 : ELECTION_VERSION
;
182 SIVAL(p
,1,criterion
);
183 SIVAL(p
,5,timeup
*1000); /* ms - despite the spec */
187 p
= skip_string(p
,1);
189 send_mailslot_reply(False
,BROWSE_MAILSLOT
,ClientDGRAM
,
190 outbuf
,PTR_DIFF(p
,outbuf
),
191 name
,group
,0,0x1e,d
->bcast_ip
,*iface_ip(d
->bcast_ip
));
195 /****************************************************************************
196 un-register a SELF name that got rejected.
198 if this name happens to be rejected when samba is in the process
199 of becoming a master browser (registering __MSBROWSE__, WORKGROUP(1d)
200 or WORKGROUP(1b)) then we must stop being a master browser. sad.
202 **************************************************************************/
203 void name_unregister_work(struct subnet_record
*d
, char *name
, int name_type
)
205 struct work_record
*work
;
206 int remove_type_local
= 0;
207 int remove_type_domain
= 0;
208 int remove_type_logon
= 0;
210 remove_netbios_name(d
,name
,name_type
,SELF
);
212 if (!(work
= find_workgroupstruct(d
, name
, False
))) return;
214 /* work out what to unbecome, from the name type being removed */
216 if (ms_browser_name(name
, name_type
))
218 remove_type_local
|= SV_TYPE_MASTER_BROWSER
;
220 if (AM_MASTER(work
) && strequal(name
, myworkgroup
) && name_type
== 0x1d)
222 remove_type_local
|= SV_TYPE_MASTER_BROWSER
;
224 if (AM_DOMMST(work
) && strequal(name
, myworkgroup
) && name_type
== 0x1b)
226 remove_type_domain
|= SV_TYPE_DOMAIN_MASTER
;
228 if (AM_DOMMEM(work
) && strequal(name
, myworkgroup
) && name_type
== 0x1c)
230 remove_type_logon
|= SV_TYPE_DOMAIN_MEMBER
;
233 if (remove_type_local
) unbecome_local_master (d
, work
, remove_type_local
);
234 if (remove_type_domain
) unbecome_domain_master(d
, work
, remove_type_domain
);
235 if (remove_type_logon
) unbecome_logon_server (d
, work
, remove_type_logon
);
239 /****************************************************************************
242 if the name being added is a SELF name, we must additionally check
243 whether to proceed to the next stage in samba becoming a master browser.
245 **************************************************************************/
246 void name_register_work(struct subnet_record
*d
, char *name
, int name_type
,
247 int nb_flags
, time_t ttl
, struct in_addr ip
, BOOL bcast
)
249 enum name_source source
= (ismyip(ip
) || ip_equal(ip
, ipzero
)) ?
254 struct work_record
*work
= find_workgroupstruct(d
,
257 struct subnet_record
*add_subnet
= (!bcast
) ? wins_client_subnet
: d
;
258 add_netbios_entry(add_subnet
,name
,name_type
,nb_flags
,ttl
,source
,ip
,True
);
262 int add_type_local
= False
;
263 int add_type_domain
= False
;
264 int add_type_logon
= False
;
266 DEBUG(4,("checking next stage: name_register_work %s\n", name
));
268 /* work out what to become, from the name type being added */
270 if (ms_browser_name(name
, name_type
))
272 add_type_local
= True
;
274 if (strequal(name
, myworkgroup
) && name_type
== 0x1d)
276 add_type_local
= True
;
278 if (strequal(name
, myworkgroup
) && name_type
== 0x1b)
280 add_type_domain
= True
;
282 if (strequal(name
, myworkgroup
) && name_type
== 0x1c)
284 add_type_logon
= True
;
287 if (add_type_local
) become_local_master (d
, work
);
288 if (add_type_domain
) become_domain_master(d
, work
);
289 if (add_type_logon
) become_logon_server (d
, work
);
295 /*******************************************************************
296 become the local master browser.
298 this is done in stages. note that this could take a while,
299 particularly on a broadcast subnet, as we have to wait for
300 the implicit registration of each name to be accepted.
302 as each name is successfully registered, become_local_master() is
303 called again, in order to initiate the next stage. see
304 dead_netbios_entry() - deals with implicit name registration
305 and response_name_reg() - deals with explicit registration
308 stage 1: was MST_POTENTIAL - go to MST_POTENTIAL and register ^1^2__MSBROWSE__^2^1.
309 stage 2: was MST_BACK - go to MST_MSB and register WORKGROUP(0x1d)
310 stage 3: was MST_MSB - go to MST_BROWSER and stay there
312 XXXX note: this code still does not cope with the distinction
313 between different types of nodes, particularly between M and P
314 nodes. that comes later.
316 ******************************************************************/
317 void become_local_master(struct subnet_record
*d
, struct work_record
*work
)
319 /* domain type must be limited to domain enum + server type. it must
320 not have SV_TYPE_SERVER or anything else with SERVER in it, else
321 clients get confused and start thinking this entry is a server
324 uint32 domain_type
= SV_TYPE_DOMAIN_ENUM
|SV_TYPE_NT
;
329 if (!lp_local_master())
331 DEBUG(0,("Samba not configured as a local master browser.\n"));
335 DEBUG(2,("Becoming master for %s %s (currently at stage %d)\n",
336 work
->work_group
,inet_ntoa(d
->bcast_ip
),work
->mst_state
));
338 switch (work
->mst_state
)
340 case MST_POTENTIAL
: /* while we were nothing but a server... */
342 DEBUG(3,("go to first stage: register ^1^2__MSBROWSE__^2^1\n"));
343 work
->mst_state
= MST_BACK
; /* an election win was successful */
345 work
->ElectionCriterion
|= 0x5;
347 /* update our server status */
348 work
->ServerType
&= ~SV_TYPE_POTENTIAL_BROWSER
;
349 add_server_entry(d
,work
,myname
,work
->ServerType
|SV_TYPE_LOCAL_LIST_ONLY
,
350 0,lp_serverstring(),True
);
352 /* add special browser name */
353 add_my_name_entry(d
,MSBROWSE
,0x01,nb_type
|NB_ACTIVE
|NB_GROUP
);
355 /* DON'T do anything else after calling add_my_name_entry() */
359 case MST_BACK
: /* while nothing had happened except we won an election... */
361 DEBUG(3,("go to second stage: register as master browser\n"));
362 work
->mst_state
= MST_MSB
; /* registering MSBROWSE was successful */
364 /* add server entry on successful registration of MSBROWSE */
365 add_server_entry(d
,work
,work
->work_group
,domain_type
|SV_TYPE_LOCAL_LIST_ONLY
,
368 /* add master name */
369 add_my_name_entry(d
,work
->work_group
,0x1d,nb_type
|NB_ACTIVE
);
371 /* DON'T do anything else after calling add_my_name_entry() */
375 case MST_MSB
: /* while we were still only registered MSBROWSE state... */
378 struct server_record
*sl
;
380 DEBUG(3,("2nd stage complete: registered as master browser for workgroup %s \
381 on subnet %s\n", work
->work_group
, inet_ntoa(d
->bcast_ip
)));
382 work
->mst_state
= MST_BROWSER
; /* registering WORKGROUP(1d) succeeded */
384 /* update our server status */
385 work
->ServerType
|= SV_TYPE_MASTER_BROWSER
;
387 DEBUG(3,("become_local_master: updating our server %s to type %x\n",
388 myname
, work
->ServerType
));
390 add_server_entry(d
,work
,myname
,work
->ServerType
|SV_TYPE_LOCAL_LIST_ONLY
,
391 0,lp_serverstring(),True
);
393 /* Count the number of servers we have on our list. If it's
394 less than 10 (just a heuristic) request the servers
395 to announce themselves.
397 for( sl
= work
->serverlist
; sl
!= NULL
; sl
= sl
->next
)
402 /* ask all servers on our local net to announce to us */
403 announce_request(work
, d
->bcast_ip
);
406 /* Reset the announce master timer so that we do an announce as soon as possible
407 now we are a master. */
408 reset_announce_timer();
410 DEBUG(0,("Samba is now a local master browser for workgroup %s on subnet %s\n",
411 work
->work_group
, inet_ntoa(d
->bcast_ip
)));
418 /* don't have to do anything: just report success */
419 DEBUG(3,("3rd stage: become master browser!\n"));
426 /*******************************************************************
427 become the domain master browser.
429 this is done in stages. note that this could take a while,
430 particularly on a broadcast subnet, as we have to wait for
431 the implicit registration of each name to be accepted.
433 as each name is successfully registered, become_domain_master() is
434 called again, in order to initiate the next stage. see
435 dead_netbios_entry() - deals with implicit name registration
436 and response_name_reg() - deals with explicit registration
439 stage 1: was DOMAIN_NONE - go to DOMAIN_MST
441 XXXX note: this code still does not cope with the distinction
442 between different types of nodes, particularly between M and P
443 nodes. that comes later.
445 ******************************************************************/
446 void become_domain_master(struct subnet_record
*d
, struct work_record
*work
)
448 /* domain type must be limited to domain enum + server type. it must
449 not have SV_TYPE_SERVER or anything else with SERVER in it, else
450 clients get confused and start thinking this entry is a server
454 if (!work
|| !d
) return;
456 if (!lp_domain_master())
458 DEBUG(0,("Samba not configured as a domain master browser.\n"));
462 DEBUG(2,("Becoming domain master for %s %s (currently at stage %d)\n",
463 work
->work_group
,inet_ntoa(d
->bcast_ip
),work
->dom_state
));
465 switch (work
->dom_state
)
467 case DOMAIN_NONE
: /* while we were nothing but a server... */
469 DEBUG(3,("become_domain_master: go to first stage: register <1b> name\n"));
470 work
->dom_state
= DOMAIN_WAIT
;
472 /* XXXX the 0x1b is domain master browser name */
473 add_my_name_entry(d
, work
->work_group
,0x1b,nb_type
|NB_ACTIVE
);
475 /* DON'T do anything else after calling add_my_name_entry() */
481 work
->dom_state
= DOMAIN_MST
; /* ... become domain master */
482 DEBUG(3,("become_domain_master: first stage - register as domain member\n"));
484 /* update our server status */
485 work
->ServerType
|= SV_TYPE_NT
|SV_TYPE_DOMAIN_MASTER
;
486 add_server_entry(d
,work
,myname
,work
->ServerType
|SV_TYPE_LOCAL_LIST_ONLY
,
487 0, lp_serverstring(),True
);
489 DEBUG(0,("Samba is now a domain master browser for workgroup %s on subnet %s\n",
490 work
->work_group
, inet_ntoa(d
->bcast_ip
)));
492 if (d
== wins_client_subnet
)
494 /* ok! we successfully registered by unicast with the
495 WINS server. we now expect to become the domain
496 master on the local subnets. if this fails, it's
497 probably a 1.9.16p2 to 1.9.16p11 server's fault.
499 this is a configuration issue that should be addressed
500 by the network administrator - you shouldn't have
501 several machines configured as a domain master browser
502 for the same WINS scope (except if they are 1.9.17 or
503 greater, and you know what you're doing.
508 add_domain_master_bcast();
515 /* don't have to do anything: just report success */
516 DEBUG(3,("domain second stage: there isn't one!\n"));
523 /*******************************************************************
524 become a logon server.
525 ******************************************************************/
526 void become_logon_server(struct subnet_record
*d
, struct work_record
*work
)
528 if (!work
|| !d
) return;
530 if (!lp_domain_logons())
532 DEBUG(0,("samba not configured as a logon master.\n"));
536 DEBUG(2,("Becoming logon server for %s %s (currently at stage %d)\n",
537 work
->work_group
,inet_ntoa(d
->bcast_ip
),work
->log_state
));
539 switch (work
->log_state
)
541 case LOGON_NONE
: /* while we were nothing but a server... */
543 DEBUG(3,("go to first stage: register <1c> name\n"));
544 work
->log_state
= LOGON_WAIT
;
546 /* XXXX the 0x1c is apparently something to do with domain logons */
547 add_my_name_entry(d
, myworkgroup
,0x1c,nb_type
|NB_ACTIVE
|NB_GROUP
);
549 /* DON'T do anything else after calling add_my_name_entry() */
555 work
->log_state
= LOGON_SRV
; /* ... become logon server */
556 DEBUG(3,("logon second stage: register \n"));
558 /* update our server status */
559 work
->ServerType
|= SV_TYPE_NT
|SV_TYPE_DOMAIN_MEMBER
;
560 add_server_entry(d
,work
,myname
,work
->ServerType
|SV_TYPE_LOCAL_LIST_ONLY
561 ,0, lp_serverstring(),True
);
563 /* DON'T do anything else after calling add_my_name_entry() */
569 DEBUG(3,("logon third stage: there isn't one!\n"));
576 /*******************************************************************
577 unbecome the local master browser. initates removal of necessary netbios
578 names, and tells the world that we are no longer a master browser.
580 XXXX this _should_ be used to demote to a backup master browser, without
581 going straight to non-master browser. another time.
583 ******************************************************************/
584 void unbecome_local_master(struct subnet_record
*d
, struct work_record
*work
,
587 int new_server_type
= work
->ServerType
;
589 /* can only remove master types with this function */
590 remove_type
&= SV_TYPE_MASTER_BROWSER
;
592 new_server_type
&= ~remove_type
;
596 DEBUG(2,("Becoming local non-master for %s\n",work
->work_group
));
598 /* no longer a master browser of any sort */
600 work
->ServerType
|= SV_TYPE_POTENTIAL_BROWSER
;
601 work
->ElectionCriterion
&= ~0x4;
602 work
->mst_state
= MST_POTENTIAL
;
604 /* announce ourselves as no longer active as a master browser. */
605 announce_server(d
, work
, work
->work_group
, myname
, 0, 0);
606 remove_name_entry(d
,MSBROWSE
,0x01);
607 remove_name_entry(d
,work
->work_group
,0x1d);
612 /*******************************************************************
613 unbecome the domain master browser. initates removal of necessary netbios
614 names, and tells the world that we are no longer a domain browser.
615 ******************************************************************/
616 void unbecome_domain_master(struct subnet_record
*d
, struct work_record
*work
,
619 int new_server_type
= work
->ServerType
;
621 DEBUG(2,("Becoming domain non-master for %s\n",work
->work_group
));
623 /* can only remove master or domain types with this function */
624 remove_type
&= SV_TYPE_DOMAIN_MASTER
;
626 new_server_type
&= ~remove_type
;
630 /* no longer a domain master browser of any sort */
632 work
->dom_state
= DOMAIN_NONE
;
634 /* announce ourselves as no longer active as a master browser on
635 all our local subnets. */
636 for (d
= FIRST_SUBNET
; d
; d
= NEXT_SUBNET_EXCLUDING_WINS(d
))
638 work
= find_workgroupstruct(d
, myworkgroup
, False
);
640 /* Remove the name entry without any NetBIOS traffic as that's
641 how it was registered. */
642 remove_name_entry(d
,work
->work_group
,0x1b);
645 /* Unregister the 1b name from the WINS server. */
646 if(wins_client_subnet
!= NULL
)
647 remove_name_entry(wins_client_subnet
, myworkgroup
, 0x1b);
652 /*******************************************************************
653 unbecome the logon server. initates removal of necessary netbios
654 names, and tells the world that we are no longer a logon server.
655 ******************************************************************/
656 void unbecome_logon_server(struct subnet_record
*d
, struct work_record
*work
,
659 int new_server_type
= work
->ServerType
;
661 DEBUG(2,("Becoming logon non-server for %s\n",work
->work_group
));
663 /* can only remove master or domain types with this function */
664 remove_type
&= SV_TYPE_DOMAIN_MEMBER
;
666 new_server_type
&= ~remove_type
;
670 /* no longer a master browser of any sort */
672 work
->log_state
= LOGON_NONE
;
674 remove_name_entry(d
,work
->work_group
,0x1c);
679 /*******************************************************************
681 ******************************************************************/
682 void run_elections(time_t t
)
684 static time_t lastime
= 0;
686 struct subnet_record
*d
;
688 /* send election packets once a second */
689 if (lastime
&& t
-lastime
<= 0) return;
693 for (d
= FIRST_SUBNET
; d
; d
= NEXT_SUBNET_EXCLUDING_WINS(d
))
695 struct work_record
*work
;
697 for (work
= d
->workgrouplist
; work
; work
= work
->next
)
699 if (work
->RunningElection
)
701 send_election(d
,work
->work_group
, work
->ElectionCriterion
,
702 t
-StartupTime
,myname
);
704 if (work
->ElectionCount
++ >= 4)
706 /* I won! now what :-) */
707 DEBUG(2,(">>> Won election on %s %s <<<\n",
708 work
->work_group
,inet_ntoa(d
->bcast_ip
)));
710 work
->RunningElection
= False
;
711 work
->mst_state
= MST_POTENTIAL
;
713 become_local_master(d
, work
);
721 /*******************************************************************
722 work out if I win an election
723 ******************************************************************/
724 static BOOL
win_election(struct work_record
*work
,int version
,uint32 criterion
,
725 int timeup
,char *name
)
727 int mytimeup
= time(NULL
) - StartupTime
;
728 uint32 mycriterion
= work
->ElectionCriterion
;
730 /* If local master is false then never win
731 in election broadcasts. */
732 if(!lp_local_master())
734 DEBUG(3,("win_election: Losing election as local master == False\n"));
738 DEBUG(4,("election comparison: %x:%x %x:%x %d:%d %s:%s\n",
739 version
,ELECTION_VERSION
,
740 criterion
,mycriterion
,
744 if (version
> ELECTION_VERSION
) return(False
);
745 if (version
< ELECTION_VERSION
) return(True
);
747 if (criterion
> mycriterion
) return(False
);
748 if (criterion
< mycriterion
) return(True
);
750 if (timeup
> mytimeup
) return(False
);
751 if (timeup
< mytimeup
) return(True
);
753 if (strcasecmp(myname
,name
) > 0) return(False
);
759 /*******************************************************************
760 process a election packet
762 An election dynamically decides who will be the master.
763 ******************************************************************/
764 void process_election(struct packet_struct
*p
,char *buf
)
766 struct dgram_packet
*dgram
= &p
->packet
.dgram
;
767 struct in_addr ip
= dgram
->header
.source_ip
;
768 struct subnet_record
*d
= find_subnet(ip
);
769 int version
= CVAL(buf
,0);
770 uint32 criterion
= IVAL(buf
,1);
771 int timeup
= IVAL(buf
,5)/1000;
773 struct work_record
*work
;
777 if (ip_equal(d
->bcast_ip
,wins_ip
))
779 DEBUG(0,("Unexpected election request from %s %s on WINS net\n",
780 name
, inet_ntoa(p
->ip
)));
786 DEBUG(3,("Election request from %s %s vers=%d criterion=%08x timeup=%d\n",
787 name
,inet_ntoa(p
->ip
),version
,criterion
,timeup
));
789 if (same_context(dgram
)) return;
791 for (work
= d
->workgrouplist
; work
; work
= work
->next
)
793 if (!strequal(work
->work_group
, myworkgroup
))
796 if (win_election(work
, version
,criterion
,timeup
,name
))
798 if (!work
->RunningElection
)
800 work
->needelection
= True
;
801 work
->ElectionCount
=0;
802 work
->mst_state
= MST_POTENTIAL
;
807 work
->needelection
= False
;
809 if (work
->RunningElection
|| AM_MASTER(work
))
811 work
->RunningElection
= False
;
812 DEBUG(3,(">>> Lost election on %s %s <<<\n",
813 work
->work_group
,inet_ntoa(d
->bcast_ip
)));
816 unbecome_local_master(d
, work
, SV_TYPE_MASTER_BROWSER
);
824 /****************************************************************************
825 checks whether a browser election is to be run on any workgroup
827 this function really ought to return the time between election
828 packets (which depends on whether samba intends to be a domain
829 master or a master browser) in milliseconds.
831 ***************************************************************************/
832 BOOL
check_elections(void)
834 struct subnet_record
*d
;
835 BOOL run_any_election
= False
;
837 for (d
= FIRST_SUBNET
; d
; d
= NEXT_SUBNET_EXCLUDING_WINS(d
))
839 struct work_record
*work
;
840 for (work
= d
->workgrouplist
; work
; work
= work
->next
)
842 run_any_election
|= work
->RunningElection
;
844 if (work
->needelection
&& !work
->RunningElection
)
846 DEBUG(3,(">>> Starting election on %s %s <<<\n",
847 work
->work_group
,inet_ntoa(d
->bcast_ip
)));
848 work
->ElectionCount
= 0;
849 work
->RunningElection
= True
;
850 work
->needelection
= False
;
854 return run_any_election
;