From: Jeremy Allison Date: Thu, 14 Apr 2005 23:32:56 +0000 (+0000) Subject: r6346: Add a counter for the number of SMB operations per connection/file. X-Git-Tag: samba-misc-tags/initial-v3-0-unstable~4939 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=743174da86ac724fc9ee3d4b7bd9a2a97a234bd8;p=thirdparty%2Fsamba.git r6346: Add a counter for the number of SMB operations per connection/file. You will need to do a make clean after SVN updating this. Next will come a smbcontrol message to dump this info. This should be interesting to profile client activity. Jeremy. --- diff --git a/source/include/smb.h b/source/include/smb.h index 80b20756517..f96d79fd063 100644 --- a/source/include/smb.h +++ b/source/include/smb.h @@ -412,6 +412,7 @@ typedef struct files_struct { int fnum; struct connection_struct *conn; int fd; + unsigned int num_smb_operations; uint16 rap_print_jobid; SMB_DEV_T dev; SMB_INO_T inode; @@ -533,6 +534,7 @@ typedef struct connection_struct time_t lastused; BOOL used; int num_files_open; + unsigned int num_smb_operations; /* Count of smb operations on this tree. */ BOOL case_sensitive; BOOL case_preserve; diff --git a/source/include/smb_macros.h b/source/include/smb_macros.h index ab4ee5ee73b..b7a3a68bec3 100644 --- a/source/include/smb_macros.h +++ b/source/include/smb_macros.h @@ -94,6 +94,7 @@ return(ERROR_DOS(ERRDOS,ERRbadfid)); \ else if((fsp)->fd == -1) \ return(ERROR_DOS(ERRDOS,ERRbadaccess));\ + (fsp)->num_smb_operations++;\ } while(0) #define CHECK_READ(fsp) if (!(fsp)->can_read) \ diff --git a/source/smbd/process.c b/source/smbd/process.c index 1bf6f4f9d14..e79686b43e2 100644 --- a/source/smbd/process.c +++ b/source/smbd/process.c @@ -962,8 +962,12 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize return(ERROR_DOS(ERRSRV,ERRaccess)); /* load service specific parameters */ - if (conn && !set_current_service(conn,SVAL(inbuf,smb_flg),(flags & (AS_USER|DO_CHDIR)?True:False))) - return(ERROR_DOS(ERRSRV,ERRaccess)); + if (conn) { + if (!set_current_service(conn,SVAL(inbuf,smb_flg),(flags & (AS_USER|DO_CHDIR)?True:False))) { + return(ERROR_DOS(ERRSRV,ERRaccess)); + } + conn->num_smb_operations++; + } /* does this protocol need to be run as guest? */ if ((flags & AS_GUEST) && (!change_to_guest() ||