extern bool rescan_listen_set;
extern bool global_in_nmbd;
-extern int num_response_packets;
-
extern bool override_logfile;
/* have we found LanMan clients yet? */
send_packet(p);
}
-static bool nmbd_periodic_processing(time_t t)
+/**************************************************************************** **
+ The main select loop.
+ **************************************************************************** */
+
+static void process(struct messaging_context *msg)
{
bool run_election;
- /*
- * Check all broadcast subnets to see if
- * we need to run an election on any of them.
- * (nmbd_elections.c)
- */
-
- run_election = check_elections();
-
- /*
- * Read incoming UDP packets.
- * (nmbd_packets.c)
- */
-
- if (listen_for_packets(msg, run_election)) {
- return run_election;
- }
-
- /*
- * Process all incoming packets
- * read above. This calls the success and
- * failure functions registered when response
- * packets arrrive, and also deals with request
- * packets from other sources.
- * (nmbd_packets.c)
- */
-
- run_packet_queue();
-
- /*
- * Run any elections - initiate becoming
- * a local master browser if we have won.
- * (nmbd_elections.c)
- */
-
- run_elections(t);
-
- /*
- * Send out any broadcast announcements
- * of our server names. This also announces
- * the workgroup name if we are a local
- * master browser.
- * (nmbd_sendannounce.c)
- */
-
- announce_my_server_names(t);
-
- /*
- * Send out any LanMan broadcast announcements
- * of our server names.
- * (nmbd_sendannounce.c)
- */
+ while( True ) {
+ time_t t = time(NULL);
+ TALLOC_CTX *frame = talloc_stackframe();
- announce_my_lm_server_names(t);
+ /*
+ * Check all broadcast subnets to see if
+ * we need to run an election on any of them.
+ * (nmbd_elections.c)
+ */
- /*
- * If we are a local master browser, periodically
- * announce ourselves to the domain master browser.
- * This also deals with syncronising the domain master
- * browser server lists with ourselves as a local
- * master browser.
- * (nmbd_sendannounce.c)
- */
+ run_election = check_elections();
- announce_myself_to_domain_master_browser(t);
+ /*
+ * Read incoming UDP packets.
+ * (nmbd_packets.c)
+ */
- /*
- * Fullfill any remote announce requests.
- * (nmbd_sendannounce.c)
- */
+ if (listen_for_packets(msg, run_election)) {
+ TALLOC_FREE(frame);
+ return;
+ }
- announce_remote(t);
+ /*
+ * Process all incoming packets
+ * read above. This calls the success and
+ * failure functions registered when response
+ * packets arrrive, and also deals with request
+ * packets from other sources.
+ * (nmbd_packets.c)
+ */
- /*
- * Fullfill any remote browse sync announce requests.
- * (nmbd_sendannounce.c)
- */
+ run_packet_queue();
- browse_sync_remote(t);
+ /*
+ * Run any elections - initiate becoming
+ * a local master browser if we have won.
+ * (nmbd_elections.c)
+ */
- /*
- * Scan the broadcast subnets, and WINS client
- * namelists and refresh any that need refreshing.
- * (nmbd_mynames.c)
- */
+ run_elections(t);
- refresh_my_names(t);
+ /*
+ * Send out any broadcast announcements
+ * of our server names. This also announces
+ * the workgroup name if we are a local
+ * master browser.
+ * (nmbd_sendannounce.c)
+ */
- /*
- * Scan the subnet namelists and server lists and
- * expire thos that have timed out.
- * (nmbd.c)
- */
+ announce_my_server_names(t);
- expire_names_and_servers(t);
+ /*
+ * Send out any LanMan broadcast announcements
+ * of our server names.
+ * (nmbd_sendannounce.c)
+ */
- /*
- * Write out a snapshot of our current browse list into
- * the browse.dat file. This is used by smbd to service
- * incoming NetServerEnum calls - used to synchronise
- * browse lists over subnets.
- * (nmbd_serverlistdb.c)
- */
+ announce_my_lm_server_names(t);
- write_browse_list(t, False);
+ /*
+ * If we are a local master browser, periodically
+ * announce ourselves to the domain master browser.
+ * This also deals with syncronising the domain master
+ * browser server lists with ourselves as a local
+ * master browser.
+ * (nmbd_sendannounce.c)
+ */
- /*
- * If we are a domain master browser, we have a list of
- * local master browsers we should synchronise browse
- * lists with (these are added by an incoming local
- * master browser announcement packet). Expire any of
- * these that are no longer current, and pull the server
- * lists from each of these known local master browsers.
- * (nmbd_browsesync.c)
- */
+ announce_myself_to_domain_master_browser(t);
- dmb_expire_and_sync_browser_lists(t);
+ /*
+ * Fullfill any remote announce requests.
+ * (nmbd_sendannounce.c)
+ */
- /*
- * Check that there is a local master browser for our
- * workgroup for all our broadcast subnets. If one
- * is not found, start an election (which we ourselves
- * may or may not participate in, depending on the
- * setting of the 'local master' parameter.
- * (nmbd_elections.c)
- */
+ announce_remote(t);
- check_master_browser_exists(t);
+ /*
+ * Fullfill any remote browse sync announce requests.
+ * (nmbd_sendannounce.c)
+ */
- /*
- * If we are configured as a logon server, attempt to
- * register the special NetBIOS names to become such
- * (WORKGROUP<1c> name) on all broadcast subnets and
- * with the WINS server (if used). If we are configured
- * to become a domain master browser, attempt to register
- * the special NetBIOS name (WORKGROUP<1b> name) to
- * become such.
- * (nmbd_become_dmb.c)
- */
+ browse_sync_remote(t);
- add_domain_names(t);
+ /*
+ * Scan the broadcast subnets, and WINS client
+ * namelists and refresh any that need refreshing.
+ * (nmbd_mynames.c)
+ */
- /*
- * If we are a WINS server, do any timer dependent
- * processing required.
- * (nmbd_winsserver.c)
- */
+ refresh_my_names(t);
- initiate_wins_processing(t);
+ /*
+ * Scan the subnet namelists and server lists and
+ * expire thos that have timed out.
+ * (nmbd.c)
+ */
- /*
- * If we are a domain master browser, attempt to contact the
- * WINS server to get a list of all known WORKGROUPS/DOMAINS.
- * This will only work to a Samba WINS server.
- * (nmbd_browsesync.c)
- */
+ expire_names_and_servers(t);
- if (lp_enhanced_browsing())
- collect_all_workgroup_names_from_wins_server(t);
+ /*
+ * Write out a snapshot of our current browse list into
+ * the browse.dat file. This is used by smbd to service
+ * incoming NetServerEnum calls - used to synchronise
+ * browse lists over subnets.
+ * (nmbd_serverlistdb.c)
+ */
- /*
- * Go through the response record queue and time out or re-transmit
- * and expired entries.
- * (nmbd_packets.c)
- */
+ write_browse_list(t, False);
- retransmit_or_expire_response_records(t);
+ /*
+ * If we are a domain master browser, we have a list of
+ * local master browsers we should synchronise browse
+ * lists with (these are added by an incoming local
+ * master browser announcement packet). Expire any of
+ * these that are no longer current, and pull the server
+ * lists from each of these known local master browsers.
+ * (nmbd_browsesync.c)
+ */
- /*
- * check to see if any remote browse sync child processes have completed
- */
+ dmb_expire_and_sync_browser_lists(t);
- sync_check_completion();
+ /*
+ * Check that there is a local master browser for our
+ * workgroup for all our broadcast subnets. If one
+ * is not found, start an election (which we ourselves
+ * may or may not participate in, depending on the
+ * setting of the 'local master' parameter.
+ * (nmbd_elections.c)
+ */
- /*
- * regularly sync with any other DMBs we know about
- */
+ check_master_browser_exists(t);
- if (lp_enhanced_browsing())
- sync_all_dmbs(t);
+ /*
+ * If we are configured as a logon server, attempt to
+ * register the special NetBIOS names to become such
+ * (WORKGROUP<1c> name) on all broadcast subnets and
+ * with the WINS server (if used). If we are configured
+ * to become a domain master browser, attempt to register
+ * the special NetBIOS name (WORKGROUP<1b> name) to
+ * become such.
+ * (nmbd_become_dmb.c)
+ */
- /* check for new network interfaces */
+ add_domain_names(t);
- reload_interfaces(t);
+ /*
+ * If we are a WINS server, do any timer dependent
+ * processing required.
+ * (nmbd_winsserver.c)
+ */
- return run_election;
-}
+ initiate_wins_processing(t);
+ /*
+ * If we are a domain master browser, attempt to contact the
+ * WINS server to get a list of all known WORKGROUPS/DOMAINS.
+ * This will only work to a Samba WINS server.
+ * (nmbd_browsesync.c)
+ */
-static void nmbd_periodic_timer_event(struct tevent_context *ev,
- struct tevent_timer *te,
- struct timeval current_time,
- void *private_data)
-{
- time_t t = current_time.tv_sec;
- struct timeval next;
- bool run_elections;
+ if (lp_enhanced_browsing())
+ collect_all_workgroup_names_from_wins_server(t);
- run_elections = nmbd_periodic_processing(t);
+ /*
+ * Go through the response record queue and time out or re-transmit
+ * and expired entries.
+ * (nmbd_packets.c)
+ */
- if (run_election || num_response_packets) {
- next = timeval_current_ofs_msec(1000);
- } else {
- next = timeval_current_ofs_msec(NMBD_SELECT_LOOP * 1000);
- }
+ retransmit_or_expire_response_records(t);
- te = tevent_add_timer(nmbd_event_context(),
- msg,
- next,
- nmbd_periodic_timer_event,
- NULL);
- if (te == NULL) {
+ /*
+ * check to see if any remote browse sync child processes have completed
+ */
- }
-}
-/**************************************************************************** **
- The main select loop.
- **************************************************************************** */
+ sync_check_completion();
-static void process(struct messaging_context *msg)
-{
- struct tevent_timer *te = NULL;
-
-static void nmbd_periodic_timer_event(struct tevent_context *ev,
- struct tevent_timer *te,
- struct timeval current_time,
- void *private_data);
- te = tevent_add_timer(nmbd_event_context(),
- msg,
- timeval_current(),
- nmbd_periodic_timer_event,
- NULL);
- if (te == NULL) {
+ /*
+ * regularly sync with any other DMBs we know about
+ */
- }
+ if (lp_enhanced_browsing())
+ sync_all_dmbs(t);
- while( True ) {
- time_t t = time(NULL);
- TALLOC_CTX *frame = talloc_stackframe();
+ /* check for new network interfaces */
- nmbd_periodic_processing(t);
+ reload_interfaces(t);
/* free up temp memory */
TALLOC_FREE(frame);