Revert "TODO: nmbd... (doesn't compile yet)"
authorStefan Metzmacher <metze@samba.org>
Thu, 22 Sep 2016 16:00:17 +0000 (18:00 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 4 Oct 2016 12:52:07 +0000 (14:52 +0200)
This reverts commit 2404b4d2528fedbbb662efa7719f4d150b0cf44f.

source3/nmbd/nmbd.c
source3/nmbd/nmbd_packets.c

index 41bd6daeae404f85710638d474389599ca4d21af..14eaef647d0c4c46e9eff46f93805bbf506315c6 100644 (file)
@@ -35,8 +35,6 @@ int global_nmb_port = -1;
 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? */
@@ -500,250 +498,202 @@ static void msg_nmbd_send_packet(struct messaging_context *msg,
        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);
index fe21a6b509c0f9b179818c8aca282488c681febf..de5ae1efef1434508b79cad6f55e4050408878f7 100644 (file)
@@ -29,6 +29,8 @@ extern int ClientNMB;
 extern int ClientDGRAM;
 extern int global_nmb_port;
 
+extern int num_response_packets;
+
 bool rescan_listen_set = False;
 
 static struct nb_packet_server *packet_server;