diff --git a/source/.cvsignore b/source/.cvsignore index 30ba04b6d01..ef9ea858b51 100644 --- a/source/.cvsignore +++ b/source/.cvsignore @@ -1,7 +1,6 @@ bin Makefile config.cache -config.h config.log config.status cvs.log diff --git a/source/include/profile.h b/source/include/profile.h index c196a63c62f..b05e1fd9bbf 100644 --- a/source/include/profile.h +++ b/source/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/source/lib/messages.c b/source/lib/messages.c index 258610f409a..1b225b1ed30 100644 --- a/source/lib/messages.c +++ b/source/lib/messages.c @@ -73,6 +73,17 @@ void ping_message(int msg_type, pid_t src, void *buf, size_t len) message_send_pid(src, MSG_PONG, buf, 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. ****************************************************************************/ @@ -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/source/libsmb/clierror.c b/source/libsmb/clierror.c index 66bf83cfc57..4c6d9a49f23 100644 --- a/source/libsmb/clierror.c +++ b/source/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/source/libsmb/smbencrypt.c b/source/libsmb/smbencrypt.c index 16f24939471..371e279ffde 100644 --- a/source/libsmb/smbencrypt.c +++ b/source/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/source/profile/profile.c b/source/profile/profile.c index 87f5e2c9b22..c639f17ce50 100644 --- a/source/profile/profile.c +++ b/source/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/source/rpc_parse/parse_samr.c b/source/rpc_parse/parse_samr.c index a2dda316f22..af205441f6a 100644 --- a/source/rpc_parse/parse_samr.c +++ b/source/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/source/rpc_server/srv_samr.c b/source/rpc_server/srv_samr.c index 1d2626f8fef..84ac1ae004b 100644 --- a/source/rpc_server/srv_samr.c +++ b/source/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/source/smbd/ipc.c b/source/smbd/ipc.c index a8c1502e944..5ade6672093 100644 --- a/source/smbd/ipc.c +++ b/source/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;iis_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, ¶ms, &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, ¶ms, &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, ¶ms, &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, ¶ms, &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, ¶ms, &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, ¶ms, &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/source/smbd/trans2.c b/source/smbd/trans2.c index 7df1c09fa00..7e2c25109a7 100644 --- a/source/smbd/trans2.c +++ b/source/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, ¶ms, &data); + END_PROFILE_NESTED(Trans2_open); break; case TRANSACT2_FINDFIRST: + START_PROFILE_NESTED(Trans2_findfirst); outsize = call_trans2findfirst(conn, inbuf, outbuf, bufsize, ¶ms, &data); + END_PROFILE_NESTED(Trans2_findfirst); break; case TRANSACT2_FINDNEXT: + START_PROFILE_NESTED(Trans2_findnext); outsize = call_trans2findnext(conn, inbuf, outbuf, length, bufsize, ¶ms, &data); + END_PROFILE_NESTED(Trans2_findnext); break; case TRANSACT2_QFSINFO: + START_PROFILE_NESTED(Trans2_qfsinfo); outsize = call_trans2qfsinfo(conn, inbuf, outbuf, length, bufsize, ¶ms, &data); + END_PROFILE_NESTED(Trans2_qfsinfo); break; case TRANSACT2_SETFSINFO: + START_PROFILE_NESTED(Trans2_setfsinfo); outsize = call_trans2setfsinfo(conn, inbuf, outbuf, length, bufsize, ¶ms, &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, ¶ms, &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, ¶ms, &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, ¶ms, &data); + END_PROFILE_NESTED(Trans2_findnotifyfirst); break; case TRANSACT2_FINDNOTIFYNEXT: + START_PROFILE_NESTED(Trans2_findnotifynext); outsize = call_trans2findnotifynext(conn, inbuf, outbuf, length, bufsize, ¶ms, &data); + END_PROFILE_NESTED(Trans2_findnotifynext); break; case TRANSACT2_MKDIR: + START_PROFILE_NESTED(Trans2_mkdir); outsize = call_trans2mkdir(conn, inbuf, outbuf, length, bufsize, ¶ms, &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, ¶ms, &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/source/utils/smbcontrol.c b/source/utils/smbcontrol.c index 62019d40361..3d17ec11231 100644 --- a/source/utils/smbcontrol.c +++ b/source/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));