summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorHerb Lewis <herb@samba.org>2000-10-11 05:31:39 +0000
committerHerb Lewis <herb@samba.org>2000-10-11 05:31:39 +0000
commit8719c27726d3412edd0781beb956f48f76a62fb6 (patch)
tree4946f7b6d6159eb566ff279d9ccba1f6d901e0e1 /source3
parentc72f94dad9639bc241890aad338ae0bea8eed84d (diff)
downloadsamba-8719c27726d3412edd0781beb956f48f76a62fb6.tar.gz
samba-8719c27726d3412edd0781beb956f48f76a62fb6.tar.bz2
samba-8719c27726d3412edd0781beb956f48f76a62fb6.zip
changes to sync with 2.2. tree
.cvsignore remove config.h - not in this directory include/profile.h profile changes lib/messages.c added message to return debug level libsmb/clierror.c cast to get rid of compiler warning libsmb/smbencrypt.c cast to get rid of compiler warning profile/profile.c add flush profile stats changes for profile struct rpc_parse/parse_samr.c fix for compiler warning rpc_server/srv_samr.c cast to get rid of compiler warning smbd/ipc.c profile stats message.c profile stats smbd/negprot.c profile stats smbd/nttrans.c profile stats smbd/trans2.c profile stats utils/smbcontrol.c new flush stats command (This used to be commit bbb24daa25dca4e4b6b1f8942cd84ee3aa1bed8e)
Diffstat (limited to 'source3')
-rw-r--r--source3/.cvsignore1
-rw-r--r--source3/include/profile.h38
-rw-r--r--source3/lib/messages.c12
-rw-r--r--source3/libsmb/clierror.c2
-rw-r--r--source3/libsmb/smbencrypt.c2
-rw-r--r--source3/profile/profile.c29
-rw-r--r--source3/rpc_parse/parse_samr.c1
-rw-r--r--source3/rpc_server/srv_samr.c4
-rw-r--r--source3/smbd/ipc.c14
-rw-r--r--source3/smbd/message.c24
-rw-r--r--source3/smbd/negprot.c2
-rw-r--r--source3/smbd/nttrans.c66
-rw-r--r--source3/smbd/trans2.c47
-rw-r--r--source3/utils/smbcontrol.c10
14 files changed, 205 insertions, 47 deletions
diff --git a/source3/.cvsignore b/source3/.cvsignore
index 30ba04b6d0..ef9ea858b5 100644
--- a/source3/.cvsignore
+++ b/source3/.cvsignore
@@ -1,7 +1,6 @@
bin
Makefile
config.cache
-config.h
config.log
config.status
cvs.log
diff --git a/source3/include/profile.h b/source3/include/profile.h
index c196a63c62..b05e1fd9bb 100644
--- a/source3/include/profile.h
+++ b/source3/include/profile.h
@@ -35,13 +35,11 @@ enum flush_reason_enum { SEEK_FLUSH, READ_FLUSH, WRITE_FLUSH, READRAW_FLUSH,
#define PROF_SHMEM_KEY ((key_t)0x07021999)
#define PROF_SHM_MAGIC 0x6349985
-#define PROF_SHM_VERSION 2
+#define PROF_SHM_VERSION 3
-/* time values in the following structure are in milliseconds */
+/* time values in the following structure are in microseconds */
-struct profile_struct {
- int prof_shm_magic;
- int prof_shm_version;
+struct profile_stats {
/* general counters */
unsigned smb_count; /* how many SMB packets we have processed */
unsigned uid_changes; /* how many times we change our effective uid */
@@ -314,10 +312,18 @@ struct profile_struct {
unsigned NT_transact_query_security_desc_time;
};
+struct profile_header {
+ int prof_shm_magic;
+ int prof_shm_version;
+ struct profile_stats stats;
+};
-extern struct profile_struct *profile_p;
+extern struct profile_header *profile_h;
+extern struct profile_stats *profile_p;
extern struct timeval profile_starttime;
extern struct timeval profile_endtime;
+extern struct timeval profile_starttime_nested;
+extern struct timeval profile_endtime_nested;
extern BOOL do_profile_flag;
extern BOOL do_profile_times;
@@ -328,7 +334,12 @@ extern BOOL do_profile_times;
#define INC_PROFILE_COUNT(x) profile_p->x++
#define DEC_PROFILE_COUNT(x) profile_p->x--
#define ADD_PROFILE_COUNT(x,y) profile_p->x += (y)
-#define PROFILE_TIME TvalDiff(&profile_starttime,&profile_endtime)
+#define PROFILE_TIME \
+ ((profile_endtime.tv_sec - profile_starttime.tv_sec) *1000000 + \
+ ((int)profile_endtime.tv_usec - (int)profile_starttime.tv_usec))
+#define PROFILE_TIME_NESTED \
+ ((profile_endtime_nested.tv_sec - profile_starttime_nested.tv_sec) *1000000 + \
+ ((int)profile_endtime_nested.tv_usec - (int)profile_starttime_nested.tv_usec))
#ifdef WITH_PROFILE
#define DO_PROFILE_INC(x) \
@@ -354,6 +365,12 @@ extern BOOL do_profile_times;
GetTimeOfDay(&profile_starttime); \
INC_PROFILE_COUNT(x##_count); \
}
+#define START_PROFILE_NESTED(x) \
+ if (do_profile_flag) { \
+ if (do_profile_times) \
+ GetTimeOfDay(&profile_starttime_nested); \
+ INC_PROFILE_COUNT(x##_count); \
+ }
#define START_PROFILE_BYTES(x,n) \
if (do_profile_flag) { \
if (do_profile_times) \
@@ -366,14 +383,21 @@ extern BOOL do_profile_times;
GetTimeOfDay(&profile_endtime); \
ADD_PROFILE_COUNT(x##_time,PROFILE_TIME); \
}
+#define END_PROFILE_NESTED(x) \
+ if (do_profile_times) { \
+ GetTimeOfDay(&profile_endtime_nested); \
+ ADD_PROFILE_COUNT(x##_time,PROFILE_TIME_NESTED); \
+ }
#else
#define DO_PROFILE_INC(x)
#define DO_PROFILE_DEC(x)
#define DO_PROFILE_DEC_INC(x,y)
#define DO_PROFILE_ADD(x,n)
#define START_PROFILE(x)
+#define START_PROFILE_NESTED(x)
#define START_PROFILE_BYTES(x,n)
#define END_PROFILE(x)
+#define END_PROFILE_NESTED(x)
#endif
#endif
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 258610f409..1b225b1ed3 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -74,6 +74,17 @@ void ping_message(int msg_type, pid_t src, void *buf, size_t len)
}
/****************************************************************************
+return current debug level
+****************************************************************************/
+void debuglevel_message(int msg_type, pid_t src, void *buf, size_t len)
+{
+ int level;
+
+ level = DEBUGLEVEL;
+ message_send_pid(src, MSG_DEBUGLEVEL, &level, sizeof(int));
+}
+
+/****************************************************************************
Initialise the messaging functions.
****************************************************************************/
BOOL message_init(void)
@@ -92,6 +103,7 @@ BOOL message_init(void)
CatchSignal(SIGUSR1, SIGNAL_CAST sig_usr1);
message_register(MSG_PING, ping_message);
+ message_register(MSG_REQ_DEBUGLEVEL, debuglevel_message);
return True;
}
diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c
index 66bf83cfc5..4c6d9a49f2 100644
--- a/source3/libsmb/clierror.c
+++ b/source3/libsmb/clierror.c
@@ -96,7 +96,7 @@ char *cli_errstr(struct cli_state *cli)
if (nt_rpc_error)
{
- char *nt_msg = get_nt_error_msg(nt_rpc_error);
+ char *nt_msg = (char *)get_nt_error_msg(nt_rpc_error);
if (nt_msg == NULL)
{
diff --git a/source3/libsmb/smbencrypt.c b/source3/libsmb/smbencrypt.c
index 16f2493947..371e279ffd 100644
--- a/source3/libsmb/smbencrypt.c
+++ b/source3/libsmb/smbencrypt.c
@@ -255,7 +255,7 @@ BOOL decode_pw_buffer(const char buffer[516], char *new_pwrd,
dump_data(100, buffer, 516);
#endif
- if ((*new_pw_len) < 0 || (*new_pw_len) > new_pwrd_size - 1) {
+ if (((int)*new_pw_len) < 0 || (*new_pw_len) > new_pwrd_size - 1) {
DEBUG(0, ("decode_pw_buffer: incorrect password length (%d).\n", (*new_pw_len)));
return False;
}
diff --git a/source3/profile/profile.c b/source3/profile/profile.c
index 87f5e2c9b2..c639f17ce5 100644
--- a/source3/profile/profile.c
+++ b/source3/profile/profile.c
@@ -31,13 +31,16 @@ extern int DEBUGLEVEL;
static int shm_id;
static BOOL read_only;
-struct profile_struct *profile_p;
+struct profile_header *profile_h;
+struct profile_stats *profile_p;
BOOL do_profile_flag = False;
BOOL do_profile_times = False;
struct timeval profile_starttime;
struct timeval profile_endtime;
+struct timeval profile_starttime_nested;
+struct timeval profile_endtime_nested;
/****************************************************************************
receive a set profile level message
@@ -48,18 +51,21 @@ void profile_message(int msg_type, pid_t src, void *buf, size_t len)
memcpy(&level, buf, sizeof(int));
switch (level) {
- case 0:
+ case 0: /* turn off profiling */
do_profile_flag = False;
do_profile_times = False;
break;
- case 1:
+ case 1: /* turn on counter profiling only */
do_profile_flag = True;
do_profile_times = False;
break;
- case 2:
+ case 2: /* turn on complete profiling */
do_profile_flag = True;
do_profile_times = True;
break;
+ case 3: /* reset profile values */
+ memset((char *)profile_p, 0, sizeof(*profile_p));
+ break;
}
DEBUG(1,("Profile level set to %d from pid %d\n", level, (int)src));
}
@@ -81,7 +87,7 @@ BOOL profile_setup(BOOL rdonly)
if we are running from inetd. Bad luck. */
if (shm_id == -1) {
if (read_only) return False;
- shm_id = shmget(PROF_SHMEM_KEY, sizeof(*profile_p),
+ shm_id = shmget(PROF_SHMEM_KEY, sizeof(*profile_h),
IPC_CREAT | IPC_EXCL | IPC_PERMS);
}
@@ -92,7 +98,7 @@ BOOL profile_setup(BOOL rdonly)
}
- profile_p = (struct profile_struct *)shmat(shm_id, 0,
+ profile_h = (struct profile_header *)shmat(shm_id, 0,
read_only?SHM_RDONLY:0);
if ((long)profile_p == -1) {
DEBUG(0,("Can't attach to IPC area. Error was %s\n",
@@ -112,9 +118,9 @@ BOOL profile_setup(BOOL rdonly)
return False;
}
- if (shm_ds.shm_segsz != sizeof(*profile_p)) {
+ if (shm_ds.shm_segsz != sizeof(*profile_h)) {
DEBUG(0,("WARNING: profile size is %d (expected %d). Deleting\n",
- (int)shm_ds.shm_segsz, sizeof(*profile_p)));
+ (int)shm_ds.shm_segsz, sizeof(*profile_h)));
if (shmctl(shm_id, IPC_RMID, &shm_ds) == 0) {
goto again;
} else {
@@ -123,12 +129,13 @@ BOOL profile_setup(BOOL rdonly)
}
if (!read_only && (shm_ds.shm_nattch == 1)) {
- memset((char *)profile_p, 0, sizeof(*profile_p));
- profile_p->prof_shm_magic = PROF_SHM_MAGIC;
- profile_p->prof_shm_version = PROF_SHM_VERSION;
+ memset((char *)profile_h, 0, sizeof(*profile_h));
+ profile_h->prof_shm_magic = PROF_SHM_MAGIC;
+ profile_h->prof_shm_version = PROF_SHM_VERSION;
DEBUG(3,("Initialised profile area\n"));
}
+ profile_p = &profile_h->stats;
message_register(MSG_PROFILE, profile_message);
return True;
}
diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
index a2dda316f2..af205441f6 100644
--- a/source3/rpc_parse/parse_samr.c
+++ b/source3/rpc_parse/parse_samr.c
@@ -4368,7 +4368,6 @@ static BOOL samr_io_userinfo_ctr(char *desc, SAM_USERINFO_CTR *ctr, prs_struct *
default:
DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
return False;
- break;
}
diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c
index 1d2626f8fe..84ac1ae004 100644
--- a/source3/rpc_server/srv_samr.c
+++ b/source3/rpc_server/srv_samr.c
@@ -2337,7 +2337,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid)
copy_sam_passwd(&new_pwd, pwd);
copy_id23_to_sam_passwd(&new_pwd, id23);
- if (!decode_pw_buffer(id23->pass, buf, 256, &len))
+ if (!decode_pw_buffer((const char *)id23->pass, buf, 256, &len))
return False;
nt_lm_owf_gen(buf, nt_hash, lm_hash);
@@ -2376,7 +2376,7 @@ static BOOL set_user_info_24(const SAM_USER_INFO_24 *id24, uint32 rid)
pdb_init_sam(&new_pwd);
copy_sam_passwd(&new_pwd, pwd);
- if (!decode_pw_buffer(id24->pass, buf, 256, &len))
+ if (!decode_pw_buffer((const char *)id24->pass, buf, 256, &len))
return False;
nt_lm_owf_gen(buf, nt_hash, lm_hash);
diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c
index a8c1502e94..5ade667209 100644
--- a/source3/smbd/ipc.c
+++ b/source3/smbd/ipc.c
@@ -374,6 +374,7 @@ int reply_trans(connection_struct *conn, char *inbuf,char *outbuf, int size, int
int dscnt = SVAL(inbuf,smb_vwv11);
int dsoff = SVAL(inbuf,smb_vwv12);
int suwcnt = CVAL(inbuf,smb_vwv13);
+ START_PROFILE(SMBtrans);
memset(name, '\0',sizeof(name));
fstrcpy(name,smb_buf(inbuf));
@@ -385,6 +386,7 @@ int reply_trans(connection_struct *conn, char *inbuf,char *outbuf, int size, int
if (tdscnt) {
if((data = (char *)malloc(tdscnt)) == NULL) {
DEBUG(0,("reply_trans: data malloc fail for %d bytes !\n", tdscnt));
+ END_PROFILE(SMBtrans);
return(ERROR(ERRDOS,ERRnomem));
}
memcpy(data,smb_base(inbuf)+dsoff,dscnt);
@@ -393,6 +395,7 @@ int reply_trans(connection_struct *conn, char *inbuf,char *outbuf, int size, int
if (tpscnt) {
if((params = (char *)malloc(tpscnt)) == NULL) {
DEBUG(0,("reply_trans: param malloc fail for %d bytes !\n", tpscnt));
+ END_PROFILE(SMBtrans);
return(ERROR(ERRDOS,ERRnomem));
}
memcpy(params,smb_base(inbuf)+psoff,pscnt);
@@ -402,6 +405,7 @@ int reply_trans(connection_struct *conn, char *inbuf,char *outbuf, int size, int
int i;
if((setup = (uint16 *)malloc(suwcnt*sizeof(uint16))) == NULL) {
DEBUG(0,("reply_trans: setup malloc fail for %d bytes !\n", (int)(suwcnt * sizeof(uint16))));
+ END_PROFILE(SMBtrans);
return(ERROR(ERRDOS,ERRnomem));
}
for (i=0;i<suwcnt;i++)
@@ -437,6 +441,7 @@ int reply_trans(connection_struct *conn, char *inbuf,char *outbuf, int size, int
free(data);
if (setup)
free(setup);
+ END_PROFILE(SMBtrans);
return(ERROR(ERRSRV,ERRerror));
}
@@ -499,12 +504,17 @@ int reply_trans(connection_struct *conn, char *inbuf,char *outbuf, int size, int
if (close_on_completion)
close_cnum(conn,vuid);
- if (one_way)
+ if (one_way) {
+ END_PROFILE(SMBtrans);
return(-1);
+ }
- if (outsize == 0)
+ if (outsize == 0) {
+ END_PROFILE(SMBtrans);
return(ERROR(ERRSRV,ERRnosupport));
+ }
+ END_PROFILE(SMBtrans);
return(outsize);
}
#undef OLD_NTDOMAIN
diff --git a/source3/smbd/message.c b/source3/smbd/message.c
index a65539affa..ab3c841d9c 100644
--- a/source3/smbd/message.c
+++ b/source3/smbd/message.c
@@ -111,11 +111,14 @@ int reply_sends(connection_struct *conn,
int len;
char *orig,*dest,*msg;
int outsize = 0;
+ START_PROFILE(SMBsends);
msgpos = 0;
- if (! (*lp_msg_command()))
+ if (! (*lp_msg_command())) {
+ END_PROFILE(SMBsends);
return(ERROR(ERRSRV,ERRmsgoff));
+ }
outsize = set_message(outbuf,0,0,True);
@@ -138,6 +141,7 @@ int reply_sends(connection_struct *conn,
msg_deliver();
+ END_PROFILE(SMBsends);
return(outsize);
}
@@ -150,9 +154,12 @@ int reply_sendstrt(connection_struct *conn,
{
char *orig,*dest;
int outsize = 0;
+ START_PROFILE(SMBsendstrt);
- if (! (*lp_msg_command()))
+ if (! (*lp_msg_command())) {
+ END_PROFILE(SMBsendstrt);
return(ERROR(ERRSRV,ERRmsgoff));
+ }
outsize = set_message(outbuf,1,0,True);
@@ -167,6 +174,7 @@ int reply_sendstrt(connection_struct *conn,
DEBUG( 3, ( "SMBsendstrt (from %s to %s)\n", msgfrom, msgto ) );
+ END_PROFILE(SMBsendstrt);
return(outsize);
}
@@ -180,9 +188,12 @@ int reply_sendtxt(connection_struct *conn,
int len;
int outsize = 0;
char *msg;
+ START_PROFILE(SMBsendtxt);
- if (! (*lp_msg_command()))
+ if (! (*lp_msg_command())) {
+ END_PROFILE(SMBsendtxt);
return(ERROR(ERRSRV,ERRmsgoff));
+ }
outsize = set_message(outbuf,0,0,True);
@@ -196,6 +207,7 @@ int reply_sendtxt(connection_struct *conn,
DEBUG( 3, ( "SMBsendtxt\n" ) );
+ END_PROFILE(SMBsendtxt);
return(outsize);
}
@@ -207,9 +219,12 @@ int reply_sendend(connection_struct *conn,
char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int outsize = 0;
+ START_PROFILE(SMBsendend);
- if (! (*lp_msg_command()))
+ if (! (*lp_msg_command())) {
+ END_PROFILE(SMBsendend);
return(ERROR(ERRSRV,ERRmsgoff));
+ }
outsize = set_message(outbuf,0,0,True);
@@ -217,6 +232,7 @@ int reply_sendend(connection_struct *conn,
msg_deliver();
+ END_PROFILE(SMBsendend);
return(outsize);
}
diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c
index 362d571ff1..1029c8db62 100644
--- a/source3/smbd/negprot.c
+++ b/source3/smbd/negprot.c
@@ -340,6 +340,7 @@ int reply_negprot(connection_struct *conn,
char *p;
int bcc = SVAL(smb_buf(inbuf),-2);
int arch = ARCH_ALL;
+ START_PROFILE(SMBnegprot);
p = smb_buf(inbuf)+1;
while (p < (smb_buf(inbuf) + bcc))
@@ -437,6 +438,7 @@ int reply_negprot(connection_struct *conn,
DEBUG( 5, ( "negprot index=%d\n", choice ) );
+ END_PROFILE(SMBnegprot);
return(outsize);
}
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index f099583e55..67f1a1bc9e 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -650,6 +650,7 @@ static int do_ntcreate_pipe_open(connection_struct *conn,
int reply_ntcreate_and_X(connection_struct *conn,
char *inbuf,char *outbuf,int length,int bufsize)
{
+ int result;
pstring fname;
uint32 flags = IVAL(inbuf,smb_ntcreate_Flags);
uint32 desired_access = IVAL(inbuf,smb_ntcreate_DesiredAccess);
@@ -675,14 +676,18 @@ int reply_ntcreate_and_X(connection_struct *conn,
files_struct *fsp=NULL;
char *p = NULL;
BOOL stat_open_only = False;
+ START_PROFILE(SMBntcreateX);
/* If it's an IPC, use the pipe handler. */
if (IS_IPC(conn)) {
- if (lp_nt_pipe_support())
+ if (lp_nt_pipe_support()) {
+ END_PROFILE(SMBntcreateX);
return do_ntcreate_pipe_open(conn,inbuf,outbuf,length,bufsize);
- else
+ } else {
+ END_PROFILE(SMBntcreateX);
return(ERROR(ERRDOS,ERRbadaccess));
+ }
}
@@ -691,8 +696,10 @@ int reply_ntcreate_and_X(connection_struct *conn,
* NT values, as that's what our code is structured to accept.
*/
- if((smb_ofun = map_create_disposition( create_disposition )) == -1)
+ if((smb_ofun = map_create_disposition( create_disposition )) == -1) {
+ END_PROFILE(SMBntcreateX);
return(ERROR(ERRDOS,ERRbadaccess));
+ }
/*
* Get the file name.
@@ -705,8 +712,10 @@ int reply_ntcreate_and_X(connection_struct *conn,
files_struct *dir_fsp = file_fsp(inbuf,smb_ntcreate_RootDirectoryFid);
size_t dir_name_len;
- if(!dir_fsp)
+ if(!dir_fsp) {
+ END_PROFILE(SMBntcreateX);
return(ERROR(ERRDOS,ERRbadfid));
+ }
if(!dir_fsp->is_directory) {
/*
@@ -718,8 +727,10 @@ int reply_ntcreate_and_X(connection_struct *conn,
if( fname[0] == ':') {
SSVAL(outbuf, smb_flg2, FLAGS2_32_BIT_ERROR_CODES);
+ END_PROFILE(SMBntcreateX);
return(ERROR(0, NT_STATUS_OBJECT_PATH_NOT_FOUND));
}
+ END_PROFILE(SMBntcreateX);
return(ERROR(ERRDOS,ERRbadfid));
}
@@ -744,8 +755,10 @@ int reply_ntcreate_and_X(connection_struct *conn,
* with the Win2k unicode bug, but that would be rare. JRA.
*/
- if(fname_len + dir_name_len >= sizeof(pstring))
+ if(fname_len + dir_name_len >= sizeof(pstring)) {
+ END_PROFILE(SMBntcreateX);
return(ERROR(ERRSRV,ERRfilespecs));
+ }
get_filename(&fname[dir_name_len], inbuf, smb_buf(inbuf)-inbuf,
smb_buflen(inbuf),fname_len);
@@ -764,8 +777,10 @@ int reply_ntcreate_and_X(connection_struct *conn,
if((smb_open_mode = map_share_mode(&stat_open_only, fname, desired_access,
share_access,
- file_attributes)) == -1)
+ file_attributes)) == -1) {
+ END_PROFILE(SMBntcreateX);
return(ERROR(ERRDOS,ERRbadaccess));
+ }
oplock_request = (flags & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0;
oplock_request |= (flags & REQUEST_BATCH_OPLOCK) ? BATCH_OPLOCK : 0;
@@ -800,6 +815,7 @@ int reply_ntcreate_and_X(connection_struct *conn,
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadpath;
}
+ END_PROFILE(SMBntcreateX);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
} else {
@@ -852,6 +868,7 @@ int reply_ntcreate_and_X(connection_struct *conn,
if (create_options & FILE_NON_DIRECTORY_FILE) {
restore_case_semantics(file_attributes);
SSVAL(outbuf, smb_flg2, FLAGS2_32_BIT_ERROR_CODES);
+ END_PROFILE(SMBntcreateX);
return(ERROR(0, NT_STATUS_FILE_IS_A_DIRECTORY));
}
@@ -864,6 +881,7 @@ int reply_ntcreate_and_X(connection_struct *conn,
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadpath;
}
+ END_PROFILE(SMBntcreateX);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
#ifdef EROFS
@@ -882,6 +900,7 @@ int reply_ntcreate_and_X(connection_struct *conn,
if(!fsp) {
restore_case_semantics(file_attributes);
+ END_PROFILE(SMBntcreateX);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
@@ -894,6 +913,7 @@ int reply_ntcreate_and_X(connection_struct *conn,
restore_case_semantics(file_attributes);
+ END_PROFILE(SMBntcreateX);
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
}
@@ -903,12 +923,14 @@ int reply_ntcreate_and_X(connection_struct *conn,
if(conn->vfs_ops.stat(conn,dos_to_unix(fsp->fsp_name, False), &sbuf) != 0) {
close_file(fsp,True);
restore_case_semantics(file_attributes);
+ END_PROFILE(SMBntcreateX);
return(ERROR(ERRDOS,ERRnoaccess));
}
} else {
if (conn->vfs_ops.fstat(fsp,fsp->fd,&sbuf) != 0) {
close_file(fsp,False);
restore_case_semantics(file_attributes);
+ END_PROFILE(SMBntcreateX);
return(ERROR(ERRDOS,ERRnoaccess));
}
}
@@ -921,6 +943,7 @@ int reply_ntcreate_and_X(connection_struct *conn,
fmode = FILE_ATTRIBUTE_NORMAL;
if (!fsp->is_directory && (fmode & aDIR)) {
close_file(fsp,False);
+ END_PROFILE(SMBntcreateX);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -977,7 +1000,9 @@ int reply_ntcreate_and_X(connection_struct *conn,
DEBUG(5,("reply_ntcreate_and_X: fnum = %d, open name = %s\n", fsp->fnum, fsp->fsp_name));
- return chain_reply(inbuf,outbuf,length,bufsize);
+ result = chain_reply(inbuf,outbuf,length,bufsize);
+ END_PROFILE(SMBntcreateX);
+ return result;
}
/****************************************************************************
@@ -1403,11 +1428,13 @@ int reply_ntcancel(connection_struct *conn,
*/
int mid = SVAL(inbuf,smb_mid);
+ START_PROFILE(SMBntcancel);
remove_pending_change_notify_requests_by_mid(mid);
remove_pending_lock_requests_by_mid(mid);
DEBUG(3,("reply_ntcancel: cancel called on mid = %d.\n", mid));
+ END_PROFILE(SMBntcancel);
return(-1);
}
@@ -1417,7 +1444,9 @@ int reply_ntcancel(connection_struct *conn,
int reply_nttranss(connection_struct *conn,
char *inbuf,char *outbuf,int length,int bufsize)
{
+ START_PROFILE(SMBnttranss);
DEBUG(4,("Ignoring nttranss of length %d\n",length));
+ END_PROFILE(SMBnttranss);
return(-1);
}
@@ -1729,6 +1758,7 @@ int reply_nttrans(connection_struct *conn,
uint16 function_code = SVAL( inbuf, smb_nt_Function);
char *params = NULL, *data = NULL, *setup = NULL;
uint32 num_params_sofar, num_data_sofar;
+ START_PROFILE(SMBnttrans);
if(global_oplock_break && (function_code == NT_TRANSACT_CREATE)) {
/*
@@ -1739,11 +1769,14 @@ int reply_nttrans(connection_struct *conn,
due to being in oplock break state.\n" ));
push_oplock_pending_smb_message( inbuf, length);
+ END_PROFILE(SMBnttrans);
return -1;
}
- if (IS_IPC(conn) && (function_code != NT_TRANSACT_CREATE))
+ if (IS_IPC(conn) && (function_code != NT_TRANSACT_CREATE)) {
+ END_PROFILE(SMBnttrans);
return (ERROR(ERRSRV,ERRaccess));
+ }
outsize = set_message(outbuf,0,0,True);
@@ -1755,6 +1788,7 @@ due to being in oplock break state.\n" ));
if(CVAL(inbuf, smb_wct) != 19 + (setup_count/2)) {
DEBUG(2,("Invalid smb_wct %d in nttrans call (should be %d)\n",
CVAL(inbuf, smb_wct), 19 + (setup_count/2)));
+ END_PROFILE(SMBnttrans);
return(ERROR(ERRSRV,ERRerror));
}
@@ -1770,6 +1804,7 @@ due to being in oplock break state.\n" ));
if ((total_parameter_count && !params) || (total_data_count && !data) ||
(setup_count && !setup)) {
DEBUG(0,("reply_nttrans : Out of memory\n"));
+ END_PROFILE(SMBnttrans);
return(ERROR(ERRDOS,ERRnomem));
}
@@ -1822,6 +1857,7 @@ due to being in oplock break state.\n" ));
free(data);
if(setup)
free(setup);
+ END_PROFILE(SMBnttrans);
return(ERROR(ERRSRV,ERRerror));
}
@@ -1848,34 +1884,46 @@ due to being in oplock break state.\n" ));
/* Now we must call the relevant NT_TRANS function */
switch(function_code) {
case NT_TRANSACT_CREATE:
+ START_PROFILE_NESTED(NT_transact_create);
outsize = call_nt_transact_create(conn, inbuf, outbuf, length, bufsize,
&setup, &params, &data);
+ END_PROFILE_NESTED(NT_transact_create);
break;
case NT_TRANSACT_IOCTL:
+ START_PROFILE_NESTED(NT_transact_ioctl);
outsize = call_nt_transact_ioctl(conn,
inbuf, outbuf, length, bufsize,
&setup, &params, &data);
+ END_PROFILE_NESTED(NT_transact_ioctl);
break;
case NT_TRANSACT_SET_SECURITY_DESC:
+ START_PROFILE_NESTED(NT_transact_set_security_desc);
outsize = call_nt_transact_set_security_desc(conn, inbuf, outbuf,
length, bufsize,
&setup, &params, &data);
+ END_PROFILE_NESTED(NT_transact_set_security_desc);
break;
case NT_TRANSACT_NOTIFY_CHANGE:
+ START_PROFILE_NESTED(NT_transact_notify_change);
outsize = call_nt_transact_notify_change(conn, inbuf, outbuf,
length, bufsize,
&setup, &params, &data);
+ END_PROFILE_NESTED(NT_transact_notify_change);
break;
case NT_TRANSACT_RENAME:
+ START_PROFILE_NESTED(NT_transact_rename);
outsize = call_nt_transact_rename(conn, inbuf, outbuf, length,
bufsize,
&setup, &params, &data);
+ END_PROFILE_NESTED(NT_transact_rename);
break;
case NT_TRANSACT_QUERY_SECURITY_DESC:
+ START_PROFILE_NESTED(NT_transact_query_security_desc);
outsize = call_nt_transact_query_security_desc(conn, inbuf, outbuf,
length, bufsize,
&setup, &params, &data);
+ END_PROFILE_NESTED(NT_transact_query_security_desc);
break;
default:
/* Error in request */
@@ -1886,6 +1934,7 @@ due to being in oplock break state.\n" ));
free(params);
if(data)
free(data);
+ END_PROFILE(SMBnttrans);
return (ERROR(ERRSRV,ERRerror));
}
@@ -1902,6 +1951,7 @@ due to being in oplock break state.\n" ));
free(params);
if(data)
free(data);
+ END_PROFILE(SMBnttrans);
return outsize; /* If a correct response was needed the call_nt_transact_xxxx
calls have already sent it. If outsize != -1 then it is
returning an error packet. */
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 7df1c09fa0..7e2c25109a 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -2158,6 +2158,7 @@ int reply_findclose(connection_struct *conn,
{
int outsize = 0;
int dptr_num=SVALS(inbuf,smb_vwv0);
+ START_PROFILE(SMBfindclose);
DEBUG(3,("reply_findclose, dptr_num = %d\n", dptr_num));
@@ -2167,6 +2168,7 @@ int reply_findclose(connection_struct *conn,
DEBUG(3,("SMBfindclose dptr_num = %d\n", dptr_num));
+ END_PROFILE(SMBfindclose);
return(outsize);
}
@@ -2178,6 +2180,7 @@ int reply_findnclose(connection_struct *conn,
{
int outsize = 0;
int dptr_num= -1;
+ START_PROFILE(SMBfindnclose);
dptr_num = SVAL(inbuf,smb_vwv0);
@@ -2191,6 +2194,7 @@ int reply_findnclose(connection_struct *conn,
DEBUG(3,("SMB_findnclose dptr_num = %d\n", dptr_num));
+ END_PROFILE(SMBfindnclose);
return(outsize);
}
@@ -2201,7 +2205,9 @@ int reply_findnclose(connection_struct *conn,
int reply_transs2(connection_struct *conn,
char *inbuf,char *outbuf,int length,int bufsize)
{
+ START_PROFILE(SMBtranss2);
DEBUG(4,("Ignoring transs2 of length %d\n",length));
+ END_PROFILE(SMBtranss2);
return(-1);
}
@@ -2226,6 +2232,7 @@ int reply_trans2(connection_struct *conn,
unsigned int tran_call = SVAL(inbuf, smb_setup0);
char *params = NULL, *data = NULL;
int num_params, num_params_sofar, num_data, num_data_sofar;
+ START_PROFILE(SMBtrans2);
if(global_oplock_break && (tran_call == TRANSACT2_OPEN)) {
/* Queue this open message as we are the process of an
@@ -2235,12 +2242,15 @@ int reply_trans2(connection_struct *conn,
DEBUGADD(2,( "in oplock break state.\n"));
push_oplock_pending_smb_message(inbuf, length);
+ END_PROFILE(SMBtrans2);
return -1;
}
if (IS_IPC(conn) && (tran_call != TRANSACT2_OPEN)
- && (tran_call != TRANSACT2_GET_DFS_REFERRAL))
+ && (tran_call != TRANSACT2_GET_DFS_REFERRAL)) {
+ END_PROFILE(SMBtrans2);
return(ERROR(ERRSRV,ERRaccess));
+ }
outsize = set_message(outbuf,0,0,True);
@@ -2248,6 +2258,7 @@ int reply_trans2(connection_struct *conn,
is so as a sanity check */
if (suwcnt != 1) {
DEBUG(2,("Invalid smb_sucnt in trans2 call\n"));
+ END_PROFILE(SMBtrans2);
return(ERROR(ERRSRV,ERRerror));
}
@@ -2259,10 +2270,11 @@ int reply_trans2(connection_struct *conn,
if ((total_params && !params) || (total_data && !data)) {
DEBUG(2,("Out of memory in reply_trans2\n"));
- if(params)
- free(params);
- if(data)
- free(data);
+ if(params)
+ free(params);
+ if(data)
+ free(data);
+ END_PROFILE(SMBtrans2);
return(ERROR(ERRDOS,ERRnomem));
}
@@ -2303,6 +2315,7 @@ int reply_trans2(connection_struct *conn,
free(params);
if(data)
free(data);
+ END_PROFILE(SMBtrans2);
return(ERROR(ERRSRV,ERRerror));
}
@@ -2330,67 +2343,89 @@ int reply_trans2(connection_struct *conn,
/* Now we must call the relevant TRANS2 function */
switch(tran_call) {
case TRANSACT2_OPEN:
+ START_PROFILE_NESTED(Trans2_open);
outsize = call_trans2open(conn,
inbuf, outbuf, bufsize,
&params, &data);
+ END_PROFILE_NESTED(Trans2_open);
break;
case TRANSACT2_FINDFIRST:
+ START_PROFILE_NESTED(Trans2_findfirst);
outsize = call_trans2findfirst(conn, inbuf, outbuf,
bufsize, &params, &data);
+ END_PROFILE_NESTED(Trans2_findfirst);
break;
case TRANSACT2_FINDNEXT:
+ START_PROFILE_NESTED(Trans2_findnext);
outsize = call_trans2findnext(conn, inbuf, outbuf,
length, bufsize,
&params, &data);
+ END_PROFILE_NESTED(Trans2_findnext);
break;
case TRANSACT2_QFSINFO:
+ START_PROFILE_NESTED(Trans2_qfsinfo);
outsize = call_trans2qfsinfo(conn, inbuf, outbuf,
length, bufsize, &params,
&data);
+ END_PROFILE_NESTED(Trans2_qfsinfo);
break;
case TRANSACT2_SETFSINFO:
+ START_PROFILE_NESTED(Trans2_setfsinfo);
outsize = call_trans2setfsinfo(conn, inbuf, outbuf,
length, bufsize,
&params, &data);
+ END_PROFILE_NESTED(Trans2_setfsinfo);
break;
case TRANSACT2_QPATHINFO:
case TRANSACT2_QFILEINFO:
+ START_PROFILE_NESTED(Trans2_qpathinfo);
outsize = call_trans2qfilepathinfo(conn, inbuf, outbuf,
length, bufsize,
&params, &data, total_data);
+ END_PROFILE_NESTED(Trans2_qpathinfo);
break;
case TRANSACT2_SETPATHINFO:
case TRANSACT2_SETFILEINFO:
+ START_PROFILE_NESTED(Trans2_setpathinfo);
outsize = call_trans2setfilepathinfo(conn, inbuf, outbuf,
length, bufsize,
&params, &data,
total_data);
+ END_PROFILE_NESTED(Trans2_setpathinfo);
break;
case TRANSACT2_FINDNOTIFYFIRST:
+ START_PROFILE_NESTED(Trans2_findnotifyfirst);
outsize = call_trans2findnotifyfirst(conn, inbuf, outbuf,
length, bufsize,
&params, &data);
+ END_PROFILE_NESTED(Trans2_findnotifyfirst);
break;
case TRANSACT2_FINDNOTIFYNEXT:
+ START_PROFILE_NESTED(Trans2_findnotifynext);
outsize = call_trans2findnotifynext(conn, inbuf, outbuf,
length, bufsize,
&params, &data);
+ END_PROFILE_NESTED(Trans2_findnotifynext);
break;
case TRANSACT2_MKDIR:
+ START_PROFILE_NESTED(Trans2_mkdir);
outsize = call_trans2mkdir(conn, inbuf, outbuf, length,
bufsize, &params, &data);
+ END_PROFILE_NESTED(Trans2_mkdir);
break;
case TRANSACT2_GET_DFS_REFERRAL:
+ START_PROFILE_NESTED(Trans2_get_dfs_referral);
outsize = call_trans2getdfsreferral(conn,inbuf,outbuf,length,
bufsize, &params, &data);
+ END_PROFILE_NESTED(Trans2_get_dfs_referral);
break;
default:
/* Error in request */
@@ -2399,6 +2434,7 @@ int reply_trans2(connection_struct *conn,
free(params);
if(data)
free(data);
+ END_PROFILE(SMBtrans2);
return (ERROR(ERRSRV,ERRerror));
}
@@ -2413,6 +2449,7 @@ int reply_trans2(connection_struct *conn,
free(params);
if(data)
free(data);
+ END_PROFILE(SMBtrans2);
return outsize; /* If a correct response was needed the
call_trans2xxx calls have already sent
it. If outsize != -1 then it is returning */
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 62019d4036..3d17ec1123 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -148,15 +148,17 @@ static BOOL do_command(char *dest, char *msg_name, char *params)
fprintf(stderr,"MSG_PROFILE needs a parameter\n");
return(False);
}
- if (strequal(params, "on")) {
- v = 2;
- } else if (strequal(params, "off")) {
+ if (strequal(params, "off")) {
v = 0;
} else if (strequal(params, "count")) {
v = 1;
+ } else if (strequal(params, "on")) {
+ v = 2;
+ } else if (strequal(params, "flush")) {
+ v = 3;
} else {
fprintf(stderr,
- "MSG_PROFILE parameter must be on, off, or count\n");
+ "MSG_PROFILE parameter must be off, count, on, or flush\n");
return(False);
}
send_message(dest, MSG_PROFILE, &v, sizeof(int));