summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1996-10-07 01:56:21 +0000
committerAndrew Tridgell <tridge@samba.org>1996-10-07 01:56:21 +0000
commit3cd7303dbc2118db7084a6d8872403d825c52323 (patch)
tree2e5f5839a4a6cff08c2078d46f6d8ff2463a5ba7
parent733c7186576c752edb07e9768f7902edc1cc5a42 (diff)
downloadsamba-3cd7303dbc2118db7084a6d8872403d825c52323.tar.gz
samba-3cd7303dbc2118db7084a6d8872403d825c52323.tar.xz
samba-3cd7303dbc2118db7084a6d8872403d825c52323.zip
- changed the default nmbd loop timout to 10 seconds (2 seconds was much
too short) - got rid of many unnecessary calls to time(NULL) in nmbd. They were causing it to chew too much CPU time when idle. Now we pass a time value in from the top level.
-rw-r--r--source/include/local.h2
-rw-r--r--source/include/proto.h20
-rw-r--r--source/nameannounce.c9
-rw-r--r--source/namebrowse.c3
-rw-r--r--source/namedbsubnet.c3
-rw-r--r--source/nameelect.c6
-rw-r--r--source/nameresp.c4
-rw-r--r--source/nameserv.c5
-rw-r--r--source/nmbd/nmbd.c25
9 files changed, 34 insertions, 43 deletions
diff --git a/source/include/local.h b/source/include/local.h
index 115617094c4..465e0029b6a 100644
--- a/source/include/local.h
+++ b/source/include/local.h
@@ -119,7 +119,7 @@
#define IDLE_CLOSED_TIMEOUT (60)
#define DPTR_IDLE_TIMEOUT (120)
#define SMBD_SELECT_LOOP (10)
-#define NMBD_SELECT_LOOP (2)
+#define NMBD_SELECT_LOOP (10)
#define BROWSE_INTERVAL (60)
#define REGISTRATION_INTERVAL (10*60)
#define NMBD_INETD_TIMEOUT (120)
diff --git a/source/include/proto.h b/source/include/proto.h
index 8c082a6140b..2c6047954ec 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -306,16 +306,16 @@ void do_announce_host(int command,
void remove_my_servers(void);
void announce_server(struct subnet_record *d, struct work_record *work,
char *name, char *comment, time_t ttl, int server_type);
-void announce_host(void);
-void announce_master(void);
-void announce_remote(void);
+void announce_host(time_t t);
+void announce_master(time_t t);
+void announce_remote(time_t t);
/*The following definitions come from namebrowse.c */
void expire_browse_cache(time_t t);
struct browse_cache_record *add_browser_entry(char *name, int type, char *wg,
time_t ttl, struct in_addr ip, BOOL local);
-void do_browser_lists(void);
+void do_browser_lists(time_t t);
/*The following definitions come from nameconf.c */
@@ -354,7 +354,7 @@ struct name_record *add_netbios_entry(struct subnet_record *d,
BOOL new_only,BOOL wins);
void expire_names(time_t t);
struct name_record *search_for_name(struct subnet_record **d,
- struct nmb_name *question,
+ struct nmb_name *question,
struct in_addr ip, int Time, int search);
/*The following definitions come from namedbresp.c */
@@ -393,7 +393,7 @@ void add_my_subnets(char *group);
struct subnet_record *add_subnet_entry(struct in_addr bcast_ip,
struct in_addr mask_ip,
char *name, BOOL add, BOOL lmhosts);
-void write_browse_list(void);
+void write_browse_list(time_t t);
/*The following definitions come from namedbwork.c */
@@ -406,7 +406,7 @@ void dump_workgroups(void);
/*The following definitions come from nameelect.c */
-void check_master_browser(void);
+void check_master_browser(time_t t);
void browser_gone(char *work_name, struct in_addr ip);
void send_election(struct subnet_record *d, char *group,uint32 criterion,
int timeup,char *name);
@@ -416,7 +416,7 @@ void name_register_work(struct subnet_record *d, char *name, int name_type,
void become_master(struct subnet_record *d, struct work_record *work);
void become_nonmaster(struct subnet_record *d, struct work_record *work,
int remove_type);
-void run_elections(void);
+void run_elections(time_t t);
void process_election(struct packet_struct *p,char *buf);
BOOL check_elections(void);
@@ -453,7 +453,7 @@ BOOL name_query(int fd,char *name,int name_type,
/*The following definitions come from nameresp.c */
-void expire_netbios_response_entries();
+void expire_netbios_response_entries(time_t t);
struct response_record *queue_netbios_pkt_wins(struct subnet_record *d,
int fd,int quest_type,enum state_type state,
char *name,int name_type,int nb_flags, time_t ttl,
@@ -474,7 +474,7 @@ void add_my_name_entry(struct subnet_record *d,char *name,int type,int nb_flags)
void add_my_names(void);
void remove_my_names();
void refresh_my_names(time_t t);
-void query_refresh_names(void);
+void query_refresh_names(time_t t);
/*The following definitions come from nameservreply.c */
diff --git a/source/nameannounce.c b/source/nameannounce.c
index fec88955108..1dadc0132c1 100644
--- a/source/nameannounce.c
+++ b/source/nameannounce.c
@@ -292,9 +292,8 @@ void announce_server(struct subnet_record *d, struct work_record *work,
/****************************************************************************
construct a host announcement unicast
**************************************************************************/
-void announce_host(void)
+void announce_host(time_t t)
{
- time_t t = time(NULL);
struct subnet_record *d;
pstring comment;
char *my_name;
@@ -368,11 +367,10 @@ void announce_host(void)
NAME_QUERY_DOM_SRV_CHK command, if there is a response from the
name query initiated here. see response_name_query()
**************************************************************************/
-void announce_master(void)
+void announce_master(time_t t)
{
struct subnet_record *d;
static time_t last=0;
- time_t t = time(NULL);
BOOL am_master = False; /* are we a master of some sort? :-) */
if (!last) last = t;
@@ -477,11 +475,10 @@ void announce_master(void)
on a remote browse list. They are done blind, no checking is done to
see if there is actually a browse master at the other end.
**************************************************************************/
-void announce_remote(void)
+void announce_remote(time_t t)
{
char *s,*ptr;
static time_t last_time = 0;
- time_t t = time(NULL);
pstring s2;
struct in_addr addr;
char *comment,*workgroup;
diff --git a/source/namebrowse.c b/source/namebrowse.c
index b426bc7a150..3bc4f9f82aa 100644
--- a/source/namebrowse.c
+++ b/source/namebrowse.c
@@ -190,11 +190,10 @@ static void start_sync_browse_entry(struct browse_cache_record *b)
/****************************************************************************
search through browser list for an entry to sync with
**************************************************************************/
-void do_browser_lists(void)
+void do_browser_lists(time_t t)
{
struct browse_cache_record *b;
static time_t last = 0;
- time_t t = time(NULL);
if (t-last < 20) return; /* don't do too many of these at once! */
/* XXXX equally this period should not be too long
diff --git a/source/namedbsubnet.c b/source/namedbsubnet.c
index 0bad79246ad..16eeb6322eb 100644
--- a/source/namedbsubnet.c
+++ b/source/namedbsubnet.c
@@ -252,14 +252,13 @@ struct subnet_record *add_subnet_entry(struct in_addr bcast_ip,
/*******************************************************************
write out browse.dat
******************************************************************/
-void write_browse_list(void)
+void write_browse_list(time_t t)
{
struct subnet_record *d;
pstring fname,fnamenew;
FILE *f;
static time_t lasttime = 0;
- time_t t = time(NULL);
if (!lasttime) lasttime = t;
if (!updatedlists || t - lasttime < 5) return;
diff --git a/source/nameelect.c b/source/nameelect.c
index be8a405daac..1c4f8e63900 100644
--- a/source/nameelect.c
+++ b/source/nameelect.c
@@ -54,10 +54,9 @@ extern uint16 nb_type; /* samba's NetBIOS name type */
/*******************************************************************
occasionally check to see if the master browser is around
******************************************************************/
-void check_master_browser(void)
+void check_master_browser(time_t t)
{
static time_t lastrun=0;
- time_t t = time(NULL);
struct subnet_record *d;
if (!lastrun) lastrun = t;
@@ -474,9 +473,8 @@ void become_nonmaster(struct subnet_record *d, struct work_record *work,
/*******************************************************************
run the election
******************************************************************/
-void run_elections(void)
+void run_elections(time_t t)
{
- time_t t = time(NULL);
static time_t lastime = 0;
struct subnet_record *d;
diff --git a/source/nameresp.c b/source/nameresp.c
index 7fcb41e79f0..2a8c5e88b04 100644
--- a/source/nameresp.c
+++ b/source/nameresp.c
@@ -174,7 +174,7 @@ static void dead_netbios_entry(struct subnet_record *d,
see name_query() and name_status() for suggested implementation.
******************************************************************/
-void expire_netbios_response_entries()
+void expire_netbios_response_entries(time_t t)
{
struct subnet_record *d;
@@ -186,7 +186,7 @@ void expire_netbios_response_entries()
{
nextn = n->next;
- if (n->repeat_time <= time(NULL))
+ if (n->repeat_time <= t)
{
if (n->repeat_count > 0)
{
diff --git a/source/nameserv.c b/source/nameserv.c
index c8bbb528116..7353251940c 100644
--- a/source/nameserv.c
+++ b/source/nameserv.c
@@ -240,7 +240,7 @@ void refresh_my_names(time_t t)
for (n = d->namelist; n; n = n->next)
{
/* each SELF name has an individual time to be refreshed */
- if (n->source == SELF && n->refresh_time < time(NULL) &&
+ if (n->source == SELF && n->refresh_time < t &&
n->death_time != 0)
{
add_my_name_entry(d,n->name.name,n->name.name_type,
@@ -263,13 +263,12 @@ void refresh_my_names(time_t t)
XXXX which names to poll and which not can be refined at a later date.
******************************************************************/
-void query_refresh_names(void)
+void query_refresh_names(time_t t)
{
struct name_record *n;
struct subnet_record *d = find_subnet(ipgrp);
static time_t lasttime = 0;
- time_t t = time(NULL);
int count = 0;
int name_refresh_time = NAME_POLL_REFRESH_TIME;
diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c
index 5b3fd19491d..d8865662c72 100644
--- a/source/nmbd/nmbd.c
+++ b/source/nmbd/nmbd.c
@@ -159,10 +159,9 @@ static void fault_continue(void)
/*******************************************************************
expire old names from the namelist and server list
******************************************************************/
-static void expire_names_and_servers(void)
+static void expire_names_and_servers(time_t t)
{
static time_t lastrun = 0;
- time_t t = time(NULL);
if (!lastrun) lastrun = t;
if (t < lastrun + 5) return;
@@ -298,23 +297,23 @@ static void process(void)
listen_for_packets(run_election);
run_packet_queue();
- run_elections();
+ run_elections(t);
- announce_host();
+ announce_host(t);
- announce_master();
+ announce_master(t);
- announce_remote();
+ announce_remote(t);
- query_refresh_names();
+ query_refresh_names(t);
- expire_names_and_servers();
- expire_netbios_response_entries();
+ expire_names_and_servers(t);
+ expire_netbios_response_entries(t);
refresh_my_names(t);
- write_browse_list();
- do_browser_lists();
- check_master_browser();
+ write_browse_list(t);
+ do_browser_lists(t);
+ check_master_browser(t);
}
}
@@ -528,7 +527,7 @@ static void usage(char *pname)
DEBUG(3,("Loaded names\n"));
- write_browse_list();
+ write_browse_list(time(NULL));
DEBUG(3,("Dumped names\n"));