summaryrefslogtreecommitdiffstats
path: root/source/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-04-15 04:07:10 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:16:22 -0500
commit8272a5ab0605fcf95527143c4f909aa1008e5b94 (patch)
tree35cc5a4d18f42122598b87afd5fe9e795808dae7 /source/smbd
parent77fb19c45dcb07f5b675831979fbd74a99e30638 (diff)
downloadsamba-8272a5ab0605fcf95527143c4f909aa1008e5b94.tar.gz
samba-8272a5ab0605fcf95527143c4f909aa1008e5b94.tar.xz
samba-8272a5ab0605fcf95527143c4f909aa1008e5b94.zip
r15088: Remove all time() and gettimeofday() calls out of the mainline
packet processing code. Only do these when needed (ie. in the idle timeout code). We drop an unneccessary global here too. Jeremy.
Diffstat (limited to 'source/smbd')
-rw-r--r--source/smbd/conn.c16
-rw-r--r--source/smbd/oplock.c18
-rw-r--r--source/smbd/process.c4
-rw-r--r--source/smbd/service.c5
4 files changed, 17 insertions, 26 deletions
diff --git a/source/smbd/conn.c b/source/smbd/conn.c
index b41467f02c7..5aa8901d597 100644
--- a/source/smbd/conn.c
+++ b/source/smbd/conn.c
@@ -154,8 +154,9 @@ find_again:
}
/****************************************************************************
-close all conn structures
+ Close all conn structures.
****************************************************************************/
+
void conn_close_all(void)
{
connection_struct *conn, *next;
@@ -178,13 +179,20 @@ BOOL conn_idle_all(time_t t, int deadtime)
for (conn=Connections;conn;conn=next) {
next=conn->next;
+
+ /* Update if connection wasn't idle. */
+ if (conn->lastused != conn->lastused_count) {
+ conn->lastused = t;
+ }
+
/* close dirptrs on connections that are idle */
- if ((t-conn->lastused) > DPTR_IDLE_TIMEOUT)
+ if ((t-conn->lastused) > DPTR_IDLE_TIMEOUT) {
dptr_idlecnum(conn);
+ }
- if (conn->num_files_open > 0 ||
- (t-conn->lastused)<deadtime)
+ if (conn->num_files_open > 0 || (t-conn->lastused)<deadtime) {
allidle = False;
+ }
}
/*
diff --git a/source/smbd/oplock.c b/source/smbd/oplock.c
index 61e812d43a8..70e5bf4d727 100644
--- a/source/smbd/oplock.c
+++ b/source/smbd/oplock.c
@@ -27,7 +27,6 @@ static int32 exclusive_oplocks_open = 0;
static int32 level_II_oplocks_open = 0;
BOOL global_client_failed_oplock_break = False;
-extern struct timeval smb_last_time;
extern uint32 global_client_caps;
extern int smb_read_error;
@@ -277,21 +276,10 @@ static char *new_break_smb_message(TALLOC_CTX *mem_ctx,
static void wait_before_sending_break(void)
{
- struct timeval cur_tv;
- long wait_left = (long)lp_oplock_break_wait_time();
+ long wait_time = (long)lp_oplock_break_wait_time();
- if (wait_left == 0) {
- return;
- }
-
- GetTimeOfDay(&cur_tv);
-
- wait_left -= ((cur_tv.tv_sec - smb_last_time.tv_sec)*1000) +
- ((cur_tv.tv_usec - smb_last_time.tv_usec)/1000);
-
- if(wait_left > 0) {
- wait_left = MIN(wait_left, 1000);
- sys_usleep(wait_left * 1000);
+ if (wait_time) {
+ smb_msleep(wait_time);
}
}
diff --git a/source/smbd/process.c b/source/smbd/process.c
index ba14e57c54a..aaf98203a25 100644
--- a/source/smbd/process.c
+++ b/source/smbd/process.c
@@ -26,8 +26,6 @@ extern int keepalive;
extern struct auth_context *negprot_global_auth_context;
extern int smb_echo_count;
-struct timeval smb_last_time;
-
static char *InBuffer = NULL;
static char *OutBuffer = NULL;
static char *current_inbuf = NULL;
@@ -1011,8 +1009,6 @@ static int construct_reply(char *inbuf,char *outbuf,int size,int bufsize)
int outsize = 0;
int msg_type = CVAL(inbuf,0);
- GetTimeOfDay(&smb_last_time);
-
chain_size = 0;
file_chain_reset();
reset_chain_p();
diff --git a/source/smbd/service.c b/source/smbd/service.c
index 5c4974329c7..ba87d0743da 100644
--- a/source/smbd/service.c
+++ b/source/smbd/service.c
@@ -20,7 +20,6 @@
#include "includes.h"
-extern struct timeval smb_last_time;
extern userdom_struct current_user_info;
/****************************************************************************
@@ -140,7 +139,7 @@ BOOL set_current_service(connection_struct *conn, uint16 flags, BOOL do_chdir)
return(False);
}
- conn->lastused = smb_last_time.tv_sec;
+ conn->lastused_count++;
snum = SNUM(conn);
@@ -601,7 +600,7 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
safe_strcpy(conn->client_address, client_addr(),
sizeof(conn->client_address)-1);
conn->num_files_open = 0;
- conn->lastused = time(NULL);
+ conn->lastused = conn->lastused_count = time(NULL);
conn->service = snum;
conn->used = True;
conn->printer = (strncmp(dev,"LPT",3) == 0);