From 010c725b36feb1a234dce9f40b95ae5869058698 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 15 Apr 2006 04:07:10 +0000 Subject: 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. (This used to be commit 8272a5ab0605fcf95527143c4f909aa1008e5b94) --- source3/auth/auth_sam.c | 4 +--- source3/include/smb.h | 1 + source3/smbd/conn.c | 16 ++++++++++++---- source3/smbd/oplock.c | 18 +++--------------- source3/smbd/process.c | 4 ---- source3/smbd/service.c | 5 ++--- 6 files changed, 19 insertions(+), 29 deletions(-) diff --git a/source3/auth/auth_sam.c b/source3/auth/auth_sam.c index 740170d73d..94e4ec414b 100644 --- a/source3/auth/auth_sam.c +++ b/source3/auth/auth_sam.c @@ -23,8 +23,6 @@ #include "includes.h" -extern struct timeval smb_last_time; - #undef DBGC_CLASS #define DBGC_CLASS DBGC_AUTH @@ -87,7 +85,7 @@ static BOOL logon_hours_ok(struct samu *sampass) return True; } - lasttime = (time_t)smb_last_time.tv_sec; + lasttime = time(NULL); utctime = gmtime(&lasttime); /* find the corresponding byte and bit */ diff --git a/source3/include/smb.h b/source3/include/smb.h index be994a9fdd..f6ee429702 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -567,6 +567,7 @@ typedef struct connection_struct { NT_USER_TOKEN *nt_user_token; time_t lastused; + time_t lastused_count; BOOL used; int num_files_open; unsigned int num_smb_operations; /* Count of smb operations on this tree. */ diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c index b41467f02c..5aa8901d59 100644 --- a/source3/smbd/conn.c +++ b/source3/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)num_files_open > 0 || (t-conn->lastused) 0) { - wait_left = MIN(wait_left, 1000); - sys_usleep(wait_left * 1000); + if (wait_time) { + smb_msleep(wait_time); } } diff --git a/source3/smbd/process.c b/source3/smbd/process.c index ba14e57c54..aaf98203a2 100644 --- a/source3/smbd/process.c +++ b/source3/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/source3/smbd/service.c b/source3/smbd/service.c index 5c4974329c..ba87d0743d 100644 --- a/source3/smbd/service.c +++ b/source3/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); -- cgit