svn commit: samba r15089 - in trunk/source: auth include smbd

jra at samba.org jra at samba.org
Sat Apr 15 04:07:16 GMT 2006


Author: jra
Date: 2006-04-15 04:07:14 +0000 (Sat, 15 Apr 2006)
New Revision: 15089

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15089

Log:
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.

Modified:
   trunk/source/auth/auth_sam.c
   trunk/source/include/smb.h
   trunk/source/smbd/conn.c
   trunk/source/smbd/oplock.c
   trunk/source/smbd/process.c
   trunk/source/smbd/service.c


Changeset:
Modified: trunk/source/auth/auth_sam.c
===================================================================
--- trunk/source/auth/auth_sam.c	2006-04-15 04:07:10 UTC (rev 15088)
+++ trunk/source/auth/auth_sam.c	2006-04-15 04:07:14 UTC (rev 15089)
@@ -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 @@
 		return True;
 	}
 
-	lasttime = (time_t)smb_last_time.tv_sec;
+	lasttime = time(NULL);
 	utctime = gmtime(&lasttime);
 
 	/* find the corresponding byte and bit */

Modified: trunk/source/include/smb.h
===================================================================
--- trunk/source/include/smb.h	2006-04-15 04:07:10 UTC (rev 15088)
+++ trunk/source/include/smb.h	2006-04-15 04:07:14 UTC (rev 15089)
@@ -569,6 +569,7 @@
 	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. */

Modified: trunk/source/smbd/conn.c
===================================================================
--- trunk/source/smbd/conn.c	2006-04-15 04:07:10 UTC (rev 15088)
+++ trunk/source/smbd/conn.c	2006-04-15 04:07:14 UTC (rev 15089)
@@ -154,8 +154,9 @@
 }
 
 /****************************************************************************
-close all conn structures
+ Close all conn structures.
 ****************************************************************************/
+
 void conn_close_all(void)
 {
 	connection_struct *conn, *next;
@@ -178,13 +179,20 @@
 
 	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;
+		}
 	}
 
 	/*

Modified: trunk/source/smbd/oplock.c
===================================================================
--- trunk/source/smbd/oplock.c	2006-04-15 04:07:10 UTC (rev 15088)
+++ trunk/source/smbd/oplock.c	2006-04-15 04:07:14 UTC (rev 15089)
@@ -27,7 +27,6 @@
 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,22 +276,11 @@
 
 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;
+	if (wait_time) {
+		smb_msleep(wait_time);
 	}
-
-	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);
-	}
 }
 
 /****************************************************************************

Modified: trunk/source/smbd/process.c
===================================================================
--- trunk/source/smbd/process.c	2006-04-15 04:07:10 UTC (rev 15088)
+++ trunk/source/smbd/process.c	2006-04-15 04:07:14 UTC (rev 15089)
@@ -26,8 +26,6 @@
 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 @@
 	int outsize = 0;
 	int msg_type = CVAL(inbuf,0);
 
-	GetTimeOfDay(&smb_last_time);
-
 	chain_size = 0;
 	file_chain_reset();
 	reset_chain_p();

Modified: trunk/source/smbd/service.c
===================================================================
--- trunk/source/smbd/service.c	2006-04-15 04:07:10 UTC (rev 15088)
+++ trunk/source/smbd/service.c	2006-04-15 04:07:14 UTC (rev 15089)
@@ -20,7 +20,6 @@
 
 #include "includes.h"
 
-extern struct timeval smb_last_time;
 extern userdom_struct current_user_info;
 
 /****************************************************************************
@@ -140,7 +139,7 @@
 		return(False);
 	}
 
-	conn->lastused = smb_last_time.tv_sec;
+	conn->lastused_count++;
 
 	snum = SNUM(conn);
   
@@ -601,7 +600,7 @@
 	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);



More information about the samba-cvs mailing list